Skip to main content
GameDev.net gamedev.net
🔒 Locked

Game Level Map "Endless" scrolling

Started by felty Feb 16, 2007 at 4:56 PM 6 replies 2k views
Original Post
felty
felty
I've been trying to figure out how to do this, and what the best method would be. Oh, and I'm talking about 2D, not 3D. So far, I've thought of having 9 map arrays. Each map array has two dimensions, and each location in the array represents the information for one tile. The center map array would be the one they are on, then the other 8 would be the ones to the N, S, E, W, NE, NW, SW, and SE, respectively, so when they hit the edge of the center map, then it starts to scroll onto the next map. Then at some point, it needs to quickly copy a bunch of the map arrays into a different map array, and load a few new maps, and unload a few of the old ones, shortly after the player steps over the boundary line. It's all tile-based. So, does anyone have a better way of handling this? I'm not sure how distance across map calculations could be done either. I believe someone referred to this as blending or something.
wodinoneeye
wodinoneeye
Quote:
Original post by felty
I've been trying to figure out how to do this, and what the best method would be. Oh, and I'm talking about 2D, not 3D.

So far, I've thought of having 9 map arrays. Each map array has two dimensions, and each location in the array represents the information for one tile. The center map array would be the one they are on, then the other 8 would be the ones to the N, S, E, W, NE, NW, SW, and SE, respectively, so when they hit the edge of the center map, then it starts to scroll onto the next map. Then at some point, it needs to quickly copy a bunch of the map arrays into a different map array, and load a few new maps, and unload a few of the old ones, shortly after the player steps over the boundary line.

It's all tile-based. So, does anyone have a better way of handling this? I'm not sure how distance across map calculations could be done either. I believe someone referred to this as blending or something.




The size of the 'maps' has to be large enough compared to the visible area the player sees such that the player (in the transition) does not see a blank edge while the system is loading/generating the next row/column of 'maps' (which if you move diagonally can be as many as 5). (The map size has to be larger than the furthest distance seen... You have to give adaquate time at maximum move rate before the player is allowed to see that new edge.)

You could use a larger array 5x5, 7x7, etc.. of smaller 'maps' if the load processing is significant (as in delay/lag because of file access). Consider a case where the player quickly moves back and forth across a map boundry, causing a reverse of the transition each time. A caching scheme that keeps the recently used 'maps' in memory can greatly lower the processing required for that case.

I use the same scheme in 3D with a 15x15 grid of maps (in 3D there is also LOD (level of detail) considerations for distant 'maps' at the horizon...)
--------------------------------------------[size="1"]Ratings are Opinion, not Fact
Captain P
Captain P
That's about the basic approach, yeah. You may want to think about when exactly you load and unload map segments: don't unload old segments when you load new ones, at least don't use the same border for both: what if the players takes two steps back? Your program would unload the freshly loaded segments and load in the just unloaded segments. Some loose boundaries would come in handy there: load early, remove late.

Or, well, you could do some tests to see what works best in your game. If there's not a lot of backtracking involved then you could keep the boundaries pretty tight, or perhaps you want this to be region-specific.
OrangyTang
OrangyTang
Quote:
Original post by TheAdmiral
The Continuous World Of Dungeon Siege is often cited as 'mandatory reading' on this forum. It's certainly relevant, but may be a bit advanced for your purposes. Nevertheless, it's one to bookmark.

Admiral

I does make apparent the hidieous complexity of dealing with game entities which may appear or disappear at any point though. o_O

I wonder if in many cases you could keep the gameplay aspects of the world always loaded in memory (eg. game entities, scripts, enemies, etc.) and only stream in and out the bigger, non-important resources (textures, sprites, sounds, music, etc.). This might be a nice trade off - no 'infinite' worlds but much, much easier to code and less obscure bugs.
Sirisian
Sirisian
For tiles. Someone previously mentioned "Consider a case where the player quickly moves back and forth across a map boundry" The simplest fix for that is to make the unload boundary further from loading boundary. This will keep map tiles in the memory for a longer time before unloading. This also means a player has to be moving away from the center of the grid to begin loading new sections.

Something else you may decide to do is to use zones. This means that not all sections of the map exist. Every edge of a section has an ID for the new section in a given direction.

I'd recommend making a texture manager that manages when textures need to be loaded. So if a texture isn't used for like x tiles steps it gets unloaded.
felty
felty
Alright, thanks for the help. I'm going to Disneyland for about a week, so I'll be sure to print out the article linked to above and read it.
stormwarestudios
stormwarestudios
Quote:
Original post by felty
I've been trying to figure out how to do this, and what the best method would be. Oh, and I'm talking about 2D, not 3D.

So far, I've thought of having 9 map arrays. Each map array has two dimensions, and each location in the array represents the information for one tile. The center map array would be the one they are on, then the other 8 would be the ones to the N, S, E, W, NE, NW, SW, and SE, respectively, so when they hit the edge of the center map, then it starts to scroll onto the next map. Then at some point, it needs to quickly copy a bunch of the map arrays into a different map array, and load a few new maps, and unload a few of the old ones, shortly after the player steps over the boundary line.

It's all tile-based. So, does anyone have a better way of handling this? I'm not sure how distance across map calculations could be done either. I believe someone referred to this as blending or something.


Two of the greatest articles I've read on the subject are the articles by Jason McIntosh and Greg Taylor.

The copying itself is not really necessary, when swapping memory pointers would be more effective.

What I'm doing for my game, Odyssey, is building a list of 'map chunks', which are 16x16-tile areas of map. The game map itself is an x*y array of indices to these map chunks, which offers a disk-space savings of maybe 50% compared to a map which uses completely unique map-chunks. This allows for both very large map spaces, as well as allows me to load the game map entirely in memory. During the rendering process, sections of the map are drawn based on the player's world x,y coordinates.

This is a combination of a couple different systems, namely the ones described in the linked articles above, and Ultima VII's "map-chunk" system.

Granted, the technology is dated, but the tradeoff of such a system is never seeing a "Loading..." screen.


[Edited by - DarkHorizon on February 20, 2007 10:38:27 AM]

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.