A gamepad usage example
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
kaqu c058cc74a2 Fixed headless server, view client, local 2 years ago
.vscode Headless server, separate view client 2 years ago
game_objects Fixed headless server, view client, local 2 years ago
pictures Headless server, separate view client 2 years ago
sounds Streamlined, sound files etc. 2 years ago
utilities Local version release 2 years ago
.gitignore Python caches removed 2 years ago
README.md Headless server, separate view client 2 years ago
cl1.sh Headless server, separate view client 2 years ago
cl2.sh Headless server, separate view client 2 years ago
local.sh Publishable client/server variant ready! 2 years ago
pandemic_pong.py Fixed headless server, view client, local 2 years ago
srv.sh Publishable client/server variant ready! 2 years ago
view.sh Headless server, separate view client 2 years ago

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

    ./local.sh

instead.

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

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

    ./cl1.sh

To connect player #2, use

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

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