37 lines
789 B
GDScript
37 lines
789 B
GDScript
extends CanvasLayer
|
|
|
|
signal start_game
|
|
# Called when the node enters the scene tree for the first time.
|
|
func _ready():
|
|
$Score.hide()
|
|
|
|
# Called every frame. 'delta' is the elapsed time since the previous frame.
|
|
func _process(delta):
|
|
pass
|
|
|
|
func _on_start_pressed():
|
|
$Score.show()
|
|
$Start.hide()
|
|
$Message.hide()
|
|
start_game.emit()
|
|
|
|
func show_game_over(score):
|
|
$Message.text = "Game Over"
|
|
$ScoreEnd.text = str(score)
|
|
$Message.show()
|
|
$MessageTimer.start()
|
|
$Score.hide()
|
|
# Wait until the MessageTimer has counted down.
|
|
await $MessageTimer.timeout
|
|
|
|
$ScoreEnd.hide()
|
|
$Message.text = "Press start"
|
|
$Message.show()
|
|
# Make a one-shot timer and wait for it to finish.
|
|
await get_tree().create_timer(1.0).timeout
|
|
$Start.show()
|
|
|
|
func update_score(score):
|
|
$Score.text = str(score)
|
|
pass
|