Odin · raylib · a build-along book

Odin't Know That

Building a native cross-platform desktop game from scratch in Odin: one source tree, one binary, using nothing but Odin and its bundled raylib.

Odin't Know That walks you from an empty directory to Sköll, a complete endless runner: a wolf that dashes across an endlessly-scrolling, procedurally-generated Norse landscape, jumping obstacles and gaps and collecting runes, with a rising speed ramp, particles and screen shake, a day→night sky, a HUD and state machine, fully synthesised sound, and a persistent high score. No engine, no image or audio assets, no third-party libraries, no package manager: every visual is a raylib shape primitive and every sound is generated at runtime. It's the same zero-dependency, all-primitives approach behind my Toys experiments, written up as a book.

Contents

  1. -PrefaceWhy this book exists, who it's for, and the ground rules.
  2. 1Setup & first lookInstall Odin, set up your editor, run a first program, and see the road ahead.
  3. 2Enough OdinA fast, code-first tour of exactly the Odin the game uses.
  4. 3Window, loop & raylibA window, the frame loop, and the raylib mental model.
  5. 4The playerA wolf that runs and jumps: movement, gravity and input.
  6. 5A scrolling worldCamera2D and parallax for an endlessly-scrolling landscape.
  7. 6Terrain & obstaclesProcedurally generated terrain, gaps and obstacles.
  8. 7Collisions & scoringCollisions, runes to collect, and a rising speed ramp.
  9. 8JuiceParticles, screen shake, and a living day→night sky.
  10. 9States & HUDThe game's state machine, menus, and the HUD.
  11. 10SoundA voice for the game: procedural audio synthesised with raylib.
  12. 11Saving & determinismA persistent high score and reproducible randomness.
  13. 12ShippingBuilding and shipping one self-contained cross-platform desktop binary.
  14. App AOdin quick referenceA one-page cheat-sheet of the Odin used in this book.
  15. App BFull source listingsThe complete verified source of the finished project.
  16. App CBeyond the bookraylib's real strengths, and where to go next.
  17. App DTroubleshootingThe recurring traps, in one place.
  18. App ELinks & referencesEverything the book cites, grouped.
  19. App FChangelogEdition history and changes to the manuscript and reference code.

The finished project

Every code sample in the book is real and compiled. The complete source is in Appendix B, and requires only the Odin compiler to build; raylib ships inside it. Want more like this? My Toys page collects the rest of my browser experiments, and the Programming section has more write-ups.

The web sibling: Yo Odin

Yo Odin is the sibling volume: the same house style applied to a WebAssembly game built from scratch down to the browser boundary. If you want the web target instead of a native desktop binary, start there.

Going deeper on Odin

This book teaches the slice of Odin the game needs. For the whole language, read Karl Zylinski's Understanding the Odin Programming Language, warmly recommended.