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

Homer Simpson

Storing isometric coordinates

Recommended Posts

Hi guys! i want to know if storing the coordinates in the map matrix is a good idea. (my english sux i ´ll give u an example) e.g: matrix [1][1].tile=1; matrix [1][1].coordx=2; matrix [1][1].coordy=3; .... an then i do a for that goes throught each array end shows it ... does it is a good idea? SOrry about my english.... __________________ ::Homer Simpson::

Share this post

Link to post
Share on other sites
there''s no need to do that.
you should have a function, that converts map coordinates (ie. index x,y of a matrix) into screen or world coordinates.
for example, in a diamond map, this function would be something like:

//POINT is a structure that has .x and .y
POINT MapToWorld(POINT ptMap)
POINT ptWorld;
ptWorld.x = (ptMap.x-ptMap.y)*TILEWIDTH/2;
ptWorld.y = (ptMap.x+ptMap.y)*TILEHEIGHT/2;

return (ptWorld);

you can tell the function (or make more versions of it) if you''re using a different map type.
that way you don''t have to give the tiles numbers, either. just run through the matrix x and y.

Make something idiot proof, and someone will make a better idiot..

Share this post

Link to post
Share on other sites