Storing isometric coordinates

Started by
2 comments, last by Homer Simpson 21 years, 10 months ago
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::
__________________::Homer Simpson::
Advertisement
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 .yPOINT 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.

//Demiurge
Make something idiot proof, and someone will make a better idiot..
//DemiurgeMake something idiot proof, and someone will make a better idiot..
thnx guy, but even if I do this function,i will have to stare the "results" in a matrix, wont i???
__________________::Homer Simpson::
No, you just call the function whenever you need the results for a given tile.

[ MSVC Fixes | STL | SDL | Game AI | Sockets | C++ Faq Lite | Boost | Asking Questions | Organising code files ]

This topic is closed to new replies.

Advertisement