DreamBall/levels/level.gd
Taevas f7e85724b3 reduce video memory usage by orders of magnitude
big fonts use lots of big lumalpha8, so just scale up small fonts
2025-03-25 23:18:33 +01:00

38 lines
1 KiB
GDScript

class_name Level
extends Node3D
signal ring_collected
signal completed
var seconds_spent: float = 0.00
var music: Music
var velocity: float = 0.0
var rings: Array[Ring] = []
var finished_rings_count: int = 0
func _ready() -> void:
var children = get_children()
for child in children:
if is_instance_of(child, Music):
music = child
assert(is_instance_valid(music), self.name + " has no music!")
var rings_node = get_node("Rings")
assert(is_instance_valid(rings_node), self.name + " has no Rings node!")
var rings_node_children = rings_node.get_children()
for ring in rings_node_children:
if is_instance_of(ring, Ring):
rings.push_back(ring)
ring.connect("collect_signal", collect_ring)
func collect_ring():
finished_rings_count = len(rings.filter(func(ring: Ring): return ring.collected))
ring_collected.emit()
if finished_rings_count >= len(rings):
completed.emit()
func _process(delta: float) -> void:
seconds_spent += delta
velocity = abs($Player.velocity.x) + abs($Player.velocity.y)
music.adaptInstrumentsToVelocity(velocity, delta)