← Dedicated courses

GAME DEVELOPMENT · GO · 16 LESSONS

Game development in Go

The core of a game is a deterministic simulation. These lessons build it as headless Go you can run and test, then show where Ebitengine's Update, Draw and Layout fit when you add a window.

Start with “Fix the timestep: an accumulator turns uneven frames into identical simulation steps” →

Who it is for

Go programmers who want to build their own 2D games, simulations or game servers and care about determinism, performance and clean structure.

Before you start

Basic Go: structs, methods, slices and interfaces; no engine experience needed.

What you will be able to do

  • Run a fixed-timestep loop with interpolation and structure an Ebitengine game around it.
  • Model input, movement, state machines, components and collisions without frame-rate bugs.
  • Generate reproducible worlds, find paths with A* and version your save files.
  • Build an authoritative multiplayer tick loop with client prediction and a measured frame budget.

Unit 1. Game loop, input and physics

Fixed timesteps, Ebitengine structure, vectors, input actions, state machines, components, collisions and spatial hashing.

  1. Fix the timestep: an accumulator turns uneven frames into identical simulation steps

    Advance a simulation in fixed steps from variable frame times, draw it with an interpolation factor and cap catch-up work after a stall.

    6 min · Worked lesson

  2. Ebitengine's Game interface: Update advances ticks, Draw only reads, Layout fixes the screen

    Structure an Ebitengine game so every state change happens in Update, Draw is a read-only view, and the rules run headless in tests.

    6 min · Worked lesson

  3. A 2D vector value type: normalized input, acceleration and drag in per-tick units

    Write a small value-semantics vector type and move a body with normalized input, per-tick acceleration and drag that behave the same on every display.

    5 min · Worked lesson

  4. Input as actions: edge detection, jump buffering and coyote time in a tick-exact simulation

    Map physical keys to actions, detect presses on the action level, and implement jump buffering and coyote time as tick counters that can be tested deterministically.

    6 min · Worked lesson

  5. Scenes and enemy behavior as explicit state machines instead of boolean flags

    Run title, playing, paused and game-over scenes through a scene interface and a transition stack, and drive an enemy with a single-mode behavior machine.

    5 min · Worked lesson

  6. Entities as IDs, components in dense generic stores, systems as plain loops

    Build a minimal entity-component store with generics, run systems over dense slices, remove with swap-delete, and judge when plain structs are the better design.

    5 min · Worked lesson

  7. AABB and circle collisions: detect overlap, push out along the shallow axis, sweep fast movers

    Test boxes and circles for overlap, compute the minimum push that separates them, and stop fast objects from tunneling with sub-steps or a swept test.

    5 min · Worked lesson

  8. A spatial hash for the broad phase: bucket by cell, query neighbors, check each pair once

    Build a uniform-grid spatial hash, insert objects by bounding box, query neighbors with deduplication, and count pair checks against the naive all-pairs loop.

    5 min · Worked lesson

Unit page →

Unit 2. Worlds, AI and multiplayer

Tilemaps and cameras, A* pathfinding, seeded generation, tweens, save files, authoritative servers, prediction and frame budgets.

  1. A camera is a coordinate transform: follow the target, clamp to the map, draw only visible tiles

    Convert between tile, world and screen coordinates, keep a following camera inside the map and compute the exact range of tiles to draw.

    6 min · Worked lesson

  2. A* on a grid: a heap, a heuristic that matches the moves, and tie-breaking you can replay

    Implement grid A* with container/heap, choose a heuristic that matches the movement rules, make equal-cost choices deterministic and decide when a flow field beats per-unit searches.

    7 min · Worked lesson

  3. Reproducible worlds: one seed, one random stream per system, and no global rand

    Generate a seeded cave with a math/rand/v2 PCG source, keep each system on its own derived stream and explain why global or shared randomness breaks replays.

    5 min · Worked lesson

  4. Tweens and sprite frames advance with the simulation tick, not the wall clock

    Drive easing curves, chained and retargeted tweens and sprite animation clips from tick counts so motion is deterministic, pausable and free of jumps.

    5 min · Worked lesson

  5. Save files are untrusted input: version them, migrate forward, validate and write atomically

    Design a versioned JSON save format, migrate v1 saves to v2, reject unknown fields and out-of-range values, and replace a save file without ever leaving it half-written.

    6 min · Worked lesson

  6. An authoritative server owns the world in one goroutine and accepts only validated intent

    Build a server tick loop in which one goroutine owns all game state, clients send inputs over channels, movement is validated against speed and rate limits, and snapshots are copies in a deterministic order.

    6 min · Worked lesson

  7. Client prediction replays unacknowledged inputs; remote players are interpolated from the past

    Hide round-trip latency by predicting local movement, reconcile with acknowledged server snapshots by replaying pending inputs, and draw remote players by interpolating a snapshot buffer.

    5 min · Worked lesson

  8. A 16.6 ms frame budget: measure allocations per update and make the steady state allocate nothing

    Turn refresh rates into frame budgets, count allocations per update with testing.AllocsPerRun, remove per-frame slices, maps, closures and strings, and profile a game loop with pprof and execution traces.

    7 min · Worked lesson

Unit page →

Related: Concurrency · Patterns: behavior