-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathhud.gd
More file actions
115 lines (83 loc) · 3.05 KB
/
Copy pathhud.gd
File metadata and controls
115 lines (83 loc) · 3.05 KB
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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
extends CanvasLayer
signal start_game
func show_message(text):
$Message.text = text
$Message.show()
$MessageTimer.start()
func show_game_over():
show_message("Game Over")
# Wait until the MessageTimer has counted down.
await $MessageTimer.timeout
$Message.text = "Multiplying!"
$Message.show()
# Make a one-shot timer and wait for it to finish.
await get_tree().create_timer(1.0).timeout
$StartButton.show()
$MenuButton.show()
func update_score(score):
$ScoreLabel.text = str(score)
func update_health(health):
$HealthLabel.text = "❤️ " + str(health)
func update_pets(pets: Array[String]):
if pets.size() == 0:
$PetsLabel.text = ""
else:
$PetsLabel.text = "".join(pets)
func flash_health_down() -> void:
var label = $HealthLabel
var original_color = label.modulate
var original_scale = label.scale
var tween = create_tween()
tween.set_loops(3)
tween.tween_property(label, "modulate", Color.BLACK, 0.1)
tween.parallel().tween_property(label, "scale", original_scale * 1.5, 0.1)
# Phase 2: Return to normal (slower - 0.2 seconds)
tween.tween_property(label, "modulate", original_color, 0.2)
tween.parallel().tween_property(label, "scale", original_scale, 0.2)
func flash_health_up() -> Tween:
var label = $HealthLabel
var original_color = label.modulate
var original_scale = label.scale
var tween = create_tween()
tween.set_loops(2)
tween.tween_property(label, "modulate", Color.RED, 0.1)
tween.parallel().tween_property(label, "scale", original_scale * 1.5, 0.1)
# Phase 2: Return to normal (slower - 0.2 seconds)
tween.tween_property(label, "modulate", original_color, 0.2)
tween.parallel().tween_property(label, "scale", original_scale, 0.2)
return tween
func flash_pets_up() -> Tween:
var label = $PetsLabel
var original_color = label.modulate
var original_scale = label.scale
var tween = create_tween()
tween.set_loops(2)
tween.tween_property(label, "modulate", Color.CYAN, 0.1)
tween.parallel().tween_property(label, "scale", original_scale * 1.5, 0.1)
tween.tween_property(label, "modulate", original_color, 0.2)
tween.parallel().tween_property(label, "scale", original_scale, 0.2)
return tween
func flash_pets_down() -> void:
var label = $PetsLabel
var original_color = label.modulate
var original_scale = label.scale
var tween = create_tween()
tween.set_loops(3)
tween.tween_property(label, "modulate", Color.ORANGE, 0.1)
tween.parallel().tween_property(label, "scale", original_scale * 1.5, 0.1)
tween.tween_property(label, "modulate", original_color, 0.2)
tween.parallel().tween_property(label, "scale", original_scale, 0.2)
func _on_start_button_pressed():
$StartButton.hide()
$MenuButton.hide()
start_game.emit()
func _on_menu_button_pressed():
get_tree().change_scene_to_file("res://main_menu/main_menu.tscn")
func _on_message_timer_timeout():
$Message.hide()
# Called when the node enters the scene tree for the first time.
func _ready() -> void:
pass # Replace with function body.
# Called every frame. 'delta' is the elapsed time since the previous frame.
func _process(_delta: float) -> void:
pass