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.
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!
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.
The game has some issues, the most important one resulting in jerky animations. See this issue on GitHub for a workaround.