Tutorial 0
Foreword
TL;DR
This foreword contains these elements:
- An overview of what the tutorial series will be all about;
- A description of the game we’re building during this tutorial series;
- Information about how to set up your development environment.
Tutorial Series
In this series, we will be helping you build your first game with engo
. We will start from scratch, and work
our way up to a fully-playable game. We will cover topics as:
- The Entity-Component-System paradigm
- Changing scenes within engo
- Writing and using your first custom Shader
- Adding sounds effects and ambiance music to the game
- And probably much more!
In case something wasn’t covered that you would very much like explained, drop us a comment at Gitter, or create an issue at GitHub to request improvements of this tutorial series.
The Game
The game we will be building, looks a lot like Mini Metro. In that game, cities are popping up which you will have to connect with metro lines. More and more people will want to travel from various cities, making the game harder and harder, until the travelers have to wait too long and it’s game over.
In our game, we won’t be connecting travelers and cities with metro lines. Instead, we’re building highways. This has quite some interesting features:
- As two cities become more and more connected, the welfare (and thus the amount of travelers) increases;
- You may want to add public transportation, i.e. buses, for them to use instead of the car;
- Trucks and vans might slow down the transportation network, as they usually tend to drive at a slower pace;
- Make up your own laws when it comes to taxes (gas, mileage, etc.), but also when it comes to how fast different types of vehicles can drive on various lanes.
- You can connect two highways and get an intersection; there’s no need for this to happen in cities.
One can think of much more interesting features, and we could fill a whole page just listing ideas, but for now, let’s teach you how to set up your own development environment.
Development Environment
For the moment, you can use Windows, Linux and OSX.
Build-Time Dependencies
- Linux:
sudo apt-get install libasound2-dev libglu1-mesa-dev freeglut3-dev mesa-common-dev xorg-dev libgl1-mesa-dev git-all
- Windows: If you’re running on Windows you’ll need a gcc compiler that the go tool can use and have
gcc.exe
in your PATH environmental variable. We recommend Mingw since it has been tested.- OSX: No additional dependencies.
Note that you will only need these installed when you build the game; you will not need these when you want to run the game. You will probably need the ‘runtime’ version of those libraries though (instead of the
-dev
ones), if you want to run the game.
In any case, you will need to install the latest version of Go. Make sure you
correctly set your $GOROOT
(which should point to the installation directory of Go, and your $GOPATH
, which is
basically the root of all your Go projects. Both of these are
environment variables.
Within this $GOPATH
directory, you will want to create a directory called src
. What you want to do now, is open
up a terminal / command prompt, go to this location (using the cd
command), and then type in the following Go command:
go get -u github.com/EngoEngine/engo
This tutorial series is built based on engo v1.0.4, and the master branch possibly contains API changes or other
development changes that may not work exactly as stated in the tutorial. To ensure you’re using v1.0.4, do
cd $GOPATH/src/github.com/EngoEngine/engo
and then checkout the right version with git checkout v1.0.4
. This also depends
on using v1.0.3 of ecs, so also do cd $GOPATH/src/github.com/EngoEngine/ecs
and then checkout the right version with git checkout v1.0.3
.
This command will fetch engo
from the repository, including all its dependencies.
Now, you will want to create your own project directory for your own game. In Go, it is customary to place the source code
of these projects within code repositories, such as GitHub and Bitbucket. The location of these
repositories is the “import path” of such a Go project. We should create this directory structure within the src
folder of the $GOPATH
.
Example
Our GitHub username is
EngoEngine
, and our project is going to be calledTrafficManager
. We are hosting the repository on GitHub. This means we want to ensure that this path exists:$GOPATH/src/github.com/EngoEngine/TrafficManager
.
Within this directory, we will be creating our game. All our files will be within this directory, and we will be
executing all go
-commands (such as go build
and go run
) from this directory (in other words: this directory
is our working directory).