Game Design & Development · Tiny-Loop Tutorial · Archetype #6
Tutorial: Pong / Paddle Game
This is the exact Pong / Paddle Game archetype from What Makes a Game? — already built and running below, you vs. a simple computer opponent. Play it, then swap the pre-built ball, colors, and difficulty using the panel underneath. You can't break the loop itself; that part is locked. Once you've tuned a version you like, you'll build this same architecture two more times: with Scratch's blocks, then from real scratch in JavaScript.
🗺️ The Architecture
Every tiny-loop game starts as a concept, then gets broken into a core loop, a systems list, and a structure — before anyone touches sprites or colors. Here's the Pong / Paddle Game's architecture:
The four systems, in order of execution every frame:
- Input system — reads the arrow keys (or mouse) and moves the player's paddle up/down.
- AI system — moves the CPU's paddle toward the ball's y position, but capped at a limited speed so it's beatable.
- Physics system — the ball moves every frame and reflects its direction off the top/bottom walls and either paddle.
- Scoring system — when the ball passes a side completely, the other player scores and the ball resets to center.
🎮 Play & Customize
You're the left paddle. Move with ↑ / ↓ or W / S, point with the mouse, drag on a touchscreen, or use the touch buttons. Where the ball hits your paddle matters: the edges send it off at a steep angle. First to the score goal wins.
Keys only work while the game has focus. Press P or Esc to pause.
Tune the Game (limited, on purpose)
Content settings change how it looks and apply instantly. Rule settings change how it plays, so the match restarts.
Notice what you can't change here: there's no field for "how bounce reflection works" or "how the CPU tracks the ball." That's the engine, the part every version of this game shares. You're tuning content and a few numbers, not rewriting architecture. That limit is on purpose.
What the sliders actually touch in the engine: Ball Speed sets the serve speed (1.5 + ballSpeed × 0.6); every paddle hit then adds 5%, capped at double. CPU Difficulty caps how many pixels per tick the CPU paddle may move toward the ball (clamp(dy, -aiSpeed, aiSpeed)). The CPU always knows exactly where the ball is. The cap is the only thing that makes it beatable.
🏛️ The Origin: From Oscilloscopes to Discrete Silicon (1958–1972)
Long before microprocessors, personal computers, or modern game engines existed, electrical engineers discovered how to turn electronic test equipment into competitive play. The game we now call Pong wasn't programmed in code—it began with analog vacuum tubes and was later built entirely out of discrete logic chips.
William Higinbotham's Tennis for Two
Higinbotham realized static science exhibits bored visitors. Using operational amplifiers from analog bomb-trajectory computers, he built two aluminum controllers with a rotary knob for trajectory angle and a push-button to hit the ball over a central cathode net.
Ralph Baer's "Brown Box" & Magnavox Odyssey
German-American engineer Ralph Baer envisioned games on standard living-room televisions. Licensed to Magnavox in 1972, the Odyssey had no CPU, RAM, or color output. Players attached translucent plastic color overlays to their TV screen with static electricity to view tennis courts, roulette tables, and haunted houses.
Allan Alcorn's Discrete TTL Pong (Atari)
When Nolan Bushnell and Ted Dabney founded Atari, they hired young engineer Allan Alcorn and assigned him a "warm-up exercise" to create a simple paddle game. Alcorn's ingenious circuit design required no expensive computer chips—revolutionizing coin-operated entertainment and launching the global video game industry.
📐 The Physics of Reflection: Alcorn's 8-Segment Deflection Model
If you build a paddle game using textbook physics ($r = d - 2(d \cdot n)n$), you encounter an immediate design catastrophe: the flat physics deadlock. If an incoming ball travels horizontally ($v_y = 0$) and strikes a vertical flat paddle, the reflection keeps $v_y = 0$. The ball bounces back and forth on the exact same scanline forever!
To turn Pong into a competitive game of skill, Allan Alcorn divided each paddle into 8 discrete vertical segments. Where the ball makes contact dictates both the outgoing bounce angle and the velocity boost.
Interactive Paddle Deflection & Angle Lab
Test how different paddle segments shape outgoing bounce vectors and rally speed
⚡ Under the Hood: Discrete TTL Hardware vs. The Modern Software Loop
Today, we think of game development as writing code that runs on a CPU. But in 1972, microprocessors like the Intel 8008 were too slow and expensive ($300+ each) for arcade games. Allan Alcorn achieved video game animation purely with discrete hardware timing.
🟡 1972: Discrete TTL Hardware State Machine
- Master Clock: A 7.159 MHz quartz crystal oscillator generates clock ticks.
- Raster Counters: Synchronous binary counters generate 15.75 kHz horizontal and 60 Hz vertical sync pulses to sweep the CRT electron gun.
- Player Inputs: Rotary potentiometer dials charge timing capacitors, producing a vertical window pulse whenever the scanline reaches paddle height.
- Ball Tracking: Dedicated flip-flops increment or decrement ball horizontal and vertical position registers every frame.
- Collision Detection: A single Boolean AND gate detects when the paddle pulse and ball pulse are HIGH simultaneously, flipping the ball's horizontal direction latch.
- Video Output: Resistors sum the sync, paddle, ball, and score pulses directly into analog composite video—zero software, zero memory buffers!
🔵 Today: Modern Software Game Loop
- Clock: The browser's
requestAnimationFrame()fires ~60 to 120 times per second synchronized with monitor refresh. - Phase 1 (Input): Event listeners (
keydown,pointermove) update state variables (player.y). - Phase 2 (AI): The computer paddle computes the distance delta (
dy = ball.y - cpu.y) and clamps its chase speed. - Phase 3 (Physics): Ball coordinates increment (
ball.x += ball.vx), wall bounds invert vertical velocity, and paddle bounding boxes calculate deflection. - Phase 4 (Scoring): Out-of-bounds checks increment score tallies and trigger serve delays.
- Phase 5 (Rasterization): Canvas 2D calls (
fillRect()) submit draw batches to the GPU framebuffer.
👀 Peek at the Code
The game running above is this code. Nothing is hidden. It's split into two parts on purpose: a small config object that the panel edits, and a locked engine that reads it.
✏️ Config: this is what the panel above editsconst config = { ball: '🏐', bg: 'space', ballSpeed: 3, aiSpeed: 3, winScore: 5 };
👆 This block updates live. Change anything in the panel and the matching value flashes here.
🔒 Engine: locked, shared by every version of this game// runs exactly 60 times per second, whatever your screen's refresh rate function update() { // 1. INPUT: player paddle follows held keys (or the pointer) if (keys.up) player.y -= 5; if (keys.down) player.y += 5; // 2. AI: CPU paddle chases the ball, capped at aiSpeed const dy = ball.y - cpu.centerY(); cpu.y += clamp(dy, -config.aiSpeed, config.aiSpeed); // 3. PHYSICS: move, bounce off walls, reflect off paddles ball.x += ball.vx; ball.y += ball.vy; if (ball.y < 0 || ball.y > H) ball.vy *= -1; if (collides(ball, player) || collides(ball, cpu)) { ball.vx *= -1.05; // reflect + speed up 5% ball.vy += (ball.y - paddle.centerY()) * 0.05; // edge hits = steeper angle } // 4. SCORING: ball fully passes a side → point, then re-serve if (ball.x < 0) { cpuScore++; serve(); } if (ball.x > W) { playerScore++; serve(); } }
🧪 Remix Challenges
The panel can only turn the knobs the engine exposes. To change the rules, you have to change the engine. Each challenge below edits exactly one system. Try them in your own copy once you've built it in Lesson 2.
TweakShrinking paddlesPhysics system · one line
Make every point you score cost you paddle length, so a lead makes the game harder. What does that do to comebacks?
player.h = Math.max(20, 50 - playerScore * 6);
TwistTwo-player modeSwap the AI system for a second input
Delete system 2 entirely and give the right paddle its own keys. The physics and scoring systems don't change at all. That's the payoff of keeping systems separate.
// replaces the AI system if (keys.p2up) cpu.y -= 5; // ↑ if (keys.p2down) cpu.y += 5; // ↓ (player 1 keeps W / S)
TransformTurn it into BreakoutNew system: bricks
Remove the CPU paddle and fill the right third of the screen with a grid of bricks. When the ball hits a brick, remove the brick, reflect the ball, and add a point. You win when the grid is empty. Which of the four systems survive unchanged? (Hint: more than you'd think.)
🧠 Check Your Understanding
Test your grasp of Pong's history, collision physics, and game architecture:
Question 2: What fatal gameplay flaw occurs if a paddle game uses pure flat-surface physics reflection (angle of incidence = angle of reflection)?
Question 3: In the original 1972 arcade hardware, how was a collision between the ball and paddle detected?
🛠️ Now Build It For Real
You've played a working Pong game and seen exactly how it's built. Next, build this same architecture yourself — twice, in two different tools.
🧩 Step 1 — Build It in Scratch
The "Build the Loop with Blocks" section above already shows the exact scripts — backdrop, sprites, variables, and all four scripts, block by block, in Scratch's own category colors. Open a Scratch tab side-by-side and copy each script exactly; the game should come to life the same way it does here.
Open a blank Scratch project tab →Want more practice first? Scratch's official Pong tutorial builds a similar loop — a ball that bounces off walls and a paddle, with a climbing score.
Open the official Scratch Pong Game tutorial →