Chapter 12 · The Capstone

A tiny RTS.
Every chapter, deployed.

Command a squad. Dodge the watchtower. Nothing here is scripted — every movement, every spotted-alarm, every shell arc is one of the formulas you just learned, running live. Flip on x-ray to see the vectors doing the work.

click the ground to move your squad ↓
The battlefield · left-drag orbit · right-drag pan · click = move order

Hold the field

Click anywhere on the ground to order your six units there — they'll arrive in formation. The enemy watchtower sweeps its vision cone; get caught inside and it opens fire. The crane repairs the wounded, the drone patrols its Bézier loop, the minimap is a matrix, the crystals are a shader. All eleven chapters are on this field — find them in the list.

your squad is cyan · the tower is angry
I drive first — then the field is yours

X-ray the math

unit #1, live:
v = (0.0, 0.0) · steering…
matrix multiplication, live — unit #1's nose vertex:
screen = P · V · M · p
M =

The math on the field

  • 01 · vectors — seek steering (desired − velocity) + the tower's dot-product vision cone
  • 02 · bézier — the recon drone patrols a cubic Bézier loop (watch the violet path)
  • 03 · matrices — the minimap: one world→map matrix, applied to every object, every frame
  • 04 · gpu — the field rubble: 400 rocks, ONE instanced draw call
  • 05 · boids — the squad moves as a flock: separation + alignment + cohesion via formation
  • 06 · ik — the repair crane FABRIK-reaches to the nearest damaged unit and heals it
  • 07 · trig — the radar sweep (cos/sin) + the crystals' sine bob + the tower's sweep
  • 08 · particles — shell arcs (v += g·dt) + impact bursts + repair sparkles
  • 09 · springs — health bars lerp, the flag spring-pops, 📷 follow-cam chases with a spring
  • 10 · shaders — the crystals run a REAL GLSL toon+fresnel fragment shader
  • 11 · 3D world — your orbiting is the View matrix; the minimap is Model→map
The point
this is what "game math" means —

No single formula here is hard. A subtraction, a dot product, a weighted sum, a lerp, one integration step. But composed — seek + separate + arrive + spot + shoot + smooth — they stop looking like math and start looking like behavior. Every RTS, MOBA and tower-defense you've played is this loop with more zeros on the end.