Classic game programming

Originally posted on May 20, 2014
Updated on January 26, 2015


After covering game loops in the previous posts, I wanted to continue my explorations into game programming and build a complete game. What better game to start with than good old Pong?


The topics covered in this example are:

  • A game loop with variable time steps.
  • 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 source code is available on GitHub.

If you've enjoyed my work or found it helpful, please consider becoming a patron. Your support helps me free up time to work on my books and projects.