I have a math problem

I want to build tiled world wich has maps and those maps have tiles. I have hard time calculating the tile window positions from the world height, width and map x,y and map height, width and tile x,y and tile height, width.

math-problem

I have tried quite few things to calculate tile x to window coordinates.

I know that I can calculate one map by doing

xposition = tileX * tileWidth – tileWidth;
yposition = tileX * tileWidth – tileWidth;

I can not get it right when calculating with world. Any help?

Comments

23. Aug 2014 · 13:50 UTC
xposition = (mapX * mapWidth) + tileX

yposition = (mapY * mapHeight) + tileY
23. Aug 2014 · 13:59 UTC
You want the screen position of each tile? You’ll also need to know which map you’re currently showing (mapx, mapy)
23. Aug 2014 · 14:21 UTC
Winterblood! Awsome thanks!