javascript - I want to build a minimap for my HTML5 game, how do I start? -
assume have big map uses background image pattern. want place minimap @ corner when moving player around. need minimap display player in big map , other sprites in map, using coarse representation , keeping relative location shows in smaller map. think basic , simple minimap. player in middle of screen (i have done that) , minimap stay @ corner of screen. if want build such feature game, how start?
assuming main map in container element, need measure scroll property of element establish @ position relative center of container (or screen).
if calculate x , y proportion (eg %) of map, can place on mini map @ same relative position.
the placing of mini map on main map of no importance.
to position of map relative screen, try document.getelementbyid("map").getboundingclientrect()
. x , y values in resulting array tell position of top left of map top left of screen. width , height of map included in array. add screen.width/2
, screen height/2
coordinates of map in center of screen.
Comments
Post a Comment