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

Tutorial: Flappy Clone

Gravity Flap Impulse Scrolling Obstacles Collision Pre-built Sprites

This is the exact Flappy Clone archetype from What Makes a Game? — already built and running below. Play it, then swap the pre-built sprite, gap size, and gravity strength 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 Flappy Clone's architecture:

🌱ConceptTap to flap against gravity and slip through as many gaps as possible.
→
🔁Core LoopFall → tap to flap → obstacle scrolls in → pass the gap → repeat.
→
🧩SystemsGravity/flap physics, obstacle spawner, scroll, collision + score.
→
🏁Win/LoseReach the score goal to win, hit an obstacle or the ground to lose.

The four systems, in order of execution every frame:

  1. Physics system — gravity constantly pulls the player down; a key press or click sets a short upward "flap" impulse instead.
  2. Spawner system — every ~1.5 seconds, a new obstacle pair (top + bottom) spawns off-screen to the right with a random gap position.
  3. Scroll system — every obstacle's x position decreases each frame, so obstacles drift toward the player.
  4. Collision & score system — AABB-checks the player against both parts of each obstacle; passing one safely scores a point, touching one or the ground/ceiling ends the game.

🎮 Play & Customize

Flap with Space or ↑, a click or tap on the game, or the touch button. The bird hovers until your first flap. Slip through the gaps, and don't touch the top or bottom edge.

Score: 0

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 round restarts.

Notice what you can't change here: there's no field for "how flap physics work" or "how scrolling is timed." 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: Gravity Strength is multiplied into both the constant downward pull (gravity × 0.15 added to velocity every frame) and the upward flap impulse (-gravity × 1.6) — raise it and both falling and flapping get snappier together, since one variable drives both. Gap Size only changes how tall the opening between the top and bottom obstacle rectangles is when spawnObstacle() builds them; the collision check and scroll speed never change.

👀 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 = {
  player:   '🐦',
  obstacle: 'pipe',
  gravity:  3,
  gapSize:  130,
  winScore: 10
};

👆 This block updates live. Change anything in the panel and the matching value flashes 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. gravity always pulls down; flapping overrides it upward
  player.vy += config.gravity * 0.15;
  if (flapPressed) player.vy = -config.gravity * 1.6;
  player.y += player.vy;

  // 2. spawn a new obstacle pair on a timer
  if (timeSinceSpawn() > spawnRate) spawnObstacle();

  // 3. scroll every obstacle toward the player
  obstacles.forEach(o => o.x -= 3);

  // 4. score on safe pass, end game on collision
  obstacles.forEach(o => {
    if (!o.scored && o.x + o.w < player.x) { score++; o.scored = true; }
    if (collides(player, o.top) || collides(player, o.bottom)) endGame(false);
  });
  if (player.y < 0 || player.y > H) endGame(false);
}
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 gravity, spawn, scroll, and collision systems power every flappy-style game anyone builds, yours included.

🧪 Remix Challenges

The panel can only turn the knobs the engine exposes. To change the rules, you change the engine. Each challenge edits one system. Try them in your own copy once you've built it in Lesson 2.

TweakSpeed up as you scoreScroll system · one line

Every 5 points, scroll the world a little faster. Players feel this as the game "waking up" and never notice the math.

obstacles.forEach(o => o.x -= 3 + Math.floor(score / 5) * 0.5);
TwistMoving gapsSpawn + scroll systems

Give each obstacle a random phase when it spawns, then slide its gap up and down on a sine wave while it scrolls. The collision code already reads gapY fresh every tick, so it keeps working without any changes.

// in spawnObstacle():  phase: Math.random() * 6.28
// in update():
o.gapY += Math.sin(ticks / 30 + o.phase) * 0.8;
TransformGravity flipReplace the flap verb

Instead of an upward kick, each tap flips gravity: the bird falls toward the ceiling until you tap again. The input is still one button, but the verb has changed from "flap" to "flip." Does the gap size need retuning? Why?

if (flapPressed) gravitySign *= -1;
player.vy += gravitySign * config.gravity * 0.15;

🛠️ Now Build It For Real

You've played a working Flappy Clone 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 "Make it Fly" tutorial builds a similar flying sprite controlled with arrow keys against a scrolling backdrop.

Open the official Scratch "Make it Fly" tutorial →
⚡ Step 2 — Code It From Real Scratch (Lesson 2) Write this same gravity system, obstacle spawner, and collision system yourself in plain JavaScript and HTML5 Canvas — no engine, no blocks.