34 lines
658 B
GDScript
34 lines
658 B
GDScript
|
extends CanvasLayer
|
||
|
|
||
|
signal start_game
|
||
|
var score: int = 0
|
||
|
|
||
|
|
||
|
func show_timeout_message(text: String) -> void:
|
||
|
$Message.text = text
|
||
|
$Message.show()
|
||
|
$MessageTimer.start()
|
||
|
|
||
|
func show_game_over():
|
||
|
show_timeout_message("Game Over")
|
||
|
await $MessageTimer.timeout
|
||
|
|
||
|
$Message.text = "Dodge the Mobs!"
|
||
|
$Message.show()
|
||
|
# Make a one-shot timer and wait for it to finish.
|
||
|
await get_tree().create_timer(1.0).timeout
|
||
|
$StartButton.show()
|
||
|
|
||
|
|
||
|
func update_score(score):
|
||
|
$ScoreLabel.text = str(score)
|
||
|
|
||
|
|
||
|
func _on_start_button_pressed():
|
||
|
$StartButton.hide()
|
||
|
start_game.emit()
|
||
|
|
||
|
|
||
|
func _on_message_timer_timeout():
|
||
|
$Message.hide()
|