Yo Odin
Building a WebAssembly arcade game from scratch in Odin: the renderer, the server, and the game, with nothing but Odin, HTML, JavaScript and CSS.
Yo Odin walks you from an empty directory to Destroids, a complete Asteroids-style arcade game. Along the way you build your own batched-Canvas2D renderer, a small web server in Odin, and the game itself: no engine, no image or audio assets, no third-party libraries, no bundler. It's the same zero-dependency, all-primitives approach behind my Toys experiments, written up as a book.
Contents
- -PrefaceWhy this book exists, who it's for, and the ground rules.
- 1Setup & first lookInstall Odin, set up your editor, run a first program, and see the road ahead.
- 2Enough OdinA fast, code-first tour of exactly the Odin the game uses.
- 3WebAssembly foundationsCompile to WASM and cross the boundary to JavaScript, both ways.
- 4A web server in OdinA static-file HTTP dev server in ~100 lines of Odin, with the right MIME types.
- 5Renderer, part 1A packed command buffer and the bridge that replays a frame in one crossing.
- 6Renderer, part 2Canvas, the animation loop, and keyboard input, plus the scratch-buffer gotcha.
- 7Loop, state & shipThe frame loop, the no-allocation entity pattern, and a flyable vector ship.
- 8Rocks, bullets & collisionsSplitting asteroids, bullets, and the elastic collision system.
- 9JuiceParticles, debris, shockwaves, screen shake, starfield, and hyperspace.
- 10HUD, state & persistenceText without fmt, the game's state machine, and a saved high score.
- 11SoundSynthesised sound with Web Audio: no audio files.
- 12Determinism, build & shipReproducible randomness, the final build, and deploying the game.
- App AOdin quick referenceA one-page cheat-sheet of the Odin used in this book.
- App BFull source listingsThe complete verified source of the finished project.
- App CExtending the rendererHow to add gradients, sprites, filters and more.
- App DTroubleshootingThe recurring traps, in one place.
- App ELinks & referencesEverything the book cites, grouped.
- 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 you can play the exact build the book produces. Want more like this? My Toys page collects the rest of my browser experiments, and the Programming section has more write-ups.
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.