|kaqu d1dad535dd||3 months ago|
|.vscode||4 months ago|
|game_objects||3 months ago|
|pictures||4 months ago|
|sounds||4 months ago|
|utilities||4 months ago|
|.gitignore||4 months ago|
|README.md||4 months ago|
|pandemic_pong.py||4 months ago|
|pp.sh||3 months ago|
|pp_player1.sh||4 months ago|
|pp_player1_bot.sh||4 months ago|
|pp_player2.sh||4 months ago|
|pp_player2_bot.sh||4 months ago|
|pp_server.sh||4 months ago|
|pp_viewer.sh||4 months ago|
|requirements.txt||4 months ago|
I recently obtained Nico's old (chinese) SNES gamepad clones for USB. To bring them to life, I decided to program yet another pong clone.
As warmup, I chose python and scanned a couple of library documents to decide which one might be a suitable choice.
I selected libevdev, the reference pages are quite convincing ...
Also, we will have to play some game typical sounds. I chose the playsound library as the enabler.
Almost forgot: You'll have to have pyqt5 installed
(see also the following passage on virtual environments for 'automatic' installation).
If you want to keep libraries separate from your other python stuff, a 'virtual environment' comes in handy.
First make sure, you have
python3-venv installed! (
sudo apt install python3-venv on debian/ubuntu based systems).
Now let's create a new virtual environment:
python3 -m venv venv
You should now see a new folder called
Activate the virtual environment with:
Your shell prompt should now include a hint: (venv)
To install the dependencies within this virtual environment:
pip install -r requirements.txt
After you're finished and want to exit the virtual environment call:
And to reactive the virtual environment later just calling
Finally, the playsound library requires some other libraries installed. For the virtual environment, the installation is as follows:
pip install vext pip install vext.gi
which will allow the use of the system gi.repository (Gtk3) from a virtualenv.
With these installed we're prep'ed & ready!
There are two options to run the game:
Run the game fullscreen locally like:
or have a sizeable window (locally) with:
python3 pandemic_pong.py --sizeable
or simply use
instead (for convenience, shell scripts have been provided for different parameter sets).
The game tries to identify the event inputs for two gamepads automatically (otherwise see troubleshooting section below!).
Have all shell files (*.sh) executable!
Then to run a headless game server instance use
To connect player #1, use
where <remote_host_ip_or_name> may be "127.0.0.1" or localhost or any other internet host.
To connect player #2, use
If you want to access a remote game server, edit the IP address within the pp_player1.sh and pp_player2.sh file respectively.
Also, you may want to play a client in fullscreen. To achieve this, substitute --sizeable by --fullscreen in both files.
It is possible to have bots as players! Use
for (left) player #1 and/or
for right player #2 respectively.
Finally, you may also connect one pure view client as
A game is won by the player who first reaches 10 points.
A match is won by the player who first wins 3 games.
The game features two additional capabilites beyond the original pong game (& may lack others ;).
The player movement permits advancing towards the 'net', i.e. is not limited to vertical movement.
It is possible to 'infect' the ball (hence the name!) by pressing one of the colour buttons. Infectiousness diminishes over time. Within the infection time, the player itself changes to the 'infection' colour. If the player contacts the ball during 'infection' time, it will contract the 'virus' (lifetime: next point!). To make things a little bit more complicated, the ball does not hint it's 'infection' by colour. If a tainted ball approaches a player, he has to vaccinate himself w/ the same colour (press corresponding button!). Yet, the vaccine diminishes over time as well ... If the player chooses the wrong colour or no vaccine at all, the ball passes right through the player. The point is counted as a miss, the opponent gains a point.
The [Select] button to terminate the program is always available ...
Note, that a single player exiting with the [Select] button terminates ALL game instances (server, clients) ...
For sizeable windows, use the GUI button ;)
In case you have other (differing) USB gamepads, you may need to identify button usage & other gamepad specifics. For convenience, I copied the sample script (folder 'utilities').
Source adjustments will have to take place within 'pong_player.py'. Recommended approach: Map events here to their original correspondents.
You may experience initial delays due to fill up of streamed input queue. After some 2-5s this effect will disappear. Currently, there is no clean initial synchronization ...
Maybe HTTP streaming shall be moved to raw TCP streaming ...
Game mechanics: Maybe introduce an incubation time?
Write a better ('invincible'?) attacking - horizontal movement - bot ...