Game Development Stack Exchange is a question and answer site for professional and independent game developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm doing a 2D platformer but I don't know how they are usually built.

The approach I'm looking at is making it tilebased, with ground tiles on bottom row, then platforms on some places in "mid-air" within the array.

Then some physics to add gravity to pull the player down if airborn, and just scroll the map horizontally and check for collisions.

Am I on the right track? Thank you.

share|improve this question
Make sure that the graphics are pixelated if you want to get anywhere. – jcora Jun 26 '12 at 13:08
up vote 6 down vote accepted

I'm going to share a link with you that someone else had shared with me:

This page covers several approaches as to how one might implement 2d platformers with both basic and some more advanced mechanics. It doesn't give you straight up code but it does a fantastic job at explaining the techniques so that you should be able to code it without too much trouble.

share|improve this answer
That article is very helpful. It doesn't mention background scrolling, though, which can in some cases be challenging. I think the important thing to remember with regards to scrolling is that your tiles (or non-tiled world) have to be translated into pixel positions first based on where the camera is. While most of my programming has been in 3D, it stands to reason that in 2D games you still want to mostly disassociate the camera from the world. In pure side-scrolling platformers you may end up locking the camera vertically to the character while giving them some "play" horizontally, etc. – gkimsey Jun 26 '12 at 20:27
Thank you for the link, just what I was looking for. – justanotherhobbyist Jun 26 '12 at 23:30

Try using Tiled, which is a great free map editor. You can build your own level with it, and then load the output file (a XML) into your application (generally Tiled compacts everything with gzip and then converts to base64, but there are libraries to load that).

As for the code, yes. You could see it as a big array.

share|improve this answer

I would buy the Level UP book: This is the only one with a broken spine & dog eared pages currently on my shelf.

Also read the author's blog for awesome ideas, particularly his Platformer Primer:

share|improve this answer
Thanks, I'll look into that. – justanotherhobbyist Jul 12 '12 at 19:23

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.