Refactored and documented blob_big.gd

This commit is contained in:
RealMelwei 2025-10-11 19:44:05 +02:00
parent b3b6998e14
commit 60e32002c1

View file

@ -5,7 +5,8 @@ var angular_speed = TAU/8
var lifetime = 5
var ready_blobs = 0
var num_blobs = 4
var num_blobs = 0
var particles_ended = false
@ -13,16 +14,20 @@ func _on_target_reached():
ready_blobs += 1
func _ready() -> void:
# Count those children that have a "target reached" signal and connect them.
for child in get_children():
if "target_reached" in child:
num_blobs += 1
child.connect("target_reached", _on_target_reached)
$SplashSound.play()
func _process(delta: float) -> void:
# Once all child blobs have reached their target, start moving as one while slowly rotating.
if ready_blobs == num_blobs:
position += (player.position - position).normalized() * speed * delta
rotate(angular_speed * delta)
lifetime -= delta
# In the end, clear all child blobs, then the rest.
if lifetime < 0 and not particles_ended:
particles_ended = true
for child in get_children():