Game Design & Development · Tiny-Loop Tutorial · Archetype #6

Tutorial: Pong / Paddle Game

Ball Physics Reflection Simple AI Score & Win Pre-built Sprites

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:

🌱ConceptBounce the ball past the CPU's paddle before it gets past yours.
🔁Core LoopBall moves → bounces off a wall or paddle → someone misses → score → repeat.
🧩SystemsPlayer input, CPU tracking, ball physics, scoring & reset.
🏁Win/LoseFirst to the score goal wins the match.

The four systems, in order of execution every frame:

  1. Input system — reads the arrow keys (or mouse) and moves the player's paddle up/down.
  2. AI system — moves the CPU's paddle toward the ball's y position, but capped at a limited speed so it's beatable.
  3. Physics system — the ball moves every frame and reflects its direction off the top/bottom walls and either paddle.
  4. Scoring system — when the ball passes a side completely, the other player scores and the ball resets to center.

🎮 Play & Customize

Move your paddle (left side) with Arrow Up / Arrow Down, W / S, or the touch buttons below the game. First to the score goal wins the match.

You 0 — 0 CPU ↑ / ↓ or W / S

💡 Click inside the game first — that gives it keyboard focus so ↑/↓ move your paddle instead of scrolling the page.

Tune the Game (limited, on purpose)

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 only tuning content, not rewriting architecture. That's the limit, on purpose.

What the sliders actually touch in the engine: Ball Speed only sets the ball's starting velocity magnitude (1.5 + ballSpeed × 0.6) each time it resets — the bounce-reflection math (vx *= -1) runs identically regardless. CPU Difficulty is the cap on how many pixels per frame the CPU paddle is allowed to close in on the ball (clamp(dy, -aiSpeed, aiSpeed)) — the CPU always tracks the ball's exact position, this only limits how fast it's allowed to react.

👀 Peek at the Code

The game running above is this code — nothing hidden. It's split into two parts on purpose: a small config object you just edited with the panel, and a locked engine that reads it.

✏️ Config — this is what the panel above edits
const config = {
  ball:     '🏐',
  bg:       'space',
  ballSpeed: 3,
  aiSpeed:   3,
  winScore:  5
};

👆 This block updates live — hit "Apply & Restart" above and watch the exact values change here. There's no separate "demo" version of the code; this is it.

🔒 Engine — locked, shared by every version of this game
function update() {
  // 1. player paddle follows held keys
  if (keys.up)   playerPaddle.y -= 5;
  if (keys.down) playerPaddle.y += 5;

  // 2. CPU paddle chases the ball, capped at aiSpeed
  const dy = ball.y - cpuPaddle.centerY();
  cpuPaddle.y += clamp(dy, -config.aiSpeed, config.aiSpeed);

  // 3. ball moves, bounces off walls and paddles
  ball.x += ball.vx; ball.y += ball.vy;
  if (ball.y < 0 || ball.y > H) ball.vy *= -1;
  if (collides(ball, playerPaddle) || collides(ball, cpuPaddle)) ball.vx *= -1;

  // 4. score when the ball fully passes a side, then reset
  if (ball.x < 0) { cpuScore++; resetBall(); }
  if (ball.x > W)     { playerScore++; resetBall(); }
}
This is what "architecture" means in practice: the config is the part of the design doc you filled out in Lesson 1 (goal, mechanic, feedback). The engine is the part no one writes twice — the same input, AI, physics, and scoring systems power every paddle game from this one to the original 1972 arcade cabinet.

🛠️ 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 →
Step 2 — Code It From Real Scratch (Lesson 2) Write this same ball physics, paddle AI, and scoring system yourself in plain JavaScript and HTML5 Canvas — no engine, no blocks. ↩️ Back to the Archetype Grid Return to What Makes a Game? to try another tiny-loop archetype or the design workshop.