Isometric map rendering
Hi,
Im sure this question has been asked before, but i have been unable to find a solution anywhere . I have attempted to render maps of isometric tiles before and simply offset every second row by half the tilewidth and half the tile height, producing a jaggered rectangular map. What im trying to do is keep the map stored in a 2d array but interpret the map in-game as diamond shaped. Can someone please explain to me a method used to do this, or any hints about problems i may face?
Thanks in advance,
Michael Cleaver.
the type of map you describe is what i refer to as a diagonal or diamond iso map, and it is the type used in sim city, aoe, etc.
the x and y axes go in diagonal directions, which is probably what''s giving you trouble.
make the top corner of the map tile (0,0) -- actually, any corner will do.
pick a direction for x to increase (either southeast or southwest, i usually pick southeast), and the other direction is the direction for y.
now, assuming you are using 64x32 tiles, to move in the x direction you add +32,+16, and to move in the y direction you add -32,+16.
so, to render your tiles...
int tilex;
int tiley;
for(int y=0;y<mapheight;y++)
{
for(int x=0;x<mapwidth;x++)
{
tilex=x0+x*32-y*32;//x0,y0 is a reference point for the upperleft corner of tile (0,0)
tiley=y0+y*16+x*16;
//use tilex and tiley to blit your tile
}
}
this will give you the map shape you are looking for.
fyi-the type of map you wound up with (the jagged rectangle) is what i refer to as a staggered map. it is used in games like civilization.
the x and y axes go in diagonal directions, which is probably what''s giving you trouble.
make the top corner of the map tile (0,0) -- actually, any corner will do.
pick a direction for x to increase (either southeast or southwest, i usually pick southeast), and the other direction is the direction for y.
now, assuming you are using 64x32 tiles, to move in the x direction you add +32,+16, and to move in the y direction you add -32,+16.
so, to render your tiles...
int tilex;
int tiley;
for(int y=0;y<mapheight;y++)
{
for(int x=0;x<mapwidth;x++)
{
tilex=x0+x*32-y*32;//x0,y0 is a reference point for the upperleft corner of tile (0,0)
tiley=y0+y*16+x*16;
//use tilex and tiley to blit your tile
}
}
this will give you the map shape you are looking for.
fyi-the type of map you wound up with (the jagged rectangle) is what i refer to as a staggered map. it is used in games like civilization.
Get off my lawn!
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement