Skip to content

Commit

Permalink
Track whether goal has been reached
Browse files Browse the repository at this point in the history
  • Loading branch information
yndajas committed Oct 2, 2023
1 parent f71f476 commit 4014a1c
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
1 change: 1 addition & 0 deletions scenes/level_1.tscn
Original file line number Diff line number Diff line change
Expand Up @@ -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"]
5 changes: 5 additions & 0 deletions scripts/level_1.gd
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 4014a1c

Please sign in to comment.