Individual academic projectDesktop version

Pong

Motion, contact and reaction.

Solo against AI at three difficulty levels, local duels and four-player survival. A Python desktop game exploring simulation steps, swept collisions and imperfect decisions.

My workI develop the simulation, modes, interfaces and records for this individual academic game.

Solo Pong: two paddles, a ball and scores across the complete arena.

Python / pygame-ce · Desktop

Pygame-rendered captures with scripted input. Desktop games.

Solo Pong at normal difficulty. Actual pygame-rendered capture after a scripted sequence, without a visible SDL window.

Separate the rhythms

Simulation advances in 1/120-second steps. Rendering is separately capped at 60 frames per second.

The match model is independent of the window. The screen turns held keys into directions; an accumulator consumes time in fixed steps, then the renderer draws the state. Time beyond a 0.1-second stall is discarded rather than fully caught up.

Through the contact

The ball is modelled as a square. The code finds the first contact along its movement and uses remaining step time after the bounce. It tests expanded paddle front faces; a ball already behind a paddle cannot be returned. Contact position changes deflection, up to 60° from horizontal.

Examine the contact

Before: consider the travelled segment, not just the final position.

Contact: find the first intersection with the expanded paddle front face.

After: leave according to impact position and consume the remaining step time.

Simplified sweep illustration: the paddle is on the right and squares mark successive positions. This does not execute the Python simulation and is not to scale.

Imperfect AI

Predicting a target does not mean tracking it perfectly.

The AI periodically samples an interception target. It predicts a fraction of travel, folds wall rebounds, adds bounded error and moves at a limited speed. Between reactions its target may be stale. With multiple balls it prioritises the approaching ball with the nearest estimated contact.

Easy

Maximum speed
220 px/s
Reaction interval
0.240 s
Aim error
±36 px
Prediction fraction
0%

Normal

Maximum speed
320 px/s
Reaction interval
0.150 s
Aim error
±22 px
Prediction fraction
45%

Hard

Maximum speed
400 px/s
Reaction interval
0.095 s
Aim error
±14 px
Prediction fraction
80%
AI parameters in logical pixels and seconds.

Change the rules

Four-player Pong: left, right, top and bottom paddles, each with three lives.
Four-player survival: each side has its own lives. Pygame capture with scripted input.

Classic mode plays to seven points, solo or in a local duel. Four-player survival uses four sides and individual lives; eliminated sides change how the arena plays. Simultaneous contacts have explicit ordering: walls and paddles precede goals.

Enlargement, slowdown and multiball change the rally. Durations advance during active simulation, not pause. The first goal ends a classic rally for one point and clears remaining balls. The game attempts to save a record once at the end of a finished match; leaving or restarting is not a result.

Tests and limitations

Isolated tests cover collisions, AI, modes, effects, states, records and resizing among other behaviour. Captures use the pygame renderer and a scripted sequence under SDL without a visible window.

Rally rhythm, difficulty, control comfort and four-player keyboard input still require physical playtesting.