Jump to content

[SOLVED] isometric coords


Michdd

Recommended Posts

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

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.

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?

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.