# Making a large tilemap

This topic is 2458 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

I am making a top down driver shooter that takes place in a town somewhere. I am currently making a tilemap but I am finding that very few of the tiles are actually going to be the same as each other and that kind of defeats the point of a tilemap. What is the best way to load in large maps like this? Currently I'm using 16 1024 x 1024 pixel images but I get some lag when switching which images are shown. Is there any better way? Or is this where separate threads are needed?
Thanks guys!

##### Share on other sites

What is the best way to load in large maps like this?
[/quote]
Use two-dimensional vectors to hold a map file.
 std::vector< std::vector<int> > map; 
I made my top down shooter by that way.

##### Share on other sites
You say 'tile map', what size are your tiles? Are your tilemaps 1024x1024, or are the tiles themselves 1024x1024?

Why not load each tile separately, and only load the ones you need at the time?

I think more details are needed, I'm not sure I understand the exact situation.
What is the resolution of each tile?
How many tiles are in each level?

##### Share on other sites
Ideally, my tilemap tiles would be 64 x 64 pixel png's. Right now I'm just using large images that are 1024 x 1024 pixels. I would like to make my map quite large if possible. Maybe 200 x 200 tiles would do but bigger would be better. To better explain the situation, I want the player to be able to move anywhere in the map he can. Right now, I am drawing the map using 16 1024 x 1024 pixel images. I draw the image directly under the player and the 8 images around the player (i.e. top, top right, right, bottom right, etc) and when the player enters a different 1024 x 1024 image, I make that image the center and draw the ones surrounding it. When the program changes which images are drawn, I get a little lag. So I'm wondering how I would avoid this lag and be able to use a large map.
Thanks for the help so far.

##### Share on other sites
To avoid the lag, switch from drawing/loading the large images, and move to the 64 x 64 tiles. That'll pretty much solve the problem.
Unless every single tile on-screen is unique, you'll end up saving several million pixels you have to load.

Your maps can be as large as you want, just split them into chunks and load each chunk only when the player comes within range of it.
If you make each chunk 16 by 16 tiles, they'd be the exact same size as your 1024 by 1024 images, so you just load the 9 chunks around the player, and free any old chunks that are now out of range.

Make the chunks share the tiles; if chunk (0,1) and chunk (1,1) are both onscreen at the same time, and they both use tile "../tiles/rock.png", then you only need to load that tile once, and have both chunks use that same tile. And each chunk might be using and drawing that same image several dozen times... but they don't need to load it several dozen times, only load it once, and free it when no longer needed. This is easier if you don't let the chunks own the image, but have another class own the images and load the images and free the images, that the chunks can talk to when they need a tile image.

##### Share on other sites
I see your point, I will give that a try. I haven't made the final version of the map I want to use yet so I'm sure there will be more overlap in tiles than I think there will be. Even if there are a lot of unique tiles, it sounds like loading from a tilesheet will be a lot faster than loading several large images. Thanks guys.

1. 1
2. 2
3. 3
Rutin
21
4. 4
5. 5
khawk
14

• 9
• 11
• 11
• 23
• 10
• ### Forum Statistics

• Total Topics
633653
• Total Posts
3013152
×