Jump to content
  • Advertisement
Sign in to follow this  
CelticSir

Positioning sprites on a map in JS

This topic is 2472 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hey

I'm really confused how to place a sprite on a map grid correctly in JavaScript.

I draw my isometric grid with this loop which works perfectly fine:


for (i=0;i<tiles_wide;i++){ //horizontal

for (j=0;j<tiles_long;j++){ // vertical

var x = (i-j)*(img[0].height/2) + (ctx.canvas.width/2)-(img[0].width/2);
var y = (i+j)*(img[0].height/4);
abposx = x + offset_x;
abposy = y + offset_y;
ctx.drawImage(img[0],abposx,abposy);
}
}


But i am stuck on how to store and input sprites into this so they appear on the grid =/ I can't work out the logic at all =/

Any one able to help explain ?

Share this post


Link to post
Share on other sites
Advertisement
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!