123456789101112131415161718192021222324252627282930313233343536373839 |
- extends Node2D
- # Manage game cycles
- 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 _on_StartTimer_timeout():
- $ScoreTimer.start()
- emit_signal("game_started")
- func _on_ScoreTimer_timeout():
- score += 1
- $HUD.update_score(score)
|