Pong

Classic game programming

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

Introduction

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?

Screenshot

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.

Download

The source code is available on GitHub.