Tuesday, May 20, 2014

Classic game programming: Pong

I originally started this blog to share a silly little game called Jumpman I wrote as an example of the State design pattern. Jumpman was pretty popular with my students and it made me realize that games might be a great way for me to get my students to roll up their sleeves, study my code and make games of their own.

I got back into game programming with the previous posts on game loops and I'd like to continue by releasing the first finished game: Pong.


Topics

The topics covered in this game are:
  • A game loop with variable time steps (as explained in the previous posts).
  • Game objects.
  • Keyboard controls.
  • Collision detection and 'faked physics'.
  • A simple AI to control the opponent paddle.
  • Multiple screens and switching between them.
  • Sound effects.
  • Scaling the screen while respecting the aspect ratio, using letter- and pillarboxing.
The code should contain enough comments to allow you to figure out what it does. Go read it!

Source code

The source code is available on GitHub:


Make sure you get the master branch, and run it on JDK 8. See this post if you're new to Git and/or Maven. It explains how to get the code from GitHub and run it in NetBeans.

Known issues

The game has some issues, the most important one resulting in jerky animations. See this issue on GitHub for a workaround.

No comments:

Post a Comment