Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

2D All the way! / Effienctly Saving Maps

Author
Message
Xlaydos
22
Years of Service
User Offline
Joined: 26th Mar 2004
Location:
Posted: 5th Mar 2006 16:17
What is the most effienct way to save a map? Is it to save 2 maps, the collision nap and a bitmap with all the nice looking things on it. This is for a 2D platformer.

Thanks
Ian Price
20
Years of Service
User Offline
Joined: 4th Mar 2006
Location:
Posted: 5th Mar 2006 16:44
The most efficient method of creating any level would be to store the graphics as individual tiles (and not one big bitmap of the whole level) and save the values of the tiles in an array/table and save this only (saving as bytes if there are less that 255, ints if there are more than 255 tile values).

If you have more than one layer of tiles eg platforms and enemies bonuses etc. you could still use the same array - eg. if the level consisted of 10x10 tiles then the platforms could be saved in the first 100 bytes (0-99 in the array) and then the enemies etc would be saved at position 100-199.

Obviously you'd need to construct a level editor, but they are usually very easy to do, which uses the input and stores the information from your level in a savable array/table. You then just reload this array ready for map reconstruction during the game.

Old's cool
Pincho Paxton
23
Years of Service
User Offline
Joined: 8th Dec 2002
Location:
Posted: 5th Mar 2006 21:40
You can do that. Usually the bitmap is made of square tiles, so you would save just the numbers of the tiles, and not the actual bitmap.

Xlaydos
22
Years of Service
User Offline
Joined: 26th Mar 2004
Location:
Posted: 5th Mar 2006 22:08
I thought it would be faster to only have to scroll 1 big sprite as opposed to many small sprites (in the actual game not mapeditor)
Pincho Paxton
23
Years of Service
User Offline
Joined: 8th Dec 2002
Location:
Posted: 5th Mar 2006 23:08
Well you don't really need a map editor in the first place. You can just draw a picture, and add the collision to it.

Grog Grueslayer
Valued Member
21
Years of Service
User Offline
Joined: 30th May 2005
Playing: Green Hell
Posted: 6th Mar 2006 09:47
Quote: "I thought it would be faster to only have to scroll 1 big sprite as opposed to many small sprites (in the actual game not mapeditor)"


You don't want each tile to be a sprite. Use "paste image" for each tile instead. The more sprites you have on the screen the slower your game will be.


Zone Chicken
22
Years of Service
User Offline
Joined: 25th Jan 2004
Location: `~-..-~`~-..-~`
Posted: 7th Mar 2006 01:38 Edited at: 7th Mar 2006 02:00
What Ian Price said i believe is best.
However i have been trying a method simular to what you said but saving rooms not the whole level as one giant map.
I've been working on a editor for a couple weeks although i only get to use dbp on the weekends.
The setup i am using currently is 64 x 64 tiles these are placed on a grid with the mouse creating my level these are the visible tiles.



Then after that is build have another overlaying grid alpha so transparent and create a collision grid over it placing c where collision needs to take place and a p where the player starting position is.



Then saves the first out as a single image file and the second grid is then read and written to a file storing a 1 if the grid = x, a 2 if the grid = p, and a 3 if the grid = c then in the tester program i load the image saved then use another array to read the collision file and place the tiles accordingly hiding the c sprites.



Thats as far as i am collision is a little iffy right now and needs fixing but that's my shoddy code it does work and is probably the best way to go since you can build any level you wanted in a couple of mins hit one button save it out and just test or play that level.

As for adding in more rooms to i have yet to try that so using a single .png for a background might not be effective enough although my plan is to try and load maybe 3 or 4 rooms at a time when the player reaches a certain point have the next group of rooms load and delete the passing group have to see how fast this would work or not though.

Also if you plan on making more then one 2D game ever i would say take the time and make a editor it will save you from having to code basically the same thing over and over for each game you make so far my editor is only at a mere 369 lines of code thats with comments.

Your signature has been erased by a mod -- please resize to under 600x120...
Ian Price
20
Years of Service
User Offline
Joined: 4th Mar 2006
Location:
Posted: 7th Mar 2006 09:05
Tiles are definitely the best bet for a platform game.

Making a map store it's tiles in an array based format and reloading the data should be instant, even for huge maps. I've written a level editor for a manic miner remake in PlayBASIC that can be seen below - the whole thing is only about 100 lines long, including loading, saving and displaying the map result.

Old's cool
Xlaydos
22
Years of Service
User Offline
Joined: 26th Mar 2004
Location:
Posted: 8th Mar 2006 19:43
Thanks guys

Login to post a reply

Server time is: 2026-07-01 21:22:20
Your offset time is: 2026-07-01 21:22:20