-
Notifications
You must be signed in to change notification settings - Fork 1
/
game_container.gd
130 lines (123 loc) · 2.65 KB
/
game_container.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
extends VBoxContainer
const SLIDES = {
"start": {
"label": "You find a dragon",
"image": "res://images/0.svg",
"sound": "res://sounds/kalimba.ogg",
"buttons": {
0:{
"text": "Attack the dragon",
"next": "attack"
},
1:{
"text": "Talk to the dragon",
"next": "talk"
}
}
},
"attack": {
"label": "You attack the dragon, but the dragon shoots fire at you and gets very angry",
"image": "res://images/attack.svg",
"sound": "res://sounds/bell.ogg",
"buttons": {
0:{
"text": "Attack the dragon again",
"next": "attack_again"
},
1:{
"text": "Say sorry to the dragon",
"next": "say_sorry"
}
}
},
"attack_again": {
"label": "You attack the dragon again, and the dragon obliterates you with more fire",
"image": "res://images/attack_again.svg",
"sound": "res://sounds/bell.ogg",
"buttons": {
0:{
"text": "Restart",
"next": "start"
},
1:{
"text": "Restart",
"next": "start"
}
}
},
"say_sorry": {
"label": "You say sorry to the dragon, and the dragon forgives you :)",
"image": "res://images/say_sorry.svg",
"sound": "res://sounds/bell.ogg",
"buttons": {
0:{
"text": "Restart",
"next": "start"
},
1:{
"text": "Restart",
"next": "start"
}
}
},
"talk": {
"label": "The dragon doesn't answer when you talk to him",
"image": "res://images/talk.svg",
"sound": "res://sounds/bell.ogg",
"buttons": {
0:{
"text": "Tell the dragon a joke",
"next": "joke"
},
1:{
"text": "Tell a compliment to the dragon",
"next": "compliment"
}
}
},
"joke": {
"label": "The dragon likes your joke",
"image": "res://images/joke.svg",
"sound": "res://sounds/bell.ogg",
"buttons": {
0:{
"text": "Restart",
"next": "start"
},
1:{
"text": "Restart",
"next": "start"
}
}
},
"compliment": {
"label": "The dragon likes your compliment",
"image": "res://images/compliment.svg",
"sound": "res://sounds/bell.ogg",
"buttons": {
0:{
"text": "Restart",
"next": "start"
},
1:{
"text": "Restart",
"next": "start"
}
}
}
}
var current_slide
func _ready():
set_slide("start")
func set_slide(slide: String) -> void:
current_slide = SLIDES[slide]
$Label.text = current_slide.label
$TextureRect.texture = load(current_slide.image)
$HBoxContainer/Button0.text = current_slide.buttons[0].text
$HBoxContainer/Button1.text = current_slide.buttons[1].text
$"../AudioStreamPlayer".stream = load(current_slide.sound)
$"../AudioStreamPlayer".play()
func _on_button_0_pressed():
set_slide(current_slide.buttons[0].next)
func _on_button_1_pressed():
set_slide(current_slide.buttons[1].next)