Godot: An in-depth test - I

Not waiting (for Godot) anymore

It’s been a long time I wanted to test Godot.

Godot is an opensource game-development engine and editor. I love games. I love opensource. I’ve been thinking for a long time about starting to create small games. So here it is: I’m going to finally test it.

First, a disclaimer: I already touched the software, but only so lightly, and it’s been quite some time now, so you may say that I’m as good as new. Plus I never really used any onther game editor (such as GameMaker, Unity, or even RPGMaker), so the odds are I’m going to make a LOT of mistakes, and that’s exactly the point of documenting my tests. So please:

  • be merciful about it

  • do not hesitate to signal them to me (on twitter)

  • do not follow this blog post as a howto

Good, with that out of the way, I can now start. It’s 23:57 in Paris, I’m alone and there’s some Pink Floyd in the air, let’s do this!

Installation

First thing first, we need to install Godot. I’ll compile from sources, because I always love to have all the brand new shiny not-quite-working-yet features.

The source code of Godot is available on Github at https://github.com/godotengine/godot.

$> git clone https://github.com/godotengine/godot
Clonage dans 'godot'...
remote: Counting objects: 27037, done.
remote: Compressing objects: 100% (506/506), done.
remote: Total 27037 (delta 295), reused 0 (delta 0), pack-reused 26529
Réception d'objets: 100% (27037/27037), 67.50 MiB | 1.28 MiB/s, done.
Résolution des deltas: 100% (17874/17874), done.
Vérification de la connectivité... fait.
$> cd godot
$> ls -l
total 276
drwxrwxr-x  3 lertsenem lertsenem   4096 nov.  28 23:40 bin
drwxrwxr-x  6 lertsenem lertsenem   4096 nov.  28 23:40 core
drwxrwxr-x  7 lertsenem lertsenem   4096 nov.  28 23:40 demos
drwxrwxr-x  6 lertsenem lertsenem   4096 nov.  28 23:40 doc
-rw-rw-r--  1 lertsenem lertsenem 105700 nov.  28 23:40 Doxyfile
drwxrwxr-x 29 lertsenem lertsenem   4096 nov.  28 23:40 drivers
-rw-rw-r--  1 lertsenem lertsenem  12574 nov.  28 23:40 godot_icon.png
-rw-rw-r--  1 lertsenem lertsenem   7272 nov.  28 23:40 godot_icon.svg
-rw-rw-r--  1 lertsenem lertsenem  17898 nov.  28 23:40 godot_logo.svg
-rw-rw-r--  1 lertsenem lertsenem   1725 nov.  28 23:40 LICENSE.md
-rw-rw-r--  1 lertsenem lertsenem    135 nov.  28 23:40 LOGO_LICENSE.md
-rw-rw-r--  1 lertsenem lertsenem   3682 nov.  28 23:40 logo.png
-rw-rw-r--  1 lertsenem lertsenem   2025 nov.  28 23:40 logo_small.png
drwxrwxr-x  2 lertsenem lertsenem   4096 nov.  28 23:40 main
-rw-rw-r--  1 lertsenem lertsenem    132 nov.  28 23:40 makerel.bat
-rwxrwxr-x  1 lertsenem lertsenem  42685 nov.  28 23:40 methods.py
drwxrwxr-x  4 lertsenem lertsenem   4096 nov.  28 23:40 modules
drwxrwxr-x 15 lertsenem lertsenem   4096 nov.  28 23:40 platform
-rw-rw-r--  1 lertsenem lertsenem   1061 nov.  28 23:40 README.md
drwxrwxr-x 10 lertsenem lertsenem   4096 nov.  28 23:40 scene
-rw-rw-r--  1 lertsenem lertsenem  12266 nov.  28 23:40 SConstruct
drwxrwxr-x  8 lertsenem lertsenem   4096 nov.  28 23:40 servers
drwxrwxr-x 20 lertsenem lertsenem   4096 nov.  28 23:40 tools
-rw-rw-r--  1 lertsenem lertsenem     73 nov.  28 23:40 version.py

(Yes I know, my terminal is set in french. Sorry for that.)

Excellent. Let’s see that README to find out how to build.

[...]

### Compiling from Source

Compilation instructions for every platform can be found in the Wiki:
http://godotengine.org/projects/godot-engine/wiki/Advanced_topics

Following the links, I finallyt get to this page, which is what I was looking for. Now I just need to follow the described process blindly.

First we need to install the dependencies.

$> sudo aptitude install scons            \
                         pkg-config       \
                         libx11-dev       \
                         libxcursor-dev   \
                         build-essential  \
                         libasound2-dev   \
                         libfreetype6-dev \
                         libgl1-mesa-dev  \
                         libglu-dev       \
                         libssl-dev       \
                         libxinerama-dev
Note Godot apparently uses SCons for compilation. Unfortunately I’m not familiar with this build system.

And now for the compilation

$> scons platform=x11

At this point in the process, depending on the speed of your CPU, you may want to go grab a coffee. For myself, while I’m waiting for Godot to compile, I will make a quick search about SCons.

What is SCons ?

SCons is a build system for automatic software construction (like make and autoconf) that uses Python scripts for its processes and configuration.

Here is an example of a (minimal) SCons project:

file hello.c
import <stdio.h>
import <stdlib.h>

int main()
{
    printf("Hello, world!\n");
}
file SConstruct
Program('hello.c')

In the file above, Program() is a Python call, taking the name of the file to build as parameter. The name of the built object is automatically deduced. The default compiler is used. How cool is that?

I’ll check the rest of SCons later, because it just warned me:

 scons: done building targets.

And now my bin/ directory looks like this:

$> ls -l bin/
total 110148
-rwxrwxr-x 1 lertsenem lertsenem 112777757 nov.  30 20:49 godot.x11.tools.64
-rw-rw-r-- 1 lertsenem lertsenem        56 nov.  28 23:40 SCsub
drwxrwxr-x 2 lertsenem lertsenem      4096 nov.  30 20:31 tests

The most important file here is fo course the executable godot.x11.tools.64. Normally at this point, according to the documentation I’m reading, I should build the "export templates", which are some the modules needed to export a Godot project for a specific platform (Linux, Windows, Android, …). I won’t build them now because I just want to try out Godot. :]

First launch

I launch the Godot executable in my terminal:

$> ./bin/godot.x11.tools.64

And a window pops up.

/images/godot/20151128_godot-1_snapshots/snapshot.png

This looks like a project creation/selection wizard. I’ll try to create a New Project.

/images/godot/20151128_godot-1_snapshots/snapshot-2.png

I obviously have to provide a path for the root of my project and its name. How about a HelloWorld Project ?

Note The path must exist, Godot won’t create the directory for you. I must say I like that very much.

And here is my new Project, freshly created !

/images/godot/20151128_godot-1_snapshots/snapshot-3.png

I select it and it’s time to see what’s inside Godot.

Main interface

Here’s what the main interface looks like:

/images/godot/20151128_godot-1_snapshots/snapshot-4.png

I think the main area is for the Scene edition. On the top left, the Scene panel allows to add objects (which are also Scenes if I remember correctly what I read about Godot earlier) to the current Scene. On the bottom left the FileSystem panel is self-explanatory. On the right, the Inspector panel should be to edit the properties of objects in the Scene.

Okay, this is a HelloWorld project, so for now I just want to add a text label writing HelloWorld on the screen. I’ll try and add a new Scene with this button:

/images/godot/20151128_godot-1_snapshots/snapshot-5.png

A new window pops up and ask me to Create a new Node (okay, so it seems I was wrong, and I should talk about Nodes rather than Scenes). There’s a lot to chose from, fortunately there’s a search box to filter the results, so I look for "text".

/images/godot/20151128_godot-1_snapshots/snapshot-6.png

And here it is: a RichTextLabel. Probably what I was looking for. When I select it, it seems to be added to the Scene: I can see it in the main window, with a red border (probably means it’s selected right now).

On the right, as expected, the Inspector panel shows the properties of the RichTextLabel Node I just added. Time to change some of those properties, I’m still looking for a way to print "Hello, World!" on my screen after all…

Because I like to make my projects clean, I rename the Node "HelloWorldLabel". You can do that by double-clicking the Node in the Scene Panel.

/images/godot/20151128_godot-1_snapshots/snapshot-9.png

Messing around in the Inspector panel, I set the Bbcode/Enabled property to On and I write "Hello, World!" in the Bbcode/Bbcode property.

/images/godot/20151128_godot-1_snapshots/snapshot-11.png

On the main panel, the Scene now shows my RichTextLabel with the text I just typed in it. Somehow I’m not sure that as the right thing to do, but that still did the trick.

Testing my game

Now I want to test my (highly conceptual) video game. On the top of the editor, there are some symbols that I guess are just made for that purpose.

/images/godot/20151128_godot-1_snapshots/snapshot-13.png

I press the play button 1. An alert box ask me to save my Scene before trying to play it and I oblige.

/images/godot/20151128_godot-1_snapshots/snapshot-15.png

Note Your project only have access to the file inside the directory you specified when creating the project. When I save my Scene here, it’s at the root of my project, in /home/lertsenem/Workspace/godot/HelloWorld.

My Scene is now saved, but when I try to run the project again, another Alert box warns me that "No Main Scene has been defined". I guess I should do that then…

On the upper left corner are some menus I didn’t try yet. I unroll the one labelled Scene and chose Project Settings:

/images/godot/20151128_godot-1_snapshots/snapshot-16.png

Here again, there’s a big list of properties I can set. Fortunately, there’s one reading main scene just under my nose:

Hurrah

I enable it and browse the files to select the Scene I saved earlier. Note that the path reads res://HelloWorldMain.scn: again, the resources are all located relatively to the root of the project.

I click for the third time on the play button, and this time it works! A loading bar is quickly replace with my (spartiate but amazing) application:

There’s nothing stopping me now

Okay, that’s enough for now, I’ll improve on that later.

What’s going on behind the Scenes

Before leaving Godot for now, I still have a question: what are the files I just created with my project, my Scene and the "Hello World" Node? To answer that, I list the root directory of my project.

$> ls -l /home/lertsenem/Workspace/godot/HelloWorld
total 16
-rw-rw-r-- 1 lertsenem lertsenem   93 nov.  30 23:21 engine.cfg
-rw-rw-r-- 1 lertsenem lertsenem 1365 nov.  30 23:23 HelloWorldMain.scn
-rw-rw-r-- 1 lertsenem lertsenem 2736 nov.  30 22:28 icon.png
-rw-rw-r-- 1 lertsenem lertsenem   18 nov.  30 22:28 icon.png.flags

There’s not much, I will review the files one by one.

$> cat engine.cfg
[application]

name="HelloWorld"
main_scene="res://HelloWorldMain.scn"
icon="res://icon.png"

That’s just a config file containing the properties of my project. I can see the main_scene property I defined earlier.

The icon.png file is just that: a default icon for my game. The icon.png.flags is a text file that list flags (well, just the one here actually) that must be referring to how to use the icon.png image.

Now the main file, the one describing my Scene.

$> file HelloWorldMain.scn
HelloWorldMain.scn: data

What a disappointment, my Scene file is saved as binary data… But I think I saw an option to save it as XML in Godot earlier! In the editor I select the Scene menu again and then the Save Scene As… option. I save the file as res://HelloWorldMain.xscn this time (I don’t want to put an xml extension, because I’d like to retain what this XML file encodes), and I get back to my terminal:

$> file HelloWorldMain.xscn
HelloWorldMain.xscn: XML document text
$> head HelloWorldMain.xscn
<?xml version="1.0" encoding="UTF-8" ?>
<resource_file type="PackedScene" subresource_count="1" version="2.0" version_name="Godot Engine v2.0.alpha.custom_build">
        <main_resource>
                <dictionary name="_bundled" shared="false">
                        <string> "conn_count" </string>
                        <int> 0 </int>
                        <string> "conns" </string>
                        <int_array  len="0">                             </int_array>
                        <string> "editable_instances" </string>
                        <array  len="0" shared="false">

Yey, it worked ! My Scene is now a regular XML, text-based file, which is great for version control. Before initiating git inside my project though, I will try to make some changes in the terminal to see if it still works with Godot.

$> sed -i 's/HelloWorldMain.scn/HelloWorldMain.xscn/' engine.cfg
$> cat engine.cfg
[application]

name="HelloWorld"
main_scene="res://HelloWorldMain.xscn"
icon="res://icon.png"
$> rm HelloWorldMain.scn
$> sed -i 's/Hello, World/Hello, Planet/' HelloWorldMain.xscn

I restart Godot, and it works, my modifications are correctly taken into account!

/images/godot/20151128_godot-1_snapshots/snapshot-22.png

I like the fact that I’m not forced to use Godot to edit my files for each small modification a lot! And that will probably come handy when adding scripts to my game: as much as the Godot built-in IDE is good, nothing beats your own IDE2.

The End

That’s the end for the night, and Gorillaz replaced Pink Floyd. I’ll just init a git repo inside my project before leaving.

You can see the git repo here (the TLS alert is normal, I use self-signed certificates and I did not have the time to mail Mozilla, Google and Microsoft my CAs ;)).

While writing this post, I found a tutorial describing almost exactly what I just did, with better screenshots than those I used nonetheless. This howto is part of a larger serie about Godot, which is really worth a read.

And of course, the official website I already mentionned at the beginning of this post is full of informations and documentation.

I’ll leave you there, see you next time.

As always for comments, suggestions or insults, use my twitter account.

  1. pausing to read the hint: "Play the project", all good
  2. And your own IDE does not beat vim, of course.

Written by Lertsenem in godot on Mon 30 November 2015. Tags: godot, gamedev, technical, test,