-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathHUD.gd
46 lines (33 loc) · 1017 Bytes
/
HUD.gd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
extends Control
export var Settings: Script
var done := false
var timer := 0.0
var cheese_left: int
var _settings: Settings
onready var time_label := $Time
onready var cheese_left_label := $CheeseLeft
onready var well_done_label := $WellDone
onready var best_time_label := $BestTime
func _ready() -> void:
_settings = Settings.new()
_settings.reload()
cheese_left = _settings.cheeses
cheese_left_label.text = "Cheese Left: %d" % cheese_left
if _settings.best_time > 0:
best_time_label.text = "Best Time: %04d" % _settings.best_time
best_time_label.show()
func _process(delta: float) -> void:
if not done:
timer += delta
time_label.text = "Time: %04d" % timer
func score() -> void:
cheese_left -= 1
cheese_left_label.text = "Cheese Left: %d" % cheese_left
if cheese_left <= 0:
done = true
well_done_label.show()
call_deferred("save_score")
func save_score() -> void:
if _settings.best_time == 0 or timer < _settings.best_time:
_settings.best_time = int(timer)
_settings.save()