-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathGame.tscn
286 lines (223 loc) · 7.29 KB
/
Game.tscn
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
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
[gd_scene load_steps=13 format=2]
[ext_resource path="res://StartMenu.tscn" type="PackedScene" id=1]
[ext_resource path="res://Fonts/Font.tres" type="DynamicFont" id=2]
[ext_resource path="res://Audio/CameraShutter_2.wav" type="AudioStream" id=3]
[ext_resource path="res://Audio/Uber.wav" type="AudioStream" id=4]
[ext_resource path="res://Audio/Cold.wav" type="AudioStream" id=5]
[ext_resource path="res://Pause.gd" type="Script" id=6]
[ext_resource path="res://Fonts/robotomediumfont.tres" type="DynamicFont" id=7]
[ext_resource path="res://RichTextLabel.gd" type="Script" id=8]
[sub_resource type="GDScript" id=1]
script/source = "extends Node
export(PackedScene) var start_level
export(Array, String) var game_levels
export(Array, String) var hard_game_levels
var levelHolder : Node
var bigText : Label
var current_level : Node
var currentBigTextTimer : Timer
var currentLevelIndex : int
var tween : Tween
var allow_input = true
var isSlomo
var startSlomoTime
var slomoSecondsFixed : float
var slomoAmount
var chosen_levels
var textSound
func _ready():
var material = preload(\"res://glow_material.tres\")
material = preload(\"res://highlight_material.tres\")
levelHolder = get_node(\"Current Level\")
bigText = get_node(\"Overlay UI/Big Text\")
textSound = get_node(\"TextSound\")
tween = get_node(\"Tween\")
start_over()
showBigText(\".\", 0.1, false)
func slomo(secondsFixed : float, amount: float):
Engine.time_scale = amount
isSlomo = true
startSlomoTime = OS.get_ticks_msec()
slomoSecondsFixed = secondsFixed
slomoAmount = amount
func _process(delta):
var now = OS.get_ticks_msec()
var slomoChangeTime = 2.0
if isSlomo:
var after = now - (startSlomoTime + (slomoSecondsFixed * 1000))
if after >= 0:
var slomoFactor = after / (slomoChangeTime * 1000)
var timeScale = clamp(lerp(slomoAmount, 1, slomoFactor), 0.1, 1)
Engine.time_scale = timeScale
if timeScale == 1:
isSlomo = false
func start_over():
chosen_levels = null
currentLevelIndex = -1
set_level(start_level)
func choose_level_type(type):
if type == \"hard\":
chosen_levels = hard_game_levels
else:
chosen_levels = game_levels
func next_level():
if not chosen_levels: return
currentLevelIndex += 1
if currentLevelIndex >= chosen_levels.size():
start_over()
return
var newLevel = load(chosen_levels[currentLevelIndex])
set_level(newLevel)
func restart_level():
set_level(load(chosen_levels[currentLevelIndex]))
func set_level(level : PackedScene):
Engine.time_scale = 1
get_tree().paused = false
if is_instance_valid(current_level):
current_level.queue_free()
yield(get_tree(), \"idle_frame\")
current_level = level.instance()
levelHolder.add_child(current_level)
func player_died():
clearBigText()
get_tree().paused = true
allow_input = false
var dead = get_node(\"Overlay UI\").find_node(\"Dead\")
dead.visible = true
tween().interpolate_property(dead, \"modulate:a\", 0.5, 1, 1, Tween.TRANS_QUAD, Tween.EASE_OUT)
yield(delay(2, true, false), \"timeout\")
restart_level()
dead.modulate.a = 0
dead.visible = false
func delay(seconds : float = 1, start : bool = true, pausable : bool = true):
var timer = Timer.new()
var parent = get_node(\"Current Level\") if pausable else self
parent.add_child(timer)
timer.one_shot = true
timer.wait_time = seconds
if start:
timer.start()
return timer
func clearBigText():
bigText.text = \"\"
func showBigText(text : String, totalTime : float = 2, playsound: bool = true):
if currentBigTextTimer and !currentBigTextTimer.is_stopped():
currentBigTextTimer.stop()
var words = text.split(\" \")
var timer = delay(totalTime / words.size())
timer.one_shot = false
currentBigTextTimer = timer
for word in words:
if playsound:
textSound.play()
bigText.text = word
bigText.rect_scale = Vector2(1.0, 1.0)
tween.interpolate_property(bigText, \"rect_scale\",
Vector2(1.0, 1.0),
Vector2(0.75, 0.75),
min(0.5, timer.wait_time), Tween.TRANS_QUAD, Tween.EASE_OUT)
tween.start()
yield(timer, \"timeout\")
clearBigText()
func playGameName(times : int):
var timer = delay(0.65, true, false)
timer.one_shot = false
for time in range(0, times):
showBigText(\"UBER COLD\", 0.65 * 2)
get_node(\"Audio/Uber\").pitch_scale = Engine.time_scale
get_node(\"Audio/Uber\").play()
yield(timer, \"timeout\")
get_node(\"Audio/Cold\").pitch_scale = Engine.time_scale
get_node(\"Audio/Cold\").play()
yield(timer, \"timeout\")
func level_add(obj):
current_level.add_child(obj)
func tween():
var tween = Tween.new()
add_child(tween)
tween.start()
return tween"
[sub_resource type="Gradient" id=2]
offsets = PoolRealArray( 0 )
colors = PoolColorArray( 1, 1, 1, 1 )
[sub_resource type="GradientTexture" id=3]
gradient = SubResource( 2 )
width = 1423
[sub_resource type="GDScript" id=4]
script/source = "extends Label
func _process(_delta):
rect_pivot_offset = rect_size / 2.0"
[node name="Game" type="Node"]
pause_mode = 2
script = SubResource( 1 )
start_level = ExtResource( 1 )
game_levels = [ "res://TutorialLevel.tscn", "res://Level.tscn", "res://Level3.tscn", "res://Level2.tscn", "res://Level5.tscn", "res://Level4.tscn", "res://Level6.tscn" ]
hard_game_levels = [ "res://TutorialLevelHard.tscn", "res://Level3Hard.tscn", "res://Level4Hard.tscn", "res://LevelHard.tscn", "res://Level5Hard.tscn", "res://Level2Hard.tscn", "res://Level6Hard.tscn" ]
[node name="Overlay UI" type="Control" parent="."]
editor/display_folded = true
anchor_right = 1.0
anchor_bottom = 1.0
margin_top = -2.0
margin_bottom = -2.0
mouse_filter = 2
[node name="Dead" type="TextureRect" parent="Overlay UI"]
visible = false
modulate = Color( 1, 0, 0, 0.552941 )
anchor_right = 1.0
anchor_bottom = 1.0
mouse_filter = 2
texture = SubResource( 3 )
expand = true
[node name="Big Text" type="Label" parent="Overlay UI"]
anchor_top = 0.5
anchor_right = 1.0
anchor_bottom = 0.5
margin_left = -59.082
margin_top = -165.04
margin_right = -59.082
margin_bottom = 181.96
rect_pivot_offset = Vector2( 512, 124 )
custom_fonts/font = ExtResource( 2 )
align = 1
valign = 1
script = SubResource( 4 )
[node name="Current Level" type="Node" parent="."]
pause_mode = 1
[node name="TextSound" type="AudioStreamPlayer" parent="."]
stream = ExtResource( 3 )
volume_db = -3.391
pitch_scale = 0.8
[node name="Audio" type="Node" parent="."]
editor/display_folded = true
[node name="Uber" type="AudioStreamPlayer" parent="Audio"]
stream = ExtResource( 4 )
[node name="Cold" type="AudioStreamPlayer" parent="Audio"]
stream = ExtResource( 5 )
[node name="Tween" type="Tween" parent="."]
[node name="CanvasLayer" type="CanvasLayer" parent="."]
layer = 128
[node name="Pause" type="Control" parent="CanvasLayer"]
pause_mode = 2
visible = false
anchor_right = 1.0
anchor_bottom = 1.0
script = ExtResource( 6 )
[node name="Overlay" type="ColorRect" parent="CanvasLayer/Pause"]
anchor_right = 1.0
anchor_bottom = 1.0
color = Color( 0, 0, 0, 0.623529 )
[node name="RichTextLabel" type="RichTextLabel" parent="CanvasLayer/Pause/Overlay"]
anchor_left = 0.5
anchor_top = 0.5
anchor_right = 0.5
anchor_bottom = 0.5
margin_left = -694.0
margin_top = -483.0
margin_right = 694.0
margin_bottom = 483.0
custom_fonts/normal_font = ExtResource( 7 )
text = "PRESS 'ESC' OR 'START' TO RESUME
UNPAUSE AND PRESS 'DELETE' KEY DURING GAMEPLAY TO QUIT
UBERCOLD IS SHORT AND DOES NOT HAVE A SAVE FUNCTION
IF YOU QUIT YOU WILL LOSE YOUR PROGRESS"
script = ExtResource( 8 )