Hello

you can make games

I come from a web dev background...

https://courses.heartgamedev.com

https://play.google.com/store/apps/details?id=io.assertchris.snakecatcher

Make a game in 2 weeks,

rest of 2 weeks, repeat

I shipped 12 games in a year

making games can be hard

You need to do all of the art, sound, programming, design, marketing...

Sometimes you

only have 72 hours

(or less, thanks Eskom)

Generating content shouldn't be the bottleneck

PCG leads to emergent gameplay similar to multiplayer

Different levels of PCG:

1. Partially generated with large set-pieces

2. Completely generated

So...what can we build with Godot?

https://godotengine.org

  1. Nodes + scripts (like Flash and Unity)

  2. GDScript or C#

  3. 2D + 3D with a lot of good guard rails

Nodes + scripts + randomising behaviour

(like Flash and Unity)

GDScript or C#

extends GameExperiment

@export var doodad_scene : PackedScene

@onready var _items := $Items

func _ready() -> void:
    for i in range(25):
        var doodad = doodad_scene.instantiate()
        _items.add_child(doodad)
extends ColorRect

func _ready() -> void:
    var number = randf()
    
    if number > 0.9:
        color = Color.DARK_GREEN
    elif number > 0.7:
        color = Color.SADDLE_BROWN
    else:
        color = Color.TRANSPARENT

Tile sets + terrains

https://kenney.nl

Sokoban

Level design with pixel art

func get_layout() -> Array[Array]:
    var layout_image := layout_texture.get_image()
    var rows := []
      
    for y in layout_texture.get_height():
        var row := []
          
        for x in layout_texture.get_width():
            var type := types.none
            var color := layout_image.get_pixel(x, y).to_html(false)
              
            for t in types.values():
                if not type_colors.has(t):
					continue
                if color == type_colors[t]:
                    type = t
      
            row.append(type)
        rows.append(row)
        
return rows
enum flip_axis {
    none, x, y,
}

func flip_layout(layout: Array[Array], flip := flip_axis.none) -> Array[Array]:
    var new_rows := []
      
    for row in layout:
        var new_row := []
          
        for cell in row:
            if flip == flip_axis.x:
                new_row.push_front(cell)
            else:
                new_row.push_back(cell)
                
        if flip == flip_axis.y:
            new_rows.push_front(new_row)
        else:
            new_rows.push_back(new_row)
            
    return new_rows
for row in layout:
    for cell in row:
      
        if tiles.has(cell):
            _tiles.set_cell(
                0, Vector2i(x, y), 0, tiles[cell]
            )
            
        if nodes.has(cell):
            var new_node = nodes[cell].instantiate()
            _nodes.add_child(new_node)
            new_node.position = Vector2(x * 64, y * 64)

Creating a seeding system

Random three words seed

func get_words(generator : RandomNumberGenerator, number : int = 3) -> PackedStringArray:
    var words := get_all_words()
    var size := words.size()
    var chosen := []
      
    for i in range(3):
        chosen.append(words[generator.randi() % size])
        
    return PackedStringArray(chosen)
  
func get_all_words() -> PackedStringArray:
    var file = File.new()
    
    if file.file_exists("res://resources/objects.txt"):
        file.open("res://resources/objects.txt", File.READ)
        var content = file.get_as_text()
        file.close()
        
        return content.split("\n", false)
      
    return PackedStringArray()
func get_hash_from_words(words : PackedStringArray) -> int:
    var complete = ""
    
    for word in words:
        complete += word.trim_prefix(" ").trim_suffix(" ").to_lower()
        
    return complete.hash()

Bouncy cars

questions?

PCG in Godot (April 2023)

By Christopher Pitt

PCG in Godot (April 2023)

  • 401