diff --git a/scenes/level_1.tscn b/scenes/level_1.tscn index 5a2390d..15f0ff4 100644 --- a/scenes/level_1.tscn +++ b/scenes/level_1.tscn @@ -544,4 +544,5 @@ volume_db = -20.0 [connection signal="body_entered" from="Door1" to="." method="_on_door_1_body_entered"] [connection signal="body_entered" from="Door2" to="." method="_on_door_2_body_entered"] +[connection signal="body_entered" from="Goal" to="." method="_on_goal_body_entered"] [connection signal="finished" from="MusicPlayer" to="." method="_on_music_finished"] diff --git a/scripts/level_1.gd b/scripts/level_1.gd index b83f51e..23bc4e4 100644 --- a/scripts/level_1.gd +++ b/scripts/level_1.gd @@ -3,6 +3,7 @@ extends Node2D @export var music_tracks: Array[AudioStreamWAV] var stream: AudioStreamWAV var time_elapsed: float = 0.0 +var goal_reached: bool = false # Called when the node enters the scene tree for the first time. func _ready() -> void: @@ -38,6 +39,10 @@ func _on_door_2_body_entered(body: Node2D) -> void: func _on_music_finished() -> void: loop_music() +func _on_goal_body_entered(body: Node2D) -> void: + if body == $Player: + goal_reached = true + func loop_music() -> void: $MusicPlayer.stream = stream $MusicPlayer.stream.loop_mode = AudioStreamWAV.LOOP_FORWARD