I recently obtained Nico's old (chinese) SNES gamepad clones
for USB. To bring them to life, I decided to program yet another pong
## 1. Python libs ##
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](https://python-libevdev.readthedocs.io/en/latest/) pages are quite convincing ...
Also, we will have to play some game typical sounds. I chose the **playsound** [library](https://pypi.org/project/playsound/) as the enabler.
Unfortunately it does not support async operation w/ linux, yet for short samples that does no significant harm!
With these installed we're prep'ed & ready!
## 2. Game usage & capabilities ##
Run the game fullscreen like:
or have a sizeable window with:
python3 pandemic_pong.py --sizeable
The game tries to identify the event inputs for two gamepads automatically (otherwise see troubleshooting section below!).
### 2.1 Scoring ###
A game is won by the player who first reaches 10 points.
A match is won by the player who first wins 3 games.
### 2.2 Additional features ###
The game features two additional capabilites beyond the original pong game (& may lack others ;).
1. The player movement permits advancing towards the 'net', i.e. is not limited to vertical movement.
2. 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.
## 3. Troubleshooting ##
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.