Skip to main content

DPongPy

Didactical implementation of PONG as an online multiplayer game, aimed at exemplifying distributed systems.

Relevant features

  • Supports offline game (1-4 players, no AI)
  • No points, no winner, just 1-4 paddles and a ball
  • Supports online game (1-4 players, no AI) via UDP

How to install

pip install dpongpy

How to play

Run python -m dpongpy --help to see the available options.

Two modes are available:

  • local for playing offline (all players sharing the same keyboard)
  • centralised for online (all players connecting to a central server)

When in centralised mode, the server must be started first, and the clients must connect to it. In this case, the server is called coordinator, and the clients are called terminals. You should start the coordinator first, and then the terminals. The coordinator instance of dpongpy shall keep track of the game state and update it according to the inputs coming from the terminal instances. When a coordinator is started, no window is shown, yet logs may be printed on the console. When a terminal is started, a window is shown, and the game can be played (provided that the coordinator is running). Terminals may observe that the ball is reset to the central position whenever a player joins or leaves the game.

When in local mode, the game will include, by default, 2 paddles and the ball. Users may specify which and how many paddles to include in their game via the --size option (-s). After the --side option, you shall specify the side of the paddle (i.e. left, right, up, or down). You should also specify which key mappings to use for each paddle, via the --keys option (-k). Available key mappings are wasd, ijkl, arrows, and numpad. You should specify the key mapping for each paddle, in the order they were specified via the --side option. Therefore, default options are: -s left -k wasd -s right -k arrows.

When in centralised mode, it is up to terminals to choose their paddle and the corresponding key mapping. This is done, once again, via the --side and --keys options. In this case, however, there is no default choice, and the user must specify the side and key mapping of the paddle they want to control.

Project structure

Overview:

<root directory>
├── CHANGELOG.md            # Changelog for the last stable release
├── dpongpy                 # Main package
│   ├── __init__.py         # Main module: here we implement the game loop business logic for the local game
│   ├── __main__.py         # Main module's entry point: this is where argument parsing occurs
│   ├── log.py              # Logging utilities
│   ├── model.py            # Model module: here we define classes for Pong-related domain entities (paddle, ball, game)
│   ├── controller          # Controller package
│   │   ├── __init__.py     # Controller module: here we define interfaces for input and event handlers
│   │   └── local.py        # Local controller module: here we implement the afore mentioned interfaces in a non-distributed way
│   ├── view.py             # View module: here we define the game rendering logic
│   └── remote              # Remote package
│       ├── __init__.py     # Remote module: here we define interfaces for remote communication (client, server, address) in a protocol-agnostic way
│       ├── udp.py          # UDP module: here we implement the afore mentioned interfaces in a UDP-specific way
│       ├── presentation.py # Presentation module: facilities for (de)serializing Pong-related domain entities
│       └── centralised     # Centralised package
│           └── __init__.py # Centralised module: here we re-define the game loop business logic to work as either centralised server or a terminal client
├── LICENSE                 # License file
├── package.json            # NPM package file (for semantic-release)
├── package-lock.json       # NPM package lock file (for semantic-release)
├── poetry.lock             # Poetry lock file for fixing Python dependencies
├── poetry.toml             # Poetry configuration file
├── pyproject.toml          # Project metadata definition, compliant to the Poetry standard
├── README.md               
├── release.config.js       # semantic-release configuration file (for release on PyPI)
├── renovate.json           # Renovate configuration file (for automatic dependency updates)
├── requirements.txt        # Use this to automatically install Poetry dependencies, then run `poetry install` to actually install the project dependencies
└── tests                   # Unit tests of the project: the file names are self-explanatory
    ├── test_model.py
    ├── test_presentation.py
    └── test_udp.py

Release files for dpongpy 1.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for dpongpy 1.1.0
File Size Uploaded
dpongpy-1.1.0.tar.gz 21.1 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for dpongpy 1.1.0
File Interpreter ABI Platform
dpongpy-1.1.0-py3-none-any.whl Python 3 none any Details

Total release size: 44.3 kB

Release files / dpongpy-1.1.0.tar.gz

Download URL dpongpy-1.1.0.tar.gz
Size 21.1 kB
Tags Source
SHA-256 checksum
How to use checksums
a69a167e146e0c7544f9b64b6ffa6af6349c59af81655707eafdafe84031b878
BLAKE2b-256 checksum
How to use checksums
9fe3d0b90c33c011641a7ba8fffb2ab56a6a0692b628cd2a9060d92fc2c00878
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.8.3 CPython/3.10.12 Linux/6.5.0-1025-azure

Release files / dpongpy-1.1.0-py3-none-any.whl

Download URL dpongpy-1.1.0-py3-none-any.whl
Size 23.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
d5f0374f16c1aeae45f94ee5c4f39278831e5796165c29b9bc838f4ba3501722
BLAKE2b-256 checksum
How to use checksums
d62e1fe8ec76cb87c20dc81bdd23208ec46abd9041f1f046e0ab255e13ad61d6
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.8.3 CPython/3.10.12 Linux/6.5.0-1025-azure

Release history Release notifications | RSS feed

This release

1.1.0 This release

2 release files

1.0.1

2 release files

1.0.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page