Pong!
When learning Python, I decided to have a bash at writing a game using Pygame - a Python wrapper for SDL, for the geeks :) The result was a fairly simple Pong game. Reading the source would be a good way to introduce yourself to making a full game in Pygame (after reading the chimp tutorial provided on the Pygame web site). TomPong is also (at time of writing) being used as part of a computer science course in object orientated programming at Princeton University in the USA, as a point of reference for a Java Pong game :)For those interested in making their own games, I have written a tutorial in making games with Pygame that accompanies TomPong. It describes how to go from making things appear on the screen, to implementing a simple game of Pong. You can find it here.
Currently implemented features are:
- A snazzy ball and two equally snazzy bats are drawn onto the screen
- A nice title, and scoreboards for each bat are there too
- The ball moves around with proper, realistic physics (using vectors)
- You can hit the ball with your bat, and if you miss, the other person scores
- You can pause the game with "p", and toggle the fullscreen mode with "f"
- Moving the bat whilst hitting the ball produces spin
- A simple ai with configurable skill level
checkspin()
function in the Ball
class).
TomPong was inspired by, and in part based on, Pypong, which can be found at: http://www.mrexcessive.net/games/gigglebubble/ The images for the bat was taken from LBreakout2 by Michael Speck, which is found at: http://www.lgames.org.
Controls:
space bar - release ball to start playing
a & z - up and down, player 1
up_arrow & down_arrow - up and down, player 2
p - pause
f - toggle fullscreen
Command-line options:
-f - start in fullscreen mode
-d - start in debug mode (good to find bugs/watch how it works)
-s=x - make ball speed equal to x
-ai=x - have computer control second player, with skill equal to x (0-10, where 10 is best)
A screenshot:
Download:
tompong-0.5.1.tar.gz (23.4kb)
tompong-0.5.tar.gz (23.1kb)
tompong-0.4.tar.gz (22.7kb - added GPL LICENSE file)
tompong-0.3.tar.gz (14kb!)
tompong-0.2.tar.gz (10kb!)
Installation:
Dependencies:
- python (version 2.2 or better recommended)
- pygame (version 1.5.3 of better recommended)
- a sense of humour
Changelog:
-
TomPong 0.5.1
- Bugfixes provided by Andy Meier:
- Version number correctly displayed in-game
- Bug whereby score would sometimes go up several times fixed
- AI movement more smooth, and more interesting
-
TomPong 0.5
- Various performance enhancements submitted by John Popplewell
- Completion of accompanying Pygame tutorial
-
TomPong 0.4
- Changed player class structure to allow different classes of player
- Added AI player class with configurable ability (speed of bat)
-
TomPong 0.3
- Added simple spin dynamics
- Made a fancier background with logo
- Made ball start "stuck" to bat, requring user intervention (press space) to start game
-
TomPong 0.2
- Added background image
- Added score counting and scoreboard
- Added algorithms to correct ball angle if too steep
-
TomPong 0.1
- Started project!
- Created ball that bounces round the screen, and runs off sides
- Created bats that are user-controlleable
- Made ball bounce off bats
- Stole ball image from KBounce
- Stole bat image from LBreakout2