DEV Community

Cover image for Godot Games Engine
gholden
gholden

Posted on

4 2

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 = ImageTexture.new()
var currentLine = 0;
var width = 1024
var height = 768
var dynImage = Image.new()
var onColour = '#ffffff';

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

    dynImage.unlock()

    imageTexture.create_from_image(dynImage)
    self.texture = imageTexture

    imageTexture.resource_name = "The created texture!"
    print(self.texture.resource_name)

    pass

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):
            dynImage.lock()
            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))

            dynImage.unlock()


        imageTexture.create_from_image(dynImage)
        self.texture = imageTexture
    pass

Sentry image

Hands-on debugging session: instrument, monitor, and fix

Join Lazar for a hands-on session where you’ll build it, break it, debug it, and fix it. You’ll set up Sentry, track errors, use Session Replay and Tracing, and leverage some good ol’ AI to find and fix issues fast.

RSVP here →

Top comments (2)

Collapse
 
moopet profile image
Ben Sinclair

Agreed. Godot is pretty cool.

Collapse
 
patsyjmoore1 profile image
Patsy J. Moore

Thank you for such a fantastic programming skills.

Sentry image

See why 4M developers consider Sentry, “not bad.”

Fixing code doesn’t have to be the worst part of your day. Learn how Sentry can help.

Learn more

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay