-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmissile_area.gd
49 lines (37 loc) · 1001 Bytes
/
missile_area.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
extends TextureRect
@export var num_area=0
var word = "."
var pos = 0
var alive = true
signal finished(num)
signal letter_failed
# 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
func set_word(new_word):
word = new_word
pos = 0
$Label.text = "[center]" + word + "[/center]"
func update_label():
$Label.text = "[center]" + "[color=#FF0000]" + word.substr(0, pos) + "[/color]" + word.substr(pos) + "[/center]"
func add_letter(letter):
if letter == word[pos]:
pos += 1
else:
pos = 0
letter_failed.emit()
update_label()
if pos == len(word):
finished.emit(num_area)
func prepare_explossion():
$Label.visible = false
alive = false
func explode():
$Explosion.visible = true
await get_tree().create_timer(1.0).timeout
alive = true
$Explosion.visible = false
$Label.visible = true