Day 2 - phentos/rl-tutorial-godot GitHub Wiki

Retrospective

  • Scenes are node trees, root for the tutorial is Game.
  • Need to keep thinking about the command pattern

Progress

  • Start by walking through Part 1 to review and rebuild the scene tree (since I lost it scuffing the project on Day 1). Moved through Part 2 up to creating a tile class. I had missed having dedicated definitions inside assets, so fixed that partway. Bummer that GDScript doesn't have higher order functions like map -- curious about personal library options. Maybe put it in the utils script to abstract away the loop, lol.

Issues

After grappling with understanding command pattern, now I'm not super comfortable with resources. Review that for Day 3.

Thoughts

match

Behaves like Rust, awesome! It even supports pattern matching and wildcards:

match foo:
  "apple":
    print("what")
  ["foo", "bar"]:
    print("foobar")
  [_, "bar"]:
    print("where'd foo go")
  _:
    "foo"

Godot 4's match is very strict, and since I was trying to match inheritance classes for the event handler's actions as they were instantiated in _process they couldn't be matched as I assumed (i.e. match action: MovementAction:). It seems necessary to use if action is MovementAction (like the tutorial does) since is also scans inheritance for equality.

Extends/inherits

While setting up the Entity resource generic, I noticed the _init() was referring to variables not defined. I assumed this was due to the Sprite2D it extended having them, which was partially true -- for example, modulate was actually 2 levels up, inside CanvasItem.