Minimal Pong (Unity / C#)
A runnable, three-script Pong built as the step-1 project in overview-arcade-classics-as-learning-projects. It isolates the skills that project teaches first: continuous movement, the game loop, manual collision and reflection, basic input, and a single score-owning controller.
It is deliberately not a clone of Atari’s Pong — it uses plain squares and original naming. Treat the original as a design reference, not something to copy.
Files
| Script | Responsibility | Key wiki concept |
|---|---|---|
Ball2D.cs | Moves the ball, reflects off walls and paddles, raises a Scored event | reflection, unity-collider2d-and-triggers |
Paddle2D.cs | Player input or a beatable “track the ball” AI, clamped to screen | unity-input, unity-transform |
PongMatch.cs | Owns the score, serves and re-serves the ball | unity-gamemanager-pattern, observer-pattern |
No Rigidbody2D is used. Collision and reflection are written out by hand on purpose — making them explicit is the learning goal of a first project.
Scene setup (about 5 minutes)
- New 2D scene. Set the Main Camera to Orthographic (the scripts read
orthographicSizeandaspectto find the play-area edges). - Create three square sprites (
GameObject → 2D Object → Sprites → Square):Ballat the origin.LeftPaddlenear the left edge,RightPaddlenear the right edge. Scale each to a tall thin bar (e.g. scale0.3, 2, 1).
- Add a Box Collider 2D to each paddle (used only for its
bounds— no Rigidbody, no physics material needed). - On
Ball, addBall2Dand drag both paddle colliders into the Paddles array. - On
LeftPaddle, addPaddle2Dwith Control Mode = Player. OnRightPaddle, addPaddle2Dwith Control Mode = Ai and drag theBalltransform into the Ball field. - Create an empty
MatchGameObject, addPongMatch, and dragBallinto its Ball field. - Press Play. Move the left paddle with W/S or the up/down arrows; the right paddle tracks the ball. Scores print to the Console.
For two human players, set the right paddle to Player and give it a custom vertical axis (Edit → Project Settings → Input Manager), then put that axis name in its Vertical Axis field.
Extension ladder
These mirror the Pong extension tasks in the canon reference (see source-classic-games-canon) and lead naturally toward step 2 (Breakout):
- On-screen score — replace the
Debug.Logcalls with a UI Text/TMP readout. (First touch of UI.) - Sound and screen shake on hit — the cheapest possible game-feel win; see unity-audiosource.
- Difficulty scaling — raise
aiResponsivenessorstartSpeedas the rally grows. (Introduces difficulty tuning, the core of Breakout.) - Serve countdown — pause briefly before each serve using a coroutine.
- Swap to Rigidbody2D — re-implement the bounce with physics and a Bouncy 2D material to compare the two approaches; see unity-rigidbody2d and transform-vs-rigidbody2d-movement.