-
Notifications
You must be signed in to change notification settings - Fork 0
/
CHE-Color.gd
67 lines (61 loc) · 1.58 KB
/
CHE-Color.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
extends Control
var colors = [Color(0, 0, 0), Color(0, 1, 0), Color(0.5, 0, 1), Color(1, 0.5, 0)]
var cel
func _ready():
colors.shuffle()
cel = colors.front()
$cel/shape.color = cel
# warning-ignore:return_value_discarded
$r.connect("pressed", self, "changeColor")
# warning-ignore:return_value_discarded
$y.connect("pressed", self, "changeColor")
# warning-ignore:return_value_discarded
$b.connect("pressed", self, "changeColor")
func colorMafs(x):
match x:
[0, 0, 0]:
#biały
return Color(1, 1, 1)
[0, 0, 1]:
#niebieski
return Color(0, 0, 1)
[0, 1, 0]:
#zolty
return Color(1, 1, 0)
[0, 1, 1]:
#zielony
return Color(0, 1, 0)
[1, 0, 0]:
#czerwony
return Color(1, 0, 0)
[1, 0, 1]:
#fioletowy
return Color(0.5, 0, 1)
[1, 1, 0]:
#pomaranczowy
return Color(1, 0.5, 0)
[1, 1, 1]:
#czarny
return Color(0, 0, 0)
func changeColor():
if $r.pressed:
$r.modulate = Color(0.1, 0.1, 0.1, 1)
else:
$r.modulate = Color(1, 1, 1, 1)
if $y.pressed:
$y.modulate = Color(0.1, 0.1, 0.1, 1)
else:
$y.modulate = Color(1, 1, 1, 1)
if $b.pressed:
$b.modulate = Color(0.1, 0.1, 0.1, 1)
else:
$b.modulate = Color(1, 1, 1, 1)
$wynik.stop()
$wynik.get_animation("change color").track_set_key_value(0, 0, $wynik/wynik.color)
$wynik.get_animation("change color").track_set_key_value(0, 1, colorMafs([int($r.pressed), int($y.pressed), int($b.pressed)]))
$wynik.play("change color")
func _on_wynik_animation_finished(_anim_name):
if cel == $wynik/wynik.color:
$Timer.start()
yield($Timer, "timeout")
TaskWithGUI.TaskWithGUICompleteTask(self)