-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathWordList.gd
70 lines (56 loc) · 1.78 KB
/
WordList.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
extends Control
var shinyCount = 0
var pictureCount = 0
const pixelfont = preload("res://fonts/GnuUnifontFull-Pm9P.ttf")
# Called when the node enters the scene tree for the first time.
func _ready() -> void:
words_builder()
%ImageCounter.text = "Imagens encontradas: {a}/{b}".format(
{"a": pictureCount, "b": len(Consts.has_picture)}
)
%ShinyCounter.text = "Shiny encontrados: {a}/{b}".format(
{"a": shinyCount, "b": len(Consts.shines)}
)
func word_node(text: String, color: Color = Color.WHITE) -> Label:
var w = Label.new()
w.text = text
w.add_theme_font_size_override("font_size", 67)
w.add_theme_font_override("font", pixelfont)
w.add_theme_color_override("font_color", color)
return w
func words_builder() -> void:
var sorted = Consts.has_picture.duplicate()
sorted.sort()
var nodes: Array[Node] = []
for w in sorted:
if w.to_lower() in Consts.matched_words:
if w.to_lower() in Consts.shines:
shinyCount += 1
pictureCount += 1
nodes.append(word_node(w.to_upper()))
else:
if w.to_lower() in Consts.revealed_words:
nodes.append(word_node(w.to_upper(), Color.DIM_GRAY))
else:
nodes.append(word_node("????"))
var hbox: HBoxContainer = null
for n in nodes:
if hbox == null:
hbox = HBoxContainer.new()
hbox.add_theme_constant_override("separation", 50)
if len(hbox.get_children()) >= 7:
%VBox.add_child(hbox)
hbox = HBoxContainer.new()
hbox.add_theme_constant_override("separation", 50)
hbox.add_child(n)
%VBox.add_child(hbox)
func _input(event):
if not event is InputEventKey:
return
if not event.is_pressed():
return
elif event.keycode == KEY_TAB:
get_tree().change_scene_to_file("res://scenes/main.tscn")
# Called every frame. 'delta' is the elapsed time since the previous frame.
func _process(delta: float) -> void:
pass