DEV Community

Cover image for Godot Games Engine

Posted on

Godot Games Engine

I recently looked back to some of the old projects I worked on using Flash back in 1999 to 2003 or so. Some of those projects involved games development and generative art. I enjoyed programming in ActionScript 2 and 3 - and I enjoyed the creativity and freedom that Flash gave me for creating fun things.

I wanted to find something similar to Flash for creating some games and interactive experiences. Ideally it would be cross platform - and I stumbled across Godot Engine . As it's Open Source (MIT Licence - so actually Free Software) - a huge plus!

The UI for Godot is great, and the scripting language (GDScript) seems neat - it's python like. If you don't like that you can use C# and you can also extend it with other languages such as C++ and Go.

As a programmer, I wanted to first checkout the scripting language - and see what it was like. So, as I often do, I decided to write a simple 2d Cellular automata (See code below). From opening up the Editor for the first time, doing a spot of reading about how to set up a Scene and use it's Node system, it took me about 30 minutes to write a simple 2d Cellular automata. The built in IDE is great, with code highlighting, code suggestions and also a comprehensive debugging tool.

Alt Text

extends TextureRect

# class member variables go here, for example:
# var a = 2
# var b = "textvar"
var imageTexture =
var currentLine = 0;
var width = 1024
var height = 768
var dynImage =
var onColour = '#ffffff';

func _ready():
    dynImage.create(width,height,false, Image.FORMAT_RGB8)
    for i in range(width):
        var rnd  = rand_range(0,10)
        if(rnd < rand_range(0,10)):
            dynImage.set_pixel(i,0, Color(onColour))


    self.texture = imageTexture

    imageTexture.resource_name = "The created texture!"


func _process(delta):
#   # Called every frame. Delta is time since last frame.
#   # Update game logic here.
    currentLine = currentLine + 1

    if(currentLine < height):
        for i in range(width):
            var currentPixel = dynImage.get_pixel(i, currentLine)
            var motherPixel = dynImage.get_pixel(i-1,currentLine-1)
            var fatherPixel = dynImage.get_pixel(i+1,currentLine-1)

            if(fatherPixel.to_html(false) == 'ffffff' && motherPixel.to_html(false) == 'ffffff'):
                dynImage.set_pixel(i, currentLine, Color(onColour))
            if(rand_range(0,10) > 7):
                dynImage.set_pixel(i, currentLine, Color(onColour))


        self.texture = imageTexture

Top comments (2)

moopet profile image
Ben Sinclair

Agreed. Godot is pretty cool.

patsyjmoore1 profile image
Patsy J. Moore

Thank you for such a fantastic programming skills.