Jump to content

  • Log In with Google      Sign In   
  • Create Account

Awesome job so far everyone! Please give us your feedback on how our article efforts are going. We still need more finished articles for our May contest theme: Remake the Classics

Making a large tilemap


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
5 replies to this topic

#1 Jeffsg605   Members   -  Reputation: 100

Like
0Likes
Like

Posted 17 March 2012 - 08:48 AM

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!

Sponsor:

#2 JustinDaniel   Members   -  Reputation: 136

Like
0Likes
Like

Posted 17 March 2012 - 10:50 AM

What is the best way to load in large maps like this?

Use two-dimensional vectors to hold a map file.
std::vector< std::vector<int> > map;
I made my top down shooter by that way.

#3 Servant of the Lord   Marketplace Seller   -  Reputation: 8955

Like
0Likes
Like

Posted 17 March 2012 - 11:15 AM

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?

All glory be to the Man at the right hand... On David's throne the King will reign, and the Government will rest upon His shoulders. All the earth will see the salvation of God.

Of Stranger Flames - [indie turn-based rpg set in a para-historical French colony] | Indie RPG development journal


#4 Jeffsg605   Members   -  Reputation: 100

Like
0Likes
Like

Posted 17 March 2012 - 06:15 PM

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.

#5 Servant of the Lord   Marketplace Seller   -  Reputation: 8955

Like
0Likes
Like

Posted 17 March 2012 - 06:34 PM

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.

All glory be to the Man at the right hand... On David's throne the King will reign, and the Government will rest upon His shoulders. All the earth will see the salvation of God.

Of Stranger Flames - [indie turn-based rpg set in a para-historical French colony] | Indie RPG development journal


#6 Jeffsg605   Members   -  Reputation: 100

Like
0Likes
Like

Posted 17 March 2012 - 06:42 PM

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.




Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS