Making 2D-Platformer Levels

Started by
3 comments, last by TheVirtualDragon 11 years, 8 months ago
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.
What's This?: basically, it's my blog. Click on it.
Advertisement
You can 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.

Between Scylla and Charybdis: First Look <-- The game I'm working on

Object-Oriented Programming Sucks <-- The kind of thing I say

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?
What's This?: basically, it's my blog. Click on it.
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.

Between Scylla and Charybdis: First Look <-- The game I'm working on

Object-Oriented Programming Sucks <-- The kind of thing I say

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?
What's This?: basically, it's my blog. Click on it.

This topic is closed to new replies.

Advertisement