Grogue: A Roguelike Tutorial in Go (Part 0)
Tags: roguelike, go, tutorial, gamedev
Published: 2023-10-09 18:46:27

---
title: Grogue: A Roguelike Tutorial in Go (Part 0)
published: true
description: A Roguelike Tutorial Using Go
tags: #roguelike #go #tutorial #gamedev
cover_image: https://dev-to-uploads.s3.amazonaws.com/uploads/articles/icmpoo6orxbiw3oduuqx.png
---

Are you interested in the [Go programming language](https://go.dev/) and creating a [roguelike game](https://en.wikipedia.org/wiki/Roguelike)? This tutorial will help you build the basics of a roguelike game in thirteen parts. Those parts will be:

1. [Drawing on the Screen](https://dev.to/thecal714/grogue-a-roguelike-tutorial-in-go-part-1-3n90)
2. [Entities and the Map](https://dev.to/thecal714/grogue-a-roguelike-tutorial-in-go-part-2-17gd)
3. [Generating a Dungeon](https://dev.to/thecal714/grogue-a-roguelike-tutorial-in-go-part-3-1jf2)
4. [Field of View](https://dev.to/thecal714/grogue-a-roguelike-tutorial-in-go-part-4-4fjk)
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](https://formulae.brew.sh/formula/go) to install this (`brew install go`). Instructions for other operating systems can be found [here](https://go.dev/doc/install).

You'll also need an IDE with support for Go such as [Visual Studio Code](https://code.visualstudio.com/), [GoLand](https://www.jetbrains.com/go/), or [Sublime Text](https://www.sublimetext.com/).

## Hello, World!

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

```sh
mkdir grogue
cd grogue
```

Then, initialize the Go project.

```sh
go mod init grogue
```

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

```go
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](https://ebitengine.org/)) then run the project with `go run .`.

You should see a window that looks something like this:

![Hello, World! screenshot](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/xbuxompf1p2njsvqvera.png)

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

{% details Source Code %} The complete source code for this part is available [here](https://github.com/seancallaway/Grogue/tree/part0). {% enddetails %}