The guide to implementing 2D platformers


Game programmer and designer Rodrigo Monteiro (@amzeratul) has published a thoroughly in-depth guide to building 2d platformer games. In presenting the four different ways to build a 2d platform, Rodrigo does a great job of introducing the concept behind each theory without immediately giving away the actual implementation. I consistently found myself thinking in my head, “Hmm…now how would I go about solving that problem?” Much of the article is kept language agnostic, so you may be tempted as well!

A few quick takeaways and lessons learned:

  • If you’re unsure which type of platformer you want to implement, and you want to do an action game, Monteiro suggests a smooth tile-based implementation (example #2)
  • Ladders are typically one tile wide to restrict movement along the y axis (a notable exception would be the vines your climb in Mario 2)
  • Moving platforms are typically implemented using AABB (Axis-Aligned Bounding Box)—the same method for your playable character
  • Flash developers will be familiar with the concept of “bitmasking” or drawing a separate non-linear hit area used for collision detection. With this method, collisions are performed much the same way as tile-based, except that the pixels themselves are the actual “tiles”
  • When implementing physics-based engines such as Box2d, friction must often be accounted for depending on the direction of movement. In Monteiro’s words, “you’ll want friction to be high on the foot, but low on the sides.”

Go have a look for yourself! The Guide to Building 2d Platformers