• Forum
  • Lounge
  • Experimenting with 2d isometric tilemaps

 
Experimenting with 2d isometric tilemaps, question

In rectangle maps if you want to render only the visible tiles on screen you can loop through the rectangular portion of the tile map array.

How does one accomplish this is isometric maps, since they aren't rectangular?
Same concept. You can just create a crude rectangle for each tile and check if it's colliding with the camera rectangle.
It doesn't seem that easy though unless you loop through the entire map array every frame.

What i'm trying to do is find which tile is at the very upper left corner of the screen and working from there. But the tiles beside it aren't adjacent in the map array since the axes are diagonal.
Last edited on
It doesn't seem that easy though unless you loop through the entire map array every frame.
No, not unless you load the entire map (Hint: You shouldn't do that). You should loop through the loaded map chunks every frame.
I considered doing something like that but my maps are presently only using 3 bytes per tile so memory didn't seem a concern.
Last edited on
It doesn't matter. Those 3 bytes will add up. If your maps are so small, then you wont have the problem you mentioned before.
How to render an isometric map:

The easiest way would just be to define a rectangle that goes outside the screen, and then render that. Obviously you'll have a fair chunk outside of the screen that can't be rendered, but its still often better than rendering the whole map.

If you want to get clever, you can move along the diagonal axis of your map. Pick a tile just off the top-left corner and go one up, one to the right, and repeat. Then go one down and one to the right from the starting tile and start rendering from there, until you get to the bottom. Change this around based on how you set up your tile grid.

If you are having trouble understanding, draw an isometric grid on a piece of paper. Now draw a rectangle on that isometric grid. Now draw some lines so that they go through every tile in the rectangle, and work out how they are linked.
If you want to get clever, you can move along the diagonal axis of your map. Pick a tile just off the top-left corner and go one up, one to the right, and repeat. Then go one down and one to the right from the starting tile and start rendering from there, until you get to the bottom. Change this around based on how you set up your tile grid.


This is actually what I ended up doing. I feel like an idiot for not realizing this sooner as it's the same technique I was using to get the upper-left corner tile. All I had to do is "move" east and then south.
Topic archived. No new replies allowed.