Playing with Godot 4 and re-visiting L-Systems as a familiarisation exercise.
As before, we use a string to track the current state of the iterations and our rules in a dictionary. For each iteration, we loop over the characters in the axiom and, for each character, execute the rule (append the matching value, or the current character, to a new axiom string).
Not shown is the LNode class for holding the angle and the current position. I could track them in the same class Iām using for everything else. However, I know from previous work, I will want to store the state if I continue.
class_name LNode
var angle: float
var position: Vector2
func _init(a: float, p: Vector2):
angle = a
position = p