Creating a 2D Platform Game


  • Creating a Tile-Based Map
  • Collision Detection
  • Finishing Things Up and Making It Fast
  • Creating an Executable .jar File
  • Ideas to Expand the Game
  • Summary

This is where the fun starts. The previous chapters covered the basics of using Java to create graphics, sound, and interactivity. In this chapter, you're going to use what you created in the previous chapters to create a real 2D platform game. Platform games are games in which the player runs and jumps from platform to platform, avoiding bad guys and collecting power-ups. To create a platform game, in this chapter you'll learn about tile-based maps, map files, collision detection, power-ups, simple bad guys, and parallax background scrolling. Check out the screenshot of the game you'll create in Screenshot.

Screenshot In this chapter, you'll create a 2D platform game with tile-based maps, bad guys, and power-ups.

Java graphics 05fig01.jpg

NOTE This chapter is less about Java-related technology and more about game-programming techniques, so not all the code for the game is presented here. Instead, you can get the code from the website,, as always.