Michdd Posted September 6, 2009 Share Posted September 6, 2009 I'm trying to create a function to calculate the coordinates for the center point of a tile on an isometric map. I can calculate the center of the tile (0, 0) but I'm having a problem going from there.. $tileWidth = 48; $tileHeight = 24; //Then say I have the (0, 0) in this Array $base = Array($baseX, $baseY); Where would I go from there? Link to comment https://forums.phpfreaks.com/topic/173293-solved-isometric-coords/ Share on other sites More sharing options...
Michdd Posted September 6, 2009 Author Share Posted September 6, 2009 For each addition to the x asix the x coordinate goes up tileWidth/2 and the x coordinate goes up tileHeight/2 But it's not like I can just do: base[0] = (tileWidth/2) * x; base[1] = (tileHeight/2) * y; Because both the x and y change for every tile. Link to comment https://forums.phpfreaks.com/topic/173293-solved-isometric-coords/#findComment-913470 Share on other sites More sharing options...
corbin Posted September 6, 2009 Share Posted September 6, 2009 Can you explain the isometric map? I know what an isometric map is, but I'm not quite sure how you're deciding where the units are on it. Link to comment https://forums.phpfreaks.com/topic/173293-solved-isometric-coords/#findComment-913485 Share on other sites More sharing options...
Michdd Posted September 6, 2009 Author Share Posted September 6, 2009 I'm not really sure what you mean. It's just an isometric map, they all fit together the same (At least I think so) I have a formula for getting the X and Y location for placing the tiles down, but I'm not sure if it's optimized.. Anyway for finding where the tiles go I use this(Although I'm not sure how this helps) The loop is like.. for($i = 0;$i < $mapHeight;$i++) { for($j = 0;$j < $mapWidth;$j++) { X point: (((($j * TILE_WIDTH)-($j * (TILE_WIDTH/2)))-($i * (TILE_WIDTH/2)))+($mapHeight * (TILE_WIDTH/2)))-(TILE_WIDTH/2) Y point: ((($i * TILE_HEIGHT)+($j * (TILE_HEIGHT/2)))-($i * (TILE_HEIGHT/2))) That would probably be made easier, I haven't really thought about it too much. I don't see how that is relevant though.. Shouldn't I be able to calculate the X and Y of the center of any tile given the tiles position if I know what (0, 0) is? Link to comment https://forums.phpfreaks.com/topic/173293-solved-isometric-coords/#findComment-913490 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.