• Advertisement
Sign in to follow this  

How should I store tiles in a big world?

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

Hello! I want to make a huge 2d world. I haven't found out how to generate those tiles in a nice way yet but besides that I need suggestions for how to store tiles so that as the character walks the old tiles are replaced by new tiles as they come on screen. I want a 40 by 30 map so thats 600 tiles on screen. Im thinking about a scrolling grid type thing, so that there is an extra layer of tiles boarding the screen but off screen. Basically I just want to see a better way and I know there must be one. Should I maybe load big regions of tiles in anticipation that the player will move there? I'm not very clear on this. Any help is appreciated.

Share this post


Link to post
Share on other sites
Advertisement
Depends on how you do scrolling. If your scrolling is locked to the tile size (you scroll in tile-sized increments), then just redraw all tiles every frame, in the appropriate x,y range. That's usually acceptable for speed. You can also do this for smooth scrolling too, but you have a slower framerate as you have to loop through all the tiles every frame.

If you have smooth scrolling, what you might want to do is blit all your tiles in an area slightly larger than your screen size (say, 4 tiles around each side) to a larger surface image. Then blit the large image when you draw the screen. If the screen threatens to move past the edge of your large image, you redraw the large image so that it is recentered, some time before the screen gets that far. (i hope that made sense).

The problem with that approach is that, while it's faster on FPS, you have a slight "redraw hiccup" when the large image is redrawn when the screen moves to it's edge.

So it comes down to 2 choices:

1) blit all tiles every frame. PRO: no hiccups. Easier to program. CON: slower overall.

2) blit from a larger "buffer" image. Redraw large image as necessary. PRO: faster per-frame blitting. CON: more complicated programming. Redraw hiccups.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement