Many (many) years ago, I was invited to teach a guest lecture on game development to a high school programming class. This small project was used as part of the class.

A shot of the physics demo in action

The small demo project is simple to use - press the arrow keys to fly a spaceship (taken from the classic game Raptor) in all 4 directions, and if you like, you can also use the spacebar to fire two “lasers.”  The included source code is short and well-commented.

As a minor bonus, the sample app also provides code for drawing an animated star field.

Download the sample app and source code from GitHub