Introduction

Before you write any code, here is what you’ll find in these pages, and why Go and Ebitengine make a great pair for building games.

What This Book Is About

If you’ve ever wanted to build a 2D game from scratch without the weight of a full engine, this book is for you. It uses Go and Ebitengine (formerly Ebiten), a lightweight 2D game library, and you build everything yourself: the game loop, the scene graph, input handling, collisions, particles. No drag-and-drop editors, no black boxes, just code you can understand and extend.

By the end, you’ll have built Gopher Survivor, a Vampire Survivor-style game. Your character moves around a map, fights waves of enemies, collects experience orbs, levels up, and picks upgrades to get stronger. You’ll see how a game loop works, how to structure a game with nodes and transforms, how to handle collisions and state machines, and how to add polish with particles, audio, and UI. The journey from a blank window to a playable game is the whole point.

Here is the finished game you will build across this book:

Gopher Survivor, the finished game, a hit landing with blood particles, a floating damage number, and enemies closing in
Figure 1. Gopher Survivor, the finished game, a hit landing with blood particles, a floating damage number, and enemies closing in

One thing to be clear about: this book assumes you already know how to program, and how to program in Go. It won’t teach syntax, structs, or goroutines. It focuses on game development, the patterns, the architecture, the tricks that make a game tick. If Go is new to you, spend some time with it first; you’ll get much more out of this book once the language feels familiar.

What Is Go (Golang)?

Go was born at Google in the late 2000s. Ken Thompson and Rob Pike, among others, wanted a language that was simple, fast to compile, and suitable for large systems. Today it powers countless backend services, DevOps tools, and CLI applications. The name “Golang” stuck from the early days when the community site was golang.org; the official home is now go.dev.

What makes Go appealing for our purposes? It compiles to native code in seconds, produces a single executable you can ship anywhere, and its syntax is straightforward, no templates or inheritance maze. You get garbage collection, concurrency built in (goroutines, channels), and cross-compilation out of the box. For 2D games and indie projects, that’s a solid foundation.

What Is Ebitengine?

Ebitengine
Figure 2. Ebitengine

Ebitengine (formerly Ebiten) is an open-source 2D game library for Go. It gives you a window, a game loop, rendering, input, and audio, the essentials, without pretending to be a full engine. There are no editors, no physics engine, no scripting layer. You write your game logic in Go and lean on Ebitengine for the low-level stuff. That simplicity is intentional: you stay in control.

It was created by Hajime Hoshi and has been used in commercial games like Fishing Paradiso, with millions of downloads. It runs on desktop (Windows, macOS, Linux), the web via WebAssembly, and mobile (iOS, Android). We’ll use it as our foundation and build a small framework on top as we go.

Why Go for Games?

Game development is often associated with C++, C#, or JavaScript. Go is less common in this space, but it has a lot going for it. The compile times are short, so you iterate quickly. You ship one binary, no runtime to bundle, no DLL jungle. Cross-compilation is trivial: build for Windows, Linux, and macOS from a single machine. And when you need concurrency (loading assets, network calls, background AI), goroutines keep things manageable without the usual threading headaches.

Is Go the right tool for a 3D AAA blockbuster? Probably not. That world belongs to C++ and specialized engines. For 2D games, indie projects, prototypes, and learning, Go and Ebitengine are a great fit. The ecosystem is growing, the API is clean, and you’re never fighting the framework.

Conventions Used in This Book

To help you navigate the content, we use the following conventions throughout:

Convention Meaning
Code in backticks Code identifiers, filenames, paths, and commands (e.g. game.go, go run ./cmd)
Bold New terms when first introduced, important concepts, and UI elements
Italics Emphasis and technical terms (e.g. game loop)
Code blocks Complete, runnable examples. We use ```go for Go and ```bash for shell commands.
> Note General information worth highlighting
> Tip Practical advice to use the subject matter more effectively
> Warning Potential pitfalls or risks to be aware of
> Important Critical information you need to succeed

We avoid referring to colors in images or diagrams, since many copies are read in grayscale or on e-readers. When we describe UI or visuals, we use position, labels, or shape instead.

The Game We Are Building: Gopher Survivor

We build a clone of Vampire Survivors. It helps to understand the original game and what our clone includes.

Vampire Survivors: The Game We Are Mimicking

Vampire Survivors (2022, poncle) is an independent roguelike that blends bullet-hell with roguelike progression. It pioneered the “bullet heaven” style: instead of dodging bullets, the player becomes a mobile tower of destruction, filling the screen with projectiles.

What You Do in the Game

A typical session works like this:

  1. Start a run: Choose a character (each has a unique starting weapon) and a stage.
  2. Move: Use the analogue stick or keys to move your character on a top-down map. The camera follows you. The map is large; you explore while avoiding danger.
  3. Auto-attack: You never press an attack button. All weapons fire automatically on cooldowns. Whips, garlic auras, holy water, spinning bibles, axes, they all trigger on their own. Your only job is to move and position yourself so enemies die before they reach you.
  4. Collect XP orbs: When enemies die, they drop experience gems (orbs). You walk over them to collect. Each orb fills your XP bar.
  5. Level up: When the XP bar is full, the game pauses and shows 3-4 random options: a new weapon, a passive item (e.g. +damage, +area), or an upgrade to an existing weapon. You pick one. If you already have that weapon, it levels up (stronger, faster, etc.). You can hold up to six weapons plus passives.
  6. Weapon evolution: When a base weapon is max level and you have its matching passive, picking up a Treasure Chest evolves it into a much stronger form. Evolution is a key power spike.
  7. Survive: Enemies spawn in waves, move toward you, and deal damage on contact. Your health bar depletes; if it hits zero, you die and the run ends. The goal is to last 30 minutes (or clear the stage). If you survive, you win.

What the Game Is Based On

  • Bullet heaven: You generate the bullets; enemies walk into them. The screen fills with your projectiles.
  • Synergy: Weapons and passives combo: garlic + area boosts, whip + speed, multiple projectiles stacking.
  • Roguelike loop: Each run is self-contained. Death resets progress for that run.
  • Power curve: You start weak and scale to absurd strength. By minute 25, dozens of enemies die per second around you.
  • Horde management: The number and toughness of enemies escalate. You must keep killing to level and stay ahead of the curve.

What We Implement in This Book vs. the Original

Our clone Gopher Survivor captures the spirit of Vampire Survivors but with a smaller scope, suitable for learning. Here is what we implement compared to the original:

Aspect Vampire Survivors (original) Gopher Survivor (this book)
Movement 8-directional, one character Same: top-down, arrow keys (Ch4)
Weapons 6 weapon slots, dozens of weapons, evolution Four weapons: Knife (Ch7), Sacred Book and Holy Shield (Ch9), Flying Axe (Ch10). No evolution.
Attacking Fully automatic, no input Same: weapons fire on timers
Aiming Most weapons auto-aim (nearest enemy or fixed direction) Knife aims toward the mouse cursor (Ch7); other weapons have fixed behaviour
Enemies Many types, different behaviours, bosses One chasing enemy at first (Ch6); later five kinds with hit points and time-scaled stats, plus a Cyclops mini-boss (Ch11). All move toward the player.
Enemy spawner Complex waves, varied spawn points Spawner at screen edges, waves of 2-3 (Ch7); difficulty tiers escalate over time (Ch11)
XP / Level up Orbs, pause, 3-4 choices, exponential XP curve XP orbs (Ch8); the world freezes with 3 choices at level up (Ch10); exponential XP
Upgrades Weapons, passives, evolution Weapon upgrades (speed, cooldown) (Ch10) plus global passives and unlock gating (HP, move speed, XP, damage, cooldown) (Ch11)
Health Health bar, damage on contact Same: health bar and contact damage (Ch8)
Drops XP orbs, gold, chests, power-ups XP orbs (Ch8), health potion (5% drop) (Ch9)
Win condition Survive 30 minutes (or stage end) No timed win, endless survival; the run ends when your HP reaches zero, and your time survived is the score (Ch10-Ch11)
UI Health, XP, minimap, pickups Health bar, XP bar, level-up popup (Ch8), upgrade panels (Ch10)
State management Menus, pause, run State machine for game flow, main menu, pause, options (Ch12)

We focus on the core loop: move, auto-attack, collect XP, level up, choose upgrades, survive waves. We omit evolution, multiple characters, and most of the content depth, so the code stays readable and each chapter adds one clear mechanic.

Feedback and Errata

No book is perfect, and code keeps evolving. If you hit a bug in the sample projects, spot a mistake in the text, or run into anything that does not behave as described, I want to hear about it. Send your reports, corrections, questions, or general feedback to luigi.vanacore@outlook.com. Error reports are especially welcome: each one helps fix the code and sharpen the explanations for the next reader.

What Comes Next

In Chapter 1, we set up an Ebitengine project, create a window, and draw an image on screen. That’s where the game loop and the core concepts come to life. From there we build the framework and the full Gopher Survivor game, step by step. Let’s go.

All the code for this book lives in the companion GitHub repository at https://github.com/LuigiVanacore/beginning-game-programming-go-ebitengine, organized one directory per chapter (ch01, ch02, and so on). Each chapter ends with a direct link to its folder.