Jump to content
  • Advertisement


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

Homer Simpson

Storing isometric coordinates

This topic is 5858 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

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

  • Advertisement

Important Information

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

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!