Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

Lunatic Raven

Large Map Management

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

I am designing a Tile based Map engine, and I want to be capable of have landscapes that are incredibly large. I don''t want one huge map though. I want to break it up into smaller maps to use less memory. What is the best way to setup this kind of engine? I have been thinking of creating smaller maps of a uniform size, like 100 x 100, and using a spreadsheet to store where the maps go. Would this work? I was also looking into Quad trees, to help with the drawing of the maps. Any thoughts on the subject would be appreciated. Thanks in advance!

Share this post


Link to post
Share on other sites
Advertisement
I''m doing the same thing. I dont think these days you are going to
have any trouble creating large maps using tiles. Tiles were origanaly
dreamed up to alow for large areas back in the day of little
resources. Even old machines now have more than enough
juice to run a tile engine without too much trouble. The main
issue in memory will most likely be the amount you use for animation
and the number of individual tiles you alow. The size of the map
itself probably won''t concern you much. You shouldn''t have to
make each section a uniform size. Only do that if your game
calls for it. My first engine alowed for what ever size I wanted.
I had an undeclared array that held the tile values for the
active portion of the map. I belive I may have had to do some
type casting trick to look them up in the 2d array with the current
dementions I was using at the time but It worked great. The array
was actualy an array of pointers to tile sructures with information about the tile and othes that might be layered on top
of it. There are ways to make the levels any size YOU need. You
dont have to be forced into any set box size. Anyway I don''t
realy know as much as I pretend to. Most everything I know
I read out of a couple of articles written by people much smarter
than I am. I guess you my have already checked the ones here out.
Maby this will help a bit and hopefuly all the other smart guys
here will have some good tips.

Share this post


Link to post
Share on other sites
Maybe I should explain more. I have the basic Map Engine done. But what I want is huge areas, like maybe maps that are 5000 x 5000 big, maybe even larger. I think having a single map this big would hit the FPS. So I was thinking that if I have maybe 100 x 100 maps, I could put them like so.

Map1--Map2--Map3
Map4--Map5--Map6
Map7--Map8--Map9

If each of these are 100 x 100, that would create a 300 x 300 map for me, then I could only draw the sub-map that I am in. Or 2 of them if I am traversing maps. For example, if I was in Map 9, there would be no need to draw maps 1, 2, 3, 4, and 7. I would only have the draw the map that I am in, and the ones adjacent to it, for when I move into them.

I just really was wondering what would be the best method to organize this.

Edited by - Lunatic Raven on September 23, 2001 5:40:03 PM

Share this post


Link to post
Share on other sites
I''m just fealing chatty today. I though I would mention that
By recomendation I used liked list to define layers to concerve memory.
I defined my map as an array of structures with the tile
data something like this.

tile_stuct
{
tile_struct next*;
char type;
}

I used unsined char to give me 256 tile types at one time
but an int
would give you as may as you wanted. Or you could just
point directly at the image data in memory if you wanted.

Someone correct me if I''m wrong on amounts but
thats one byte for the type and 4 bytes for the pointer.
and maby another byte if you wanted to add an event value
to let you know if its solid gound VS pit or somthing.
A total of 8 or so bytes per tile. In a world where we messure
bytes by the million don''t worry about running out of space on
area alone. My old version ran under dos without and extender and
I had maps that were of reasonable size then.

Share this post


Link to post
Share on other sites
Sorry I typed the last thing durring your second post. You shouldn't
need to worry about your fps getting hit. Size wont matter since
you will only be drawing a set amout each time. One screen. Everything else is simply ingnored. If your game requres AI updates
to char off screen that might hurt abit but you wont even need to
check if each tile is on screen. You will simply accsess your
tile array at the current XY position and blit them ignoring the
rest. That make any since? I'm going kinda fast.

You will no doubt want to break your over all areas down for
logic sake. Say as the "Alien ship" and the "Home World" or
what ever. You might try having maps and submaps. Submaps
being each displayable unit of a map. The map just being the
over all collection of smaller maps that are joined together
as you see fit.

Edited by - Goober King on September 23, 2001 5:56:52 PM

Share this post


Link to post
Share on other sites
quote:
Original post by Goober King
Someone correct me if I''m wrong on amounts but
thats one byte for the type and 4 bytes for the pointer.

That''s true, although some compilers may add a few more bytes to pad the struct.



~~~~~~~~~~
Martee

Share this post


Link to post
Share on other sites
Well if what you are looking for is to only draw what you will see on the screen and not everything else just take your world coordinates, figgure out which tile the coordinates corespond to in your map array or however you stored your map. Show however many tiles you need to fill the screen. something liek this:

//the amount of tiles it will take to fill the screen
screen_tile_fill_x=world_x+20;
screen_tile_fill_y=world_y+20;

world_x=5;
world_y=5;

for(int x=world_x; x for(int y=world_y; y

//Blt all of your tiles according to x and y
//if the tiles don''t fill the whole screen than increase the till fill
// all of this is assumeing that you have a function that already blts or copies the tiles that you want and also that you have two global variables keeping track of the world coord which you should have for scrolling


}

}


anyway that is just a stripped down version. you would have to add all of your tile checking a copying code. but with this it will allow you to store the whole 5000x5000 map in say a array and then only copy the tiles that the user will see and not worry about any of the others so instead of bltting 5000x5000 tiles you could blt 50X50 at a time this would increase frame rate and you would not have to divide your large map up anyway this is just the way i would do it.

you can lead a horse through water, but you CAN make him drink.(he may or may not drown with this process)

Share this post


Link to post
Share on other sites
If you do a search on old messages from this forum, you will find a thread where we discussed just this topic... in particular, we theorized how Ultima Online accomplished their large maps. Here is my advice, in order of importance:

1) Don''t do it. If you are making a really LARGE map just for the sake of making a large map, you might need to rethink your motives. Is it really necessary for your game? What you are describing is technically quite feasible... the hard part then becomes actually filling your world with interesting geography to explore. If you can''t do that, then you shouldn''t make the map very large... if, on the other hand, you''re just doing it for a technical demo... then read on.

2) Meta-tiles. Tiles made up of other tiles. Read the old thread.

3) Dynamically load individual map sections off disk as the map scrolls. Trust me, your hard drive is plenty fast for this. Read the old thread.

4) Compress your map data. If the "Plains of Magrathea" are composed of 90% grass tiles, 5% scrub tiles, and 5% other stuff, that data will compress down very tightly. A simple RLE scheme could cut your memory usage dramatically.

Share this post


Link to post
Share on other sites
I agree with Pyabo about the geography issue, but if you still want/need obscenely large maps, here is my suggestion.

When I started I wanted to have the capabilities for two things, a world of unlimited size and I did not want to have "zones" (to use a EQ term) I wanted it to be fluid. So this is what I came up with after reading a newsgroup thread a long time ago about Ultima 5.

1) Break your UberMap into sizeable chunks, lets say 256x256... play with this number for best results. The tradeoff here is how often you go to the disk vs the ammount of memory you will need to run your program.
2) Load the map the PC is on, and all adjacent maps like so. Assume player is on map (not tile) 8,4

+-----+-----+-----+
| 7,3 | 7,4 | 7,5 |
+-----+-----+-----+
| 8,3 |(8,4)| 8,5 |
+-----+-----+-----+
| 9,3 | 9,4 | 9,5 |
+-----+-----+-----+


Now, the player roams about Map(8,4) and moves over to 8,3. If the player moves 10% of the way into 8,3, it is safe to assume that they are there to stay.

3) Unload the farthest maps from the player (in this case (7,5), (8,5), and (9,5))

4) Load the enough maps to maintain the 3x3 map (in this case (7,2), (8,2), and (9,2)). Like so:

Player is now at (8,3)
+-----+ +.....+
| | = Loaded map | | = Freed Map
+-----+ +.....+

+*****+
| | = Map about to be loaded
+*****+

+*****+-----+-----+.....+
| 7,2 | 7,3 | 7,4 | 7,5 |
+*****+-----+-----+.....+
| 8,2 |(8,3)| 8,4 | 8,5 |
+*****+-----+-----+.....+
| 9,2 | 9,3 | 9,4 | 9,5 |
+*****+-----+-----+.....+


See? This gives your program more than enough time to load (probably with a different thread) the new maps without having to have to have a brief pause between maps.

Since you don't have a 5000x5000 or even a 5,000,000x5,000,000 map in memory, you are free to use the memory saved to lower your requirements (no reason that a simple tile engine require 128MB of RAM) or put it to better use for AI, graphics, etc.

The beauty of this method is that you can thoeretically have an unlimitedly sized map.... and infinite map

Well, I hope this helps.

-OberonZ


Edited by - OberonZ on September 24, 2001 11:37:33 PM

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
Why not just use the MapViewOfFile function and let your OS page the data in and out as needed? Window''s paging algorithms work pretty well.

Just make sure you only draw the stuff that''s visible!

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!