Step 1 of 5 · Reading · ~2 min
Read
Production
Capstone: Mini Pong
You've shipped a game loop, input, ECS queries, collision detection, and a physics integrator. Time to put them together.
Pong is the world's smallest real game:
- Two paddles, one ball, a field, a score.
- Per tick: read input, move paddles, step the ball, handle wall and paddle collisions, score if the ball escapes.
It exercises every engine subsystem in 50 lines of code.
The world
- Field 100 wide x 50 tall. Origin (0,0) top-left.
- Left paddle at x=2, right paddle at x=96. Both height 10. Both initial top y=20.
- Ball at (50, 25) with velocity (+1, +1).
- Score starts (0, 0).
The tick
- Input:
UP_L,DOWN_L,UP_R,DOWN_R— move the addressed paddle by 1 in y, clamped to [0, 40].NONE— no paddle change. - Physics:
ball.x += vx; ball.y += vy. - Wall collision: if
y < 0ory > 49, bounce vy. - Paddle collision: if ball reaches a paddle's x and its y is within the paddle's vertical span, flip vx.
- Score: if the ball escapes left or right, increment the score and reset the ball.
The snapshot
A SNAPSHOT command dumps the world state in a deterministic textual format:
BALL <x> <y> L <l_top> R <r_top> SCORE <sL> <sR>
Note the double spaces before L and before SCORE — that's the format the test runner expects.
Why a textual snapshot?
Real engines render pixels. But for testing and replays, a textual dump of world state is invaluable: it's deterministic, diffable, and machine-checkable. Many AAA engines have an internal "world snapshot" facility for exactly this purpose.
The Practice problem
Implement the rules above. Pass the tests, and you've shipped a working game engine — game loop, input, physics, collision, scoring, and a render snapshot, all in one file.
Discussion
Ask a question, share an insight, or help someone who’s stuck.
Sign in to post a comment or reply.
Loading…