-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathHUD.gd
221 lines (181 loc) · 3.63 KB
/
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
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
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
extends CanvasLayer
signal start_game
signal home_pressed
signal play_again
signal toggle_volume
signal toggle_menu
signal close_menu
signal quit_game
signal time_trial
signal close_welcome(new_name)
signal show_stats
signal close_stats
# Called when the node enters the scene tree for the first time.
func _ready():
$ScoreLabel.hide()
$PreviewBlock.hide()
$GameOver.hide()
$Blocks.show()
var generatedName = generateName()
$WelcomePopup/FirstPage/NameLabel.text = generatedName
for block in $Blocks.get_children():
await get_tree().create_timer(0.2).timeout
block.show()
block.play_fall_in()
# Called every frame. 'delta' is the elapsed time since the previous frame.
func _process(_delta):
pass
func set_preview_block(number):
$PreviewBlock.set_number(number);
func update_score(score):
$ScoreLabel.text = str(score)
$GameOver/ScoreLabel.text = str(score)
func _on_start_button_pressed():
$StartButton.hide()
$StartTimeButton.hide()
$MainTitle.hide()
$ScoreLabel.show()
$MusicToggle.hide()
$PreviewBlock.show()
start_game.emit()
func _on_volume_button_pressed():
var current_img = $Menu/Volume.icon.get_path()
if current_img == "res://mute.png":
var image = preload("res://volume.png")
$Menu/Volume.icon = image
$MusicToggle.text = "Music: On"
else:
var image = preload("res://mute.png")
$Menu/Volume.icon = image
$MusicToggle.text = "Music: Off"
toggle_volume.emit()
func _on_go_home_button_pressed():
home_pressed.emit()
func _on_play_again_button_pressed():
play_again.emit()
func _on_menu_pressed():
toggle_menu.emit()
func _on_close_button_pressed():
close_menu.emit()
func _on_quit_game_button_pressed():
quit_game.emit()
func _on_start_time_button_pressed():
time_trial.emit()
func _on_show_stats_pressed():
show_stats.emit()
func _on_close_stats_pressed():
close_stats.emit()
func _on_music_toggle_pressed():
_on_volume_button_pressed()
func _on_close_welcome_pressed():
print($WelcomePopup/FirstPage/NameLabel.get_text())
close_welcome.emit($WelcomePopup/FirstPage/NameLabel.get_text())
var prefixes := [
"Mystic",
"Cryptic",
"Ethereal",
"Enigmatic",
"Puzzling",
"Intricate",
"Curious",
"Arcane",
"Clever",
"Surreal",
"Quizzical",
"Perplexing",
"Complex",
"Mindful",
"Unusual",
"Challenging",
"Baffling",
"Amusing",
"Astute",
"Tricky",
"Abstract",
"Cognitive",
"Confounding",
"Cunning",
"Cerebral",
"Crafty",
"Delicate",
"Devious",
"Elusive",
"Eccentric",
"Esoteric",
"Fascinating",
"Ingenious",
"Insightful",
"Intellectual",
"Mysterious",
"Paradoxical",
"Pensive",
"Peculiar",
"Pensive",
"Thoughtful",
"Unconventional",
"Unfathomable",
"Unpredictable",
"Whimsical",
"Witty",
"Cryptical",
"Riddling",
]
var suffixes := [
"Kangaroo",
"Sloth",
"Penguin",
"Giraffe",
"Cheetah",
"Llama",
"Panda",
"Hedgehog",
"Ostrich",
"Octopus",
"Squirrel",
"Raccoon",
"Koala",
"Flamingo",
"Platypus",
"Narwhal",
"Walrus",
"Seagull",
"Parrot",
"Hippo",
"Gorilla",
"Hamster",
"Chameleon",
"Kitten",
"Puppy",
"Robot",
"Spaceship",
"Banana",
"Taco",
"Pineapple",
"Gummybear",
"Bubble",
"Unicorn",
"Dragon",
"Wizard",
"Ninja",
"Superhero",
"Rainbow",
"Marshmallow",
"Sneaker",
"Slinky",
"SillyPutty",
"Noodle",
"Slinky",
"Kazoo",
"Pajamas",
"Banjo",
"Pirate"
]
# Function to generate a name
func generateName():
var randomPrefix = prefixes[randi() % prefixes.size()]
var randomSuffix = suffixes[randi() % suffixes.size()]
var generatedName = randomPrefix + " " + randomSuffix
return generatedName
func _on_generate_name_pressed():
var generatedName = generateName()
$WelcomePopup/FirstPage/NameLabel.text = generatedName