• Advertisement
Sign in to follow this  

Making 2D-Platformer Levels

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

Suppose you are making a 2D platform game. You are now at the stage where you need to design the levels. This game you are making can be tile based or have epic graphics. It also uses Box2D/Chipmunk/<Insert your favourite physics engine here> to manage the collisions and physics.

Well, I am doing exactly just that and until now, I have been drawing 50 by 50 tiles in Gimp, then loading them in to my game and drawing them according to a little text file which defines the level (e.g. a "2" means grass tile). But now, I have had a thought. Wouldn't it be easier if you just opened up Gimp/Photoshop and actually drew the level your self? This would be very easy to do: open a tile, copy it and paste it on to your level and then move it around depending on where you want it. Then you could save it as .png and load it in to your game. Then, you could tell the physics engine where the ground is etc. (basically creating bodies in the case of Box2D).

So, is this a better way to create levels in a game (like the one described)? You could easily move and edit the tiles around or even eliminate the need for tiles altogether and have a vectorial game. Then you could just load the saved image and display it and that would be it.

Share this post


Link to post
Share on other sites
Advertisement
You [i]can[/i] do that, but it raises some issues. Firstly, the levels are no longer dynamic. You can't edit them in a map editor, for instance...and that's one of the strengths of tile-based games. Also, you'd probably want to chunk the map, assuming it's the size of a level in a typical platformer, so that you could load and unload pieces of it at different times as the player progressed through the level.

Share this post


Link to post
Share on other sites
Good point, but I presume this is how vectorial levels as explained in the last part of this post:

http://higherorderfun.com/blog/2012/05/20/the-guide-to-implementing-2d-platformers/

Are made then?

Share this post


Link to post
Share on other sites
Yes, in general, you would want to break the level art into pieces and load them on an as-needed basis. You may even need to break it up anyway if it's sufficiently complex and difficult for your image editing program to handle (We've had this problem.) For a small level though, you can probably get away with loading a single image.

Share this post


Link to post
Share on other sites
Also, I had this other idea:

1. Use Gimp / Inkscape as a level editor and save the level as a png file
2. Use The Python Imaging Library to load the image and iterate through it
3. Compare each 50x50 portion of the file to the tiles in a tile set.
4. If a the images are the same (if the 50x50 area of the level is, for example, a grass tile) then write to a .json file (or something similar) which will be used to store data about the level.

This method isn't that useful for graphics, but if you are using something like Box2D, then you can easily save where the bodies are and where the collisions will happen, just by looking at a tile map.

So would this be a good way to do things? Edited by TheVirtualDragon

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement