Skip to content
Download
The Grost book

Introduction

Grost is the programming language of Gobu Engine. You use it to write the behaviour of everything that moves in your game: the player, the enemies, the coins, the menus.

This book teaches Grost from scratch. If you have used GDScript, Python or Lua, it will feel familiar. If it’s your first language, read the chapters in order: each one only uses what you have already seen.

A script is a piece of code that gives something in your game its behaviour. This one says hello when it starts, and then counts the seconds that go by:

module Hello
mut seconds : float = 0.0
fn _ready() void {
print("Hello from Grost!")
}
fn _process(delta: float) void {
seconds += delta
}

Line by line:

  • module Hello names the script. That name is also a tag: a label other scripts can use to find the actor. An actor is each thing in a scene: the player, a coin, a camera.
  • mut seconds : float = 0.0 declares a variable: a value with a name. mut means it can change, float is its type (a number with decimals) and 0.0 is the value it starts with.
  • fn _ready() void { ... } is a function: a block of code with a name. The engine calls this one once, when the actor enters the scene. void says it gives nothing back.
  • _process(delta) is called on every frame. A frame is one picture of the game, and there are many per second. delta is the seconds since the previous frame.
  • Blocks go between { }. A ; at the end of a line is optional.

print writes its text in the editor’s Output panel. When you press Play, you see:

Hello from Grost!

In Gobu every document (a file you open and edit in the editor) has its own code:

DocumentWhat for
.sceneA level: what appears in it, the score, the game flow
.prefabSomething with its own behaviour: player, enemy, bullet, coin
.uipA user interface: menu, HUD, pause screen

The code is embedded in the document and runs on its root actor, the one at the top of the document. You can also write standalone .gro files, like the examples in this book.

This script shows several ideas the book explains chapter by chapter. You don’t need to understand all of it now: it’s here so you can see what Grost does for a game.

Data that tells you when it changes (chapter 8). Here, the health of a character, and whether it is still alive:

MAX_HP :: 100
live hp : int = MAX_HP
live alive : bool => hp > 0

Reactions to those changes, without checking every frame. upon runs once, the first time its condition is true; watch runs each time hp changes:

upon not alive {
print("game over")
}
watch hp(value: int) {
print($"hp: {value}/{MAX_HP}")
}

A coroutine (a function that can pause and carry on later) that waits, can be canceled, and always cleans up on the way out (chapter 10). This one is a poison that takes 10 health every second:

async fn poison(ticks: int) void {
defer { print("poison wore off") }
for _i : int in range(ticks) {
await sleep(1.0)
set hp = hp - 10
}
}
fn _ready() void {
spawn poison(3)
}
  • Chapters 1 to 5 cover the core language: values, containers, functions, control flow and structs.
  • 6 to 9, how code connects to the game: use, signals, reactive state and interfaces.
  • 10 to 14, tools for games: concurrency, ECS, saving the game, input and annotations.
  • 15 is for readers coming from GDScript.

Every complete example in this book is compiled by the engine’s tests: when the language changes, the book has to change with it.