Skip to content

Systems

Code patterns most games need for objects, effects, simulation and collision.

5 cheat sheets · 3 subcategories

Patterns

Reusable runtime patterns for many short-lived objects.

Interactive visual
core

Object Pooling

create everything up front, then recycle instead of allocate

Pre-allocate bullets, effects and enemies once, then hand out and return them. No allocation or GC spikes mid-fight, and a hard cap on live objects.

Interactive visual
core

Particle System

thousands of short-lived points, one draw call

An emitter spawns particles at a rate, each lives for a set time under simple forces, and all of them render in a single instanced draw call.

Simulation

Stepping a world forward deterministically.

Interactive visual
core

Fixed Timestep

physics ticks at a steady rate, rendering just blends between ticks

Run physics in constant dt slices from an accumulator, clamp long frames, and interpolate between the last two states for smooth, repeatable motion.

Collision

Deciding what touched what, and when.

Interactive visual
core

Hitboxes & Hurtboxes

attacks carry hitboxes, bodies carry hurtboxes, and they only meet on active frames

Attacks own hitboxes that exist only during active frames; characters own hurtboxes. An overlap is a hit, registered once per swing per target.

Interactive visual
core

Tunneling & Continuous Collision

fast objects skip over thin walls between two ticks

A fast object can be on one side of a thin wall at one tick and past it at the next. Swept tests (CCD) check the whole path between positions.