Are you interested in the Go programming language and creating a roguelike game? This tutorial will help you build the basics of a roguelike game in thirteen parts. Those parts will be:

  1. Drawing on the Screen
  2. Entities and the Map
  3. Generating a Dungeon
  4. Field of View
  5. Enemies
  6. Doing Damage (and Taking Some, Too)
  7. Adding an Interface
  8. Items and Inventory
  9. Ranged Attacks
  10. Saving and Loading
  11. Deeper into the Dungeon
  12. Increasing the Difficulty (of the Game)
  13. Gearing Up

In this part 0, we'll get the base of the project set up.

Prior Knowledge

This tutorial assumes you have a basic knowledge of Go and are capable of running commands on your operating system's command-line interface.

Installation

To follow along with this tutorial, you'll need Go version 1.21 or later. On MacOS, you can use Homebrew to install this (brew install go). Instructions for other operating systems can be found here.

You'll also need an IDE with support for Go such as Visual Studio Code, GoLand, or Sublime Text.

Hello, World!

In the folder where you keep your projects (~/Projects, for me), create a new folder called grogue and move into it.

mkdir grogue
cd grogue

Then, initialize the Go project.

go mod init grogue

Now, create a new file main.go and add the following contents:

package main

import (
    "log"

    "github.com/hajimehoshi/ebiten/v2"
    "github.com/hajimehoshi/ebiten/v2/ebitenutil"
)

type Game struct{}

func (g *Game) Update() error {
    return nil
}

func (g *Game) Draw(screen *ebiten.Image) {
    ebitenutil.DebugPrint(screen, "Hello, World!")
}

func (g *Game) Layout(outsideWidth, outsideHeight int) (screenWidth, screenHeight int) {
    return 320, 240
}

func main() {
    ebiten.SetWindowSize(640, 480)
    ebiten.SetWindowTitle("Hello, World!")
    if err := ebiten.RunGame(&Game{}); err != nil {
        log.Fatal(err)
    }
}

Run go mod tidy to pull in the dependencies for our project (the Ebitengine) then run the project with go run ..

You should see a window that looks something like this:

If that works, you're ready for Part 1, which will be out soon!

The complete source code for this part is available here.