extends Node2D signal game_started signal game_over var score = 0 var music_position = 0.0 func new_game(): score = 0 $Player.spawn($StartPositon.position) $StartTimer.start() $HUD.update_score(score) $HUD.show_message("Get ready") $Music.play(music_position) func game_over(): $ScoreTimer.stop() $HUD.show_game_over() music_position = $Music.get_playback_position() $Music.stop() $DeathSound.play() emit_signal("game_over") func _ready(): randomize() # Plant seed for random number generation func _on_StartTimer_timeout(): $ScoreTimer.start() emit_signal("game_started") func _on_ScoreTimer_timeout(): score += 1 $HUD.update_score(score)