On this page
  1. The spawn loop
  2. Gap sizing
  3. Constrained placement is where fairness lives
  4. Object pooling and why it matters in a browser
  5. Generated versus authored
  6. Continuous fields

The spawn loop

An endless field is produced by a loop that is much simpler than most players imagine. There is no world, no level and no map — there is a short list of obstacles currently on or near the screen, and two rules for maintaining it.

  1. Move everything left by the current scroll speed times the frame time.
  2. Retire anything whose right edge has passed well off the left of the screen.
  3. Spawn a new obstacle whenever the distance since the last spawn exceeds the current spacing.

That is the entire structure. At any moment there are typically four or five obstacles in the list, which is why an endless game can run for an hour in a browser without the memory footprint growing at all.

The spawn position is just off the right edge — 40 units beyond it in our case. That margin exists so that an obstacle never visibly pops into existence; it has already fully entered the world before any part of it becomes visible.

Gap sizing

Each new gate needs a gap height, and it comes from the difficulty ramp rather than from a random number.

We interpolate between a starting height and a floor, using a progression value that approaches one exponentially over the run. In our standard game that is 205 units down to 150, reaching about halfway within twenty seconds.

The floor is the important value and it is derived rather than chosen. It must be at least the flyer's diameter plus the distance the flyer travels during one correction at terminal fall speed. Below that, a gap stops testing accuracy and starts testing whether your flap landed on the right frame — which players correctly perceive as arbitrary even when it is technically possible.

Gap Hunter is the site's stress test for this rule. It shrinks gaps by 2.4 units per gate down to a floor of 92, which is roughly three flyer diameters, and then stops. The floor is where it is because that is where control stops being sufficient.

Constrained placement is where fairness lives

Gap height is the easy part. The gap's vertical centre is where a generator is made fair or unfair, and the naive implementation is always unfair.

Choosing a centre uniformly at random within the safe band produces, sooner or later, a gap near the ceiling immediately after a gap near the floor. Whether that is survivable depends on the scroll speed and the flight model's climb rate — and at any reasonable difficulty, it is not. The player then experiences an unwinnable pattern, which is much worse than a hard one.

The fix is to make each placement relative:

  1. Compute the safe band: half a gap plus a margin from each edge.
  2. Compute the reachable band: the previous centre plus or minus the maximum vertical distance the flyer can cover in the time before it arrives.
  3. Choose uniformly within the intersection of those two bands.
  4. If the result is within about 26 units of the previous centre, nudge it — otherwise the field settles into a flat corridor that reads as boring rather than as easy.

That maximum distance is not a constant. It is derived from the current scroll speed and the spacing, so it automatically tightens as the game gets faster. The generator therefore becomes more conservative in placement exactly when it becomes more aggressive in speed, which is the opposite of what a naive implementation does.

Object pooling and why it matters in a browser

Creating and discarding objects every frame is the main cause of stutter in browser games, because it gives the garbage collector work to do at unpredictable moments. A collection pause of even 30 milliseconds during a tight gate sequence feels like the game hitched, and players reasonably blame the game rather than the runtime.

Obstacles themselves are cheap — there are only ever a handful — so we create them normally. Particles are not: a burst can be dozens of objects several times a second. Those come from a fixed pool allocated once at startup, where spawning means finding an inactive slot and resetting its fields rather than allocating anything.

The other half of the problem is the frame-time clamp. Whatever we do, a browser will occasionally hand us a 300-millisecond frame — a tab regaining focus, a thermal throttle, another tab doing something expensive. Clamping the step to 50 milliseconds means that turns into a small visual stutter rather than the flyer teleporting through a pillar.

Generated versus authored

Not everything on this site is generated. Neon Flight draws from five hand-built sequences — a zig-zag, two staircases, a mirrored pair and a run of alternating extremes — and that choice is what makes an expert-difficulty game fair.

ApproachStrengthWeakness
Fully generatedEndless variety; no memorisationHard to guarantee interesting shapes
Fully authoredLearnable; deliberate difficulty curveFinite; memorisation replaces skill
Generated from authored piecesVariety plus learnable shapesMore design work per game

The third approach is what most good endless games actually do, including several here. The generator chooses which authored piece comes next and where to place it, so the player learns a vocabulary of shapes rather than a sequence of events.

The deeper version of this argument is in random versus pattern-based obstacles.

Continuous fields

Corridor games generate differently again. There are no discrete obstacles at all — there is a rolling list of vertical slices, each with a top and a bottom edge, and the whole corridor shifts left together.

The centre line comes from two sine terms of different periods summed together. That is a cheap way to get a path that never repeats obviously and — crucially — never jumps, because any discontinuity in a continuous wall is simply a wall.

Width narrows with difficulty exactly like a gap height does, with the same kind of floor. Cloud Runner stops at a comfortable width; Sky Tunnel stops at 132 units, which is about five flyer diameters and is the tightest we were willing to ship.

A corridor also needs a second constraint that a gate field does not: a cap on how steeply the walls may climb or fall. Without one, two sine terms can combine into a slope that demands a sustained climb at the flyer's maximum rate, which is unfair in exactly the way an unreachable gap is. Ours limits the centre line to half a unit of height per unit of distance, which is comfortably inside what a steady flap rhythm produces.

Key takeaways

  • An endless field is a short list of obstacles plus two rules: retire what has left, spawn what is due.
  • Gap floors are derived from the flight model, not chosen — the flyer's diameter plus one correction at terminal speed.
  • Fairness comes from placing each gap relative to the previous one within a reachable band.
  • The reachable band tightens automatically as speed rises, so the generator gets more conservative exactly when the game gets faster.
  • Most good endless games generate from authored pieces, so players learn a vocabulary of shapes rather than a sequence.

Frequently asked questions

Is an endless game's obstacle field really infinite?
Functionally yes, structurally no. At any moment only four or five obstacles exist; the rest are retired as they leave the screen and created as they enter. Nothing is stored and memory use stays flat however long you play.
Can a random generator produce an impossible pattern?
An unconstrained one will, eventually and inevitably. That is why good generators place each gap relative to the previous one within a band derived from the flyer's climb rate and the current scroll speed.
Why do obstacles spawn off-screen?
So nothing visibly pops into existence. Ours appear 40 units beyond the right edge, fully formed before any part of them becomes visible.
Do you use fixed patterns anywhere?
Yes — Neon Flight uses five hand-built sequences, and Boss Gate uses an authored boss shutter. At expert difficulty, learnable shapes are what make the game fair.
Illustrated portrait used for the Flappy Arcade editorial byline

Alex Morgan

Browser Games Editor & Interactive Gaming Content Specialist

Alex Morgan is the editorial byline for everything published on Flappy Arcade — the design notes, the flight-model tuning and the strategy guides for all 30 games. More about our editorial byline.

Published · Last updated