win/lose scenario, make the cutscenes

This commit is contained in:
D L 2023-01-30 00:40:31 -08:00
parent b5da1cf566
commit e02aaa26c2
6 changed files with 606 additions and 11 deletions

View File

@ -83,6 +83,10 @@ __meta__ = {
"_edit_vertical_guides_": [ 2134.0, 3833.0 ] "_edit_vertical_guides_": [ 2134.0, 3833.0 ]
} }
tile_set_name = "SnowySlopes" tile_set_name = "SnowySlopes"
finish_x_pos = 354
target_time = 60.0
defeat_cutscene = "LostRace1"
victory_cutscene = "Cutscene2"
spawning = { spawning = {
Vector2( 45, -6 ): "CIRNO", Vector2( 45, -6 ): "CIRNO",
Vector2( 80, -7 ): "SANAE", Vector2( 80, -7 ): "SANAE",

178
Scenes/LostRace1.tscn Normal file
View File

@ -0,0 +1,178 @@
[gd_scene load_steps=9 format=2]
[ext_resource path="res://Fonts/luckiest-guy/luckiest-guy.tres" type="DynamicFont" id=1]
[ext_resource path="res://Scripts/CutsceneRunner.gd" type="Script" id=2]
[ext_resource path="res://Sounds/Beep.wav" type="AudioStream" id=3]
[ext_resource path="res://Graphics/UI/DialogueBox.png" type="Texture" id=5]
[sub_resource type="Animation" id=3]
resource_name = "DialogueFade"
length = 2.0
tracks/0/type = "value"
tracks/0/path = NodePath(".:modulate")
tracks/0/interp = 1
tracks/0/loop_wrap = true
tracks/0/imported = false
tracks/0/enabled = true
tracks/0/keys = {
"times": PoolRealArray( 0, 0.7, 0.701, 1.2, 2 ),
"transitions": PoolRealArray( 1, 1, 1, 1, 1 ),
"update": 0,
"values": [ Color( 1, 1, 1, 1 ), Color( 1, 1, 1, 0 ), Color( 1, 1, 1, 0 ), Color( 1, 1, 1, 0 ), Color( 1, 1, 1, 1 ) ]
}
tracks/1/type = "method"
tracks/1/path = NodePath("..")
tracks/1/interp = 1
tracks/1/loop_wrap = true
tracks/1/imported = false
tracks/1/enabled = true
tracks/1/keys = {
"times": PoolRealArray( 0.7, 2 ),
"transitions": PoolRealArray( 1, 1 ),
"values": [ {
"args": [ ],
"method": "mid_dialogue_fade"
}, {
"args": [ ],
"method": "dialogue_fade_done"
} ]
}
[sub_resource type="Animation" id=4]
resource_name = "FinalFade"
length = 1.5
tracks/0/type = "value"
tracks/0/path = NodePath("../ColorRect:modulate")
tracks/0/interp = 1
tracks/0/loop_wrap = true
tracks/0/imported = false
tracks/0/enabled = true
tracks/0/keys = {
"times": PoolRealArray( 0, 1.5 ),
"transitions": PoolRealArray( 1, 1 ),
"update": 0,
"values": [ Color( 1, 1, 1, 0 ), Color( 1, 1, 1, 1 ) ]
}
tracks/1/type = "method"
tracks/1/path = NodePath("..")
tracks/1/interp = 1
tracks/1/loop_wrap = true
tracks/1/imported = false
tracks/1/enabled = true
tracks/1/keys = {
"times": PoolRealArray( 1.5 ),
"transitions": PoolRealArray( 1 ),
"values": [ {
"args": [ ],
"method": "final_fade_done"
} ]
}
[sub_resource type="Animation" id=1]
resource_name = "InitialFade"
length = 2.25
tracks/0/type = "value"
tracks/0/path = NodePath(".:modulate")
tracks/0/interp = 1
tracks/0/loop_wrap = true
tracks/0/imported = false
tracks/0/enabled = true
tracks/0/keys = {
"times": PoolRealArray( 1.5, 2.2 ),
"transitions": PoolRealArray( 1, 1 ),
"update": 0,
"values": [ Color( 1, 1, 1, 0 ), Color( 1, 1, 1, 1 ) ]
}
tracks/1/type = "value"
tracks/1/path = NodePath("../ColorRect:modulate")
tracks/1/interp = 1
tracks/1/loop_wrap = true
tracks/1/imported = false
tracks/1/enabled = true
tracks/1/keys = {
"times": PoolRealArray( 0, 1.5 ),
"transitions": PoolRealArray( 1, 1 ),
"update": 0,
"values": [ Color( 1, 1, 1, 1 ), Color( 1, 1, 1, 0 ) ]
}
tracks/2/type = "method"
tracks/2/path = NodePath("..")
tracks/2/interp = 1
tracks/2/loop_wrap = true
tracks/2/imported = false
tracks/2/enabled = true
tracks/2/keys = {
"times": PoolRealArray( 2.2 ),
"transitions": PoolRealArray( 1 ),
"values": [ {
"args": [ ],
"method": "dialogue_fade_done"
} ]
}
[sub_resource type="Animation" id=2]
length = 0.001
tracks/0/type = "value"
tracks/0/path = NodePath(".:modulate")
tracks/0/interp = 1
tracks/0/loop_wrap = true
tracks/0/imported = false
tracks/0/enabled = true
tracks/0/keys = {
"times": PoolRealArray( 0 ),
"transitions": PoolRealArray( 1 ),
"update": 0,
"values": [ Color( 1, 1, 1, 0 ) ]
}
tracks/1/type = "value"
tracks/1/path = NodePath("../ColorRect:modulate")
tracks/1/interp = 1
tracks/1/loop_wrap = true
tracks/1/imported = false
tracks/1/enabled = true
tracks/1/keys = {
"times": PoolRealArray( 0 ),
"transitions": PoolRealArray( 1 ),
"update": 0,
"values": [ Color( 1, 1, 1, 1 ) ]
}
[node name="Control" type="Control"]
anchor_right = 1.0
anchor_bottom = 1.0
script = ExtResource( 2 )
cutscene_name = "LostRace"
next_scene_to_load = "DownhillAutoscroller"
[node name="DialogueBox" type="TextureRect" parent="."]
modulate = Color( 1, 1, 1, 0 )
anchor_top = 1.0
anchor_right = 1.0
anchor_bottom = 1.0
margin_top = -120.0
texture = ExtResource( 5 )
[node name="RichTextLabel" type="RichTextLabel" parent="DialogueBox"]
anchor_right = 1.0
anchor_bottom = 1.0
margin_left = 24.0
margin_top = 12.0
margin_right = -24.0
margin_bottom = -12.0
custom_colors/default_color = Color( 0.196078, 0.2, 0.32549, 1 )
custom_fonts/normal_font = ExtResource( 1 )
[node name="AnimationPlayer" type="AnimationPlayer" parent="DialogueBox"]
anims/DialogueFade = SubResource( 3 )
anims/FinalFade = SubResource( 4 )
anims/InitialFade = SubResource( 1 )
anims/RESET = SubResource( 2 )
[node name="ColorRect" type="ColorRect" parent="."]
anchor_right = 1.0
anchor_bottom = 1.0
color = Color( 0, 0, 0, 1 )
[node name="AudioStreamPlayer" type="AudioStreamPlayer" parent="."]
stream = ExtResource( 3 )
volume_db = -10.0

178
Scenes/LostRace2.tscn Normal file
View File

@ -0,0 +1,178 @@
[gd_scene load_steps=9 format=2]
[ext_resource path="res://Fonts/luckiest-guy/luckiest-guy.tres" type="DynamicFont" id=1]
[ext_resource path="res://Scripts/CutsceneRunner.gd" type="Script" id=2]
[ext_resource path="res://Sounds/Beep.wav" type="AudioStream" id=3]
[ext_resource path="res://Graphics/UI/DialogueBox.png" type="Texture" id=5]
[sub_resource type="Animation" id=3]
resource_name = "DialogueFade"
length = 2.0
tracks/0/type = "value"
tracks/0/path = NodePath(".:modulate")
tracks/0/interp = 1
tracks/0/loop_wrap = true
tracks/0/imported = false
tracks/0/enabled = true
tracks/0/keys = {
"times": PoolRealArray( 0, 0.7, 0.701, 1.2, 2 ),
"transitions": PoolRealArray( 1, 1, 1, 1, 1 ),
"update": 0,
"values": [ Color( 1, 1, 1, 1 ), Color( 1, 1, 1, 0 ), Color( 1, 1, 1, 0 ), Color( 1, 1, 1, 0 ), Color( 1, 1, 1, 1 ) ]
}
tracks/1/type = "method"
tracks/1/path = NodePath("..")
tracks/1/interp = 1
tracks/1/loop_wrap = true
tracks/1/imported = false
tracks/1/enabled = true
tracks/1/keys = {
"times": PoolRealArray( 0.7, 2 ),
"transitions": PoolRealArray( 1, 1 ),
"values": [ {
"args": [ ],
"method": "mid_dialogue_fade"
}, {
"args": [ ],
"method": "dialogue_fade_done"
} ]
}
[sub_resource type="Animation" id=4]
resource_name = "FinalFade"
length = 1.5
tracks/0/type = "value"
tracks/0/path = NodePath("../ColorRect:modulate")
tracks/0/interp = 1
tracks/0/loop_wrap = true
tracks/0/imported = false
tracks/0/enabled = true
tracks/0/keys = {
"times": PoolRealArray( 0, 1.5 ),
"transitions": PoolRealArray( 1, 1 ),
"update": 0,
"values": [ Color( 1, 1, 1, 0 ), Color( 1, 1, 1, 1 ) ]
}
tracks/1/type = "method"
tracks/1/path = NodePath("..")
tracks/1/interp = 1
tracks/1/loop_wrap = true
tracks/1/imported = false
tracks/1/enabled = true
tracks/1/keys = {
"times": PoolRealArray( 1.5 ),
"transitions": PoolRealArray( 1 ),
"values": [ {
"args": [ ],
"method": "final_fade_done"
} ]
}
[sub_resource type="Animation" id=1]
resource_name = "InitialFade"
length = 2.25
tracks/0/type = "value"
tracks/0/path = NodePath(".:modulate")
tracks/0/interp = 1
tracks/0/loop_wrap = true
tracks/0/imported = false
tracks/0/enabled = true
tracks/0/keys = {
"times": PoolRealArray( 1.5, 2.2 ),
"transitions": PoolRealArray( 1, 1 ),
"update": 0,
"values": [ Color( 1, 1, 1, 0 ), Color( 1, 1, 1, 1 ) ]
}
tracks/1/type = "value"
tracks/1/path = NodePath("../ColorRect:modulate")
tracks/1/interp = 1
tracks/1/loop_wrap = true
tracks/1/imported = false
tracks/1/enabled = true
tracks/1/keys = {
"times": PoolRealArray( 0, 1.5 ),
"transitions": PoolRealArray( 1, 1 ),
"update": 0,
"values": [ Color( 1, 1, 1, 1 ), Color( 1, 1, 1, 0 ) ]
}
tracks/2/type = "method"
tracks/2/path = NodePath("..")
tracks/2/interp = 1
tracks/2/loop_wrap = true
tracks/2/imported = false
tracks/2/enabled = true
tracks/2/keys = {
"times": PoolRealArray( 2.2 ),
"transitions": PoolRealArray( 1 ),
"values": [ {
"args": [ ],
"method": "dialogue_fade_done"
} ]
}
[sub_resource type="Animation" id=2]
length = 0.001
tracks/0/type = "value"
tracks/0/path = NodePath(".:modulate")
tracks/0/interp = 1
tracks/0/loop_wrap = true
tracks/0/imported = false
tracks/0/enabled = true
tracks/0/keys = {
"times": PoolRealArray( 0 ),
"transitions": PoolRealArray( 1 ),
"update": 0,
"values": [ Color( 1, 1, 1, 0 ) ]
}
tracks/1/type = "value"
tracks/1/path = NodePath("../ColorRect:modulate")
tracks/1/interp = 1
tracks/1/loop_wrap = true
tracks/1/imported = false
tracks/1/enabled = true
tracks/1/keys = {
"times": PoolRealArray( 0 ),
"transitions": PoolRealArray( 1 ),
"update": 0,
"values": [ Color( 1, 1, 1, 1 ) ]
}
[node name="Control" type="Control"]
anchor_right = 1.0
anchor_bottom = 1.0
script = ExtResource( 2 )
cutscene_name = "LostRace"
next_scene_to_load = "DownhillAutoscroller2"
[node name="DialogueBox" type="TextureRect" parent="."]
modulate = Color( 1, 1, 1, 0 )
anchor_top = 1.0
anchor_right = 1.0
anchor_bottom = 1.0
margin_top = -120.0
texture = ExtResource( 5 )
[node name="RichTextLabel" type="RichTextLabel" parent="DialogueBox"]
anchor_right = 1.0
anchor_bottom = 1.0
margin_left = 24.0
margin_top = 12.0
margin_right = -24.0
margin_bottom = -12.0
custom_colors/default_color = Color( 0.196078, 0.2, 0.32549, 1 )
custom_fonts/normal_font = ExtResource( 1 )
[node name="AnimationPlayer" type="AnimationPlayer" parent="DialogueBox"]
anims/DialogueFade = SubResource( 3 )
anims/FinalFade = SubResource( 4 )
anims/InitialFade = SubResource( 1 )
anims/RESET = SubResource( 2 )
[node name="ColorRect" type="ColorRect" parent="."]
anchor_right = 1.0
anchor_bottom = 1.0
color = Color( 0, 0, 0, 1 )
[node name="AudioStreamPlayer" type="AudioStreamPlayer" parent="."]
stream = ExtResource( 3 )
volume_db = -10.0

178
Scenes/WonRace1.tscn Normal file
View File

@ -0,0 +1,178 @@
[gd_scene load_steps=9 format=2]
[ext_resource path="res://Fonts/luckiest-guy/luckiest-guy.tres" type="DynamicFont" id=1]
[ext_resource path="res://Scripts/CutsceneRunner.gd" type="Script" id=2]
[ext_resource path="res://Sounds/Beep.wav" type="AudioStream" id=3]
[ext_resource path="res://Graphics/UI/DialogueBox.png" type="Texture" id=5]
[sub_resource type="Animation" id=3]
resource_name = "DialogueFade"
length = 2.0
tracks/0/type = "value"
tracks/0/path = NodePath(".:modulate")
tracks/0/interp = 1
tracks/0/loop_wrap = true
tracks/0/imported = false
tracks/0/enabled = true
tracks/0/keys = {
"times": PoolRealArray( 0, 0.7, 0.701, 1.2, 2 ),
"transitions": PoolRealArray( 1, 1, 1, 1, 1 ),
"update": 0,
"values": [ Color( 1, 1, 1, 1 ), Color( 1, 1, 1, 0 ), Color( 1, 1, 1, 0 ), Color( 1, 1, 1, 0 ), Color( 1, 1, 1, 1 ) ]
}
tracks/1/type = "method"
tracks/1/path = NodePath("..")
tracks/1/interp = 1
tracks/1/loop_wrap = true
tracks/1/imported = false
tracks/1/enabled = true
tracks/1/keys = {
"times": PoolRealArray( 0.7, 2 ),
"transitions": PoolRealArray( 1, 1 ),
"values": [ {
"args": [ ],
"method": "mid_dialogue_fade"
}, {
"args": [ ],
"method": "dialogue_fade_done"
} ]
}
[sub_resource type="Animation" id=4]
resource_name = "FinalFade"
length = 1.5
tracks/0/type = "value"
tracks/0/path = NodePath("../ColorRect:modulate")
tracks/0/interp = 1
tracks/0/loop_wrap = true
tracks/0/imported = false
tracks/0/enabled = true
tracks/0/keys = {
"times": PoolRealArray( 0, 1.5 ),
"transitions": PoolRealArray( 1, 1 ),
"update": 0,
"values": [ Color( 1, 1, 1, 0 ), Color( 1, 1, 1, 1 ) ]
}
tracks/1/type = "method"
tracks/1/path = NodePath("..")
tracks/1/interp = 1
tracks/1/loop_wrap = true
tracks/1/imported = false
tracks/1/enabled = true
tracks/1/keys = {
"times": PoolRealArray( 1.5 ),
"transitions": PoolRealArray( 1 ),
"values": [ {
"args": [ ],
"method": "final_fade_done"
} ]
}
[sub_resource type="Animation" id=1]
resource_name = "InitialFade"
length = 2.25
tracks/0/type = "value"
tracks/0/path = NodePath(".:modulate")
tracks/0/interp = 1
tracks/0/loop_wrap = true
tracks/0/imported = false
tracks/0/enabled = true
tracks/0/keys = {
"times": PoolRealArray( 1.5, 2.2 ),
"transitions": PoolRealArray( 1, 1 ),
"update": 0,
"values": [ Color( 1, 1, 1, 0 ), Color( 1, 1, 1, 1 ) ]
}
tracks/1/type = "value"
tracks/1/path = NodePath("../ColorRect:modulate")
tracks/1/interp = 1
tracks/1/loop_wrap = true
tracks/1/imported = false
tracks/1/enabled = true
tracks/1/keys = {
"times": PoolRealArray( 0, 1.5 ),
"transitions": PoolRealArray( 1, 1 ),
"update": 0,
"values": [ Color( 1, 1, 1, 1 ), Color( 1, 1, 1, 0 ) ]
}
tracks/2/type = "method"
tracks/2/path = NodePath("..")
tracks/2/interp = 1
tracks/2/loop_wrap = true
tracks/2/imported = false
tracks/2/enabled = true
tracks/2/keys = {
"times": PoolRealArray( 2.2 ),
"transitions": PoolRealArray( 1 ),
"values": [ {
"args": [ ],
"method": "dialogue_fade_done"
} ]
}
[sub_resource type="Animation" id=2]
length = 0.001
tracks/0/type = "value"
tracks/0/path = NodePath(".:modulate")
tracks/0/interp = 1
tracks/0/loop_wrap = true
tracks/0/imported = false
tracks/0/enabled = true
tracks/0/keys = {
"times": PoolRealArray( 0 ),
"transitions": PoolRealArray( 1 ),
"update": 0,
"values": [ Color( 1, 1, 1, 0 ) ]
}
tracks/1/type = "value"
tracks/1/path = NodePath("../ColorRect:modulate")
tracks/1/interp = 1
tracks/1/loop_wrap = true
tracks/1/imported = false
tracks/1/enabled = true
tracks/1/keys = {
"times": PoolRealArray( 0 ),
"transitions": PoolRealArray( 1 ),
"update": 0,
"values": [ Color( 1, 1, 1, 1 ) ]
}
[node name="Control" type="Control"]
anchor_right = 1.0
anchor_bottom = 1.0
script = ExtResource( 2 )
cutscene_name = "LostRace"
next_scene_to_load = "DownhillAutoscroller2"
[node name="DialogueBox" type="TextureRect" parent="."]
modulate = Color( 1, 1, 1, 0 )
anchor_top = 1.0
anchor_right = 1.0
anchor_bottom = 1.0
margin_top = -120.0
texture = ExtResource( 5 )
[node name="RichTextLabel" type="RichTextLabel" parent="DialogueBox"]
anchor_right = 1.0
anchor_bottom = 1.0
margin_left = 24.0
margin_top = 12.0
margin_right = -24.0
margin_bottom = -12.0
custom_colors/default_color = Color( 0.196078, 0.2, 0.32549, 1 )
custom_fonts/normal_font = ExtResource( 1 )
[node name="AnimationPlayer" type="AnimationPlayer" parent="DialogueBox"]
anims/DialogueFade = SubResource( 3 )
anims/FinalFade = SubResource( 4 )
anims/InitialFade = SubResource( 1 )
anims/RESET = SubResource( 2 )
[node name="ColorRect" type="ColorRect" parent="."]
anchor_right = 1.0
anchor_bottom = 1.0
color = Color( 0, 0, 0, 1 )
[node name="AudioStreamPlayer" type="AudioStreamPlayer" parent="."]
stream = ExtResource( 3 )
volume_db = -10.0

View File

@ -20,23 +20,64 @@ var dialogue_fading_in : bool = true
var cutscene_directory = { var cutscene_directory = {
"Cutscene1": [ "Cutscene1": [
["Kyouko: Woooow.", ["Kyouko is relaxing outside while neglecting her duties.",
"Kyouko: I can't believe it's taken this long for them to make a stupid game about me snowboarding."], "Aya flies across Myouren Temple while the Bunbunmaru Newspaper falls down from above and hits the ground, Kyouko notices it and picks it up."],
["Reimu: Is the dialogue completed at least?", ["Kyouko: Huh, whats this?"],
"Kyouko: They're still working on it.",
"Reimu: Oh. Wake me up when they're finished."],
["Kyouko: Gee, I hope they get the game done soon.", ["She unfolds the paper and reads it."],
"Kyouko: I really wanna go snowboarding now."],
["Kyouko: Like I reaaally wanna. Really."], ["Kyouko: A winter game competition, eh? I wonder what this is about?"],
["~~ Looking for something to do with your holiday? Then come on down to Moriya Shrine, were looking for competitors to participate for our winter festival, winners will receive a statue of the legendary Inari Okami which will grant blessing for the upcoming harvest.", "We hope to see you attend Moriyas Wanton Winter Wagor! ~~"],
["Kyouko was hesitant at first about attending the winter fest, but her boredom got the best of her and decided to journey to Moriya Shrine."],
["Kyouko: I made up my mind, I'm going to Moriya shrine to win that statue for myself!"],
["Kyouko decides to rush down to Moriya shrine to compete for the prize, despite not knowing what was in store for her.", "Kyouko arrives at Moriya Shrine, though shes a bit nervous to see a large crowd of people gather from all across Gensokyo."],
["Kyouko: This place looks crowded, Im not so sure about this…"],
["As her shyness grows, she turns her attention away from the crowd and to Sanae and Reimu, they both seem to be talking about something."],
["Reimu: So where'd ya get this statue anyway?", "Sanae: Oh, I just found it in our storage one day. Guess we had it all along, huh?", "Reimu: Huh, weird."],
["This piqued Kyoukos interest and she wondered just how valuable this statue would be if were to win it for herself, this gets her excited for the competition."],
["Kyouko: Well, I guess Ill have to do my best!"],
["As everyone in the crowd prepares for the winter games, Kyouko braces herself for whatever challenge faces her."],
], ],
"Cutscene2": [ "Cutscene2": [
["Kyouko: Ain't got nothing going on in Cutscene 2 huh."], ["After a long competition, Kyouko was rewarded with the honor of opening the present that holds the statue inside, after she opened it everyone was greeted by a surprise."],
], ],
"Cutscene3": [ "Cutscene3": [
["Kyouko: Cutscene 3 too."], ["Luna, Sunny, Star: Congratulations, youre the winner!", "Kyouko: Whaaaaaaaat?!?"],
["Kyouko was bewildered by what she had seen, it turns out this wasnt the Inari Okami but a prank!"],
["Sanae: Wait, this was all a setup?", "Sunny: Hehe, surprised?", "Star: We fooled you!", "Luna: You shouldve seen it coming!"],
["There was confusion among the crowd, Kyouko was troubled by all this."],
["Reimu: So you were the ones who set all this up!"],
["Sunny: Thats right. While everyone was busy competing for the Okami statue, we decided to hide ourselves in this present while pretending to be the statue itself!"],
["The fairies were greeted with dead silence for a brief moment until Kyouko started laughing. Reimu and Sanae looked at each other in confusion."],
["Kyouko: Bwhahaha, you got me good, I havent had this much fun in a while!"],
["The three fairies looked at each other in confusion at first, then decided to laugh all together while the crowd decided to leave.", "As the sun sets, Kyouko waves goodbye to the fairies as they part ways."],
["Kyouko: I cant wait to tell lady Byakuren about my journey once I return to Myouren Temple!"],
],
"LostRace": [
["You lost the race - try again!"],
],
"WonRace": [
["You won the race! Onto the next one!"],
], ],
} }
@ -45,6 +86,8 @@ func _ready():
animation_player = find_node("AnimationPlayer") animation_player = find_node("AnimationPlayer")
audio_stream_player = find_node("AudioStreamPlayer") audio_stream_player = find_node("AudioStreamPlayer")
animation_player.play("InitialFade") animation_player.play("InitialFade")
if cutscene_name == "Cutscene2":
MusicController.play_score_end()
func advance_dialogue(): func advance_dialogue():
if cutscene_sub_index == cutscene_directory[cutscene_name][cutscene_index].size() - 1: if cutscene_sub_index == cutscene_directory[cutscene_name][cutscene_index].size() - 1:

View File

@ -11,6 +11,10 @@ class_name GameScene
export var tile_set_name: String export var tile_set_name: String
export var camera_h_offset : float = 3 export var camera_h_offset : float = 3
export var camera_v_offset : float = 1 export var camera_v_offset : float = 1
export var finish_x_pos : int
export var target_time : float
export var defeat_cutscene : String
export var victory_cutscene : String
const Constants = preload("res://Scripts/Constants.gd") const Constants = preload("res://Scripts/Constants.gd")
const Unit = preload("res://Scripts/Unit.gd") const Unit = preload("res://Scripts/Unit.gd")
const UNIT_DIRECTORY = { const UNIT_DIRECTORY = {
@ -23,6 +27,7 @@ export var spawning : Dictionary
var spawning_map = {} # keeps track of what's alive var spawning_map = {} # keeps track of what's alive
var paused : bool = false var paused : bool = false
var race_over : bool = false
var units = [] var units = []
var player : Player var player : Player
@ -98,7 +103,16 @@ func _process(delta):
if !stage_finished: if !stage_finished:
time_elapsed_in_race += delta time_elapsed_in_race += delta
# 1 grid unit = 2ft, 1 grid unit / s = 1.36 mph # 1 grid unit = 2ft, 1 grid unit / s = 1.36 mph
player_speed_mph = sqrt(pow(player.v_speed, 2) + pow(player.h_speed, 2)) * 1.36 player_speed_mph = player.h_speed * 1.36
if not race_over and player.pos.x >= finish_x_pos:
race_over = true
if time_elapsed_in_race > target_time:
# lost race
get_tree().change_scene("res://Scenes/" + defeat_cutscene + ".tscn")
else:
# won race
get_tree().change_scene("res://Scenes/" + victory_cutscene + ".tscn")
func read_paused(): func read_paused():
if Input.is_action_just_pressed(Constants.INPUT_MAP[Constants.PlayerInput.GBA_START]): if Input.is_action_just_pressed(Constants.INPUT_MAP[Constants.PlayerInput.GBA_START]):