A gamepad usage example
 
 
Go to file
bruegeln 24b64d5224 ignore pythons venv/ folder 2020-12-06 15:32:54 +01:00
.vscode Headless server, separate view client 2020-12-03 19:10:27 +01:00
game_objects Fixed headless server, view client, local 2020-12-03 19:16:19 +01:00
pictures Headless server, separate view client 2020-12-03 19:10:27 +01:00
sounds Streamlined, sound files etc. 2020-11-25 19:24:10 +01:00
utilities Local version release 2020-11-26 18:19:17 +01:00
.gitignore ignore pythons venv/ folder 2020-12-06 15:32:54 +01:00
README.md README fixed, shell scripts renamed 2020-12-06 12:10:06 +01:00
pandemic_pong.py Fixed headless server, view client, local 2020-12-03 19:16:19 +01:00
pp.sh README fixed, shell scripts renamed 2020-12-06 12:10:06 +01:00
pp_player1.sh README fixed, shell scripts renamed 2020-12-06 12:10:06 +01:00
pp_player2.sh README fixed, shell scripts renamed 2020-12-06 12:10:06 +01:00
pp_server.sh README fixed, shell scripts renamed 2020-12-06 12:10:06 +01:00
pp_viewer.sh README fixed, shell scripts renamed 2020-12-06 12:10:06 +01:00

README.md

Showtime

Pandemic Pong, a gamepad usage example

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.

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 pages are quite convincing ...

Also, we will have to play some game typical sounds. I chose the playsound library as the enabler.

Unfortunately it does not support async operation w/ linux, yet for short samples that does no significant harm!

Almost forgot: You'll have to have pyqt5 installed.

With these installed we're prep'ed & ready!

2. Game usage & capabilities

There are two options to run the game:

Showtime

2.1 Local gameplay

Run the game fullscreen locally like:

    python3 pandemic_pong.py

or have a sizeable window (locally) with:

    python3 pandemic_pong.py --sizeable

or simply use

    ./pp.sh

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!).

2.2 Client/Server gameplay

Have all shell files (*.sh) executable!

Then to run a headless game server instance use

    ./pp_server.sh

On a gameserver: Make sure, inbound TCP & UDP traffic to port 5050 is not blocked by your firewall or router!

  • To connect a player successfully, make sure the server is up & ready (past splash screen ...).
  • Also, don't start players simultaneously (either one may fail to connect - try again ... ;).

To connect player #1, use

    ./pp_player1.sh

To connect player #2, use

    ./pp_player2.sh

If you want to access a remote game server, edit the IP address within the cl1.sh or cl2.sh file respectively.

Also, you may want to play a client in fullscreen. To achieve this, substitute --sizeable by --fullscreen in both files.

Finally, you may also connect one pure view client as

    ./pp_viewer.sh

2.3 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.4 Additional features

The game features two additional capabilites beyond the original pong game (& may lack others ;).

Showtime

  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.

2.5 Exiting

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 ;)

3. Troubleshooting

3.1 Gamepad identification

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.

3.2 Client/Server problems

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 ...

On a gameserver: Make sure, inbound TCP & UDP traffic to port 5050 is not blocked by your firewall or router!

4. Outlook

  • Streaming synchronization needs improvement.

  • Maybe HTTP streaming shall be moved to raw TCP streaming ...

  • Game mechanics: Maybe introduce an incubation time? Or let infection die over time ...