Skip to content
Comfy Engine

The Book

The Comfy Engine Book: a handbook for small 2D games

A reading order for building small 2D games close to the code: what an engine should do, how engines compare, the game loop, ECS, wgpu, cameras and shipping.

Maintained by Kasimir Lund

This is the page to start from. The Book is not one long tutorial; it is a reading order through the guides on this site that we keep current, from deciding what you need an engine to do, to putting a finished game in front of players. Read it in order the first time, then come back to the chapter you need.

Everything here assumes you can write some code. Most examples are in Rust, but the ideas carry over to C, C++, C#, Lua or whatever your framework speaks. Where a guide depends on a particular crate or engine version, it says so.

Part one: choosing your ground

  1. What a 2D engine should give you. A checklist of the features that matter for small games (immediate drawing, batching, z-ordering, cameras, audio, debug UI) and the features you can safely ignore. Use it to judge any engine, or to scope your own.
  2. Rust game engines compared. macroquad, Bevy, Fyrox, ggez and others side by side: API style, ECS or not, how they draw, where they run and who each one suits.
  3. macroquad vs Bevy for a first 2D game. The two most common starting points, compared on a real small project.

Part two: how the machine works

  1. How to make a game engine. A tiny 2D engine in Rust, step by step: window, loop, input, quads, textures, then audio.
  2. Game engine architecture. The layers of a small engine and how data moves through one frame.
  3. Fixed timestep game loops. Delta time, the accumulator, the spiral of death and interpolation.
  4. ECS for 2D games. What an entity component system buys you, and when a plain list of structs is the better tool.

Part three: pictures on the screen

  1. Getting started with wgpu. Instance, adapter, device, pipelines and bind groups, explained on the way to a textured quad.
  2. 2D lighting with HDR and bloom. Light maps, HDR render targets, tonemapping and a bloom pass.
  3. A pixel-perfect 2D camera. Integer scaling, low-resolution targets and following the player without shimmer.

Part four: making it look like a game

  1. How to make pixel art for a 2D game. Canvas sizes, palettes and a first sprite.
  2. Pixel art characters. Readable 16 by 16 and 32 by 32 characters with idle and walk cycles.
  3. Backgrounds and parallax. Depth with value and saturation, and the code that scrolls it.
  4. Small examples. Short, engine-agnostic snippets for shapes, sprites, y-sorting, cooldowns, particles and more.

Part five: finishing and shipping

  1. Game jam scoping. Plan a 48 or 72 hour game you will actually finish.
  2. Game audio basics. Sound effects, music loops, mixing and variation.
  3. Shipping a Rust game to the browser. WebAssembly builds, audio on first input and hosting.
  4. How to release an indie game on Steam. The store page, builds, review and launch week.

Case study: one small engine over four releases

Our write-ups of Comfy, an open-source and deliberately opinionated 2D engine in Rust, follow its design over four releases: the first public version, 0.2, 0.3 and 0.4. Read together they are a good lesson in the trade-offs of a small engine: globals or context objects, lifetimes in game state, user shaders and where culling belongs.

New chapters arrive on the blog every week. If a chapter you need is missing, tell us.