game over screen and stuff
This commit is contained in:
@@ -11,7 +11,6 @@ var word_set_array
|
|||||||
var alphabet = ["A","B","C","D","E","F","G","H","I","J","K","L","M","N",
|
var alphabet = ["A","B","C","D","E","F","G","H","I","J","K","L","M","N",
|
||||||
"O","P","Q","R","S","T","U","V","W","X","Y","Z"]
|
"O","P","Q","R","S","T","U","V","W","X","Y","Z"]
|
||||||
var comets = []
|
var comets = []
|
||||||
var comet_speed = 150
|
|
||||||
var active
|
var active
|
||||||
|
|
||||||
# display
|
# display
|
||||||
@@ -19,15 +18,21 @@ var viewport_size
|
|||||||
var scale_factor_x
|
var scale_factor_x
|
||||||
var scale_factor_y
|
var scale_factor_y
|
||||||
|
|
||||||
# numbers
|
# difficulty
|
||||||
var max_delay = 2
|
var max_delay = 2
|
||||||
|
var min_delay = .5
|
||||||
var delay = max_delay
|
var delay = max_delay
|
||||||
|
var comet_speed = 250
|
||||||
|
|
||||||
|
# numbers
|
||||||
var spawn_timer = 0
|
var spawn_timer = 0
|
||||||
var max_character_count = 0
|
var max_character_count = 0
|
||||||
|
|
||||||
# stats
|
# stats
|
||||||
var health = 100
|
var health = 100
|
||||||
|
var hit_count = 0.0
|
||||||
var miss_count = 0.0
|
var miss_count = 0.0
|
||||||
|
var comets_processed = 0.0
|
||||||
var total_comets = 0.0
|
var total_comets = 0.0
|
||||||
|
|
||||||
# ui init
|
# ui init
|
||||||
@@ -80,18 +85,23 @@ func _ready() -> void:
|
|||||||
# Runs every frame
|
# Runs every frame
|
||||||
func _process(delta: float) -> void:
|
func _process(delta: float) -> void:
|
||||||
if active:
|
if active:
|
||||||
|
|
||||||
|
if health <= 0:
|
||||||
|
game_over()
|
||||||
|
|
||||||
spawn_timer += delta
|
spawn_timer += delta
|
||||||
|
|
||||||
hp_label.text = "HP: " + str(health)
|
hp_label.text = "HP: " + str(health)
|
||||||
miss_label.text = "X: " + str(miss_count)
|
miss_label.text = "X: " + str(miss_count)
|
||||||
if total_comets > 0:
|
|
||||||
var accper = (total_comets - miss_count)/(total_comets)*100
|
|
||||||
acc_label.text = "ACC: " + str(snapped(accper, .02)) + "%"
|
|
||||||
|
|
||||||
if spawn_timer >= delay:
|
if spawn_timer >= delay:
|
||||||
spawn_timer = 0
|
spawn_timer = 0
|
||||||
spawn_word()
|
spawn_word()
|
||||||
|
|
||||||
|
func calculate_accuracy():
|
||||||
|
var accper = (hit_count)/(comets_processed)*100
|
||||||
|
acc_label.text = "ACC: " + str(snapped(accper, .02)) + "%"
|
||||||
|
|
||||||
func spawn_word():
|
func spawn_word():
|
||||||
var scan_commet = comet_source.instantiate()
|
var scan_commet = comet_source.instantiate()
|
||||||
var comet_width = scan_commet.get_node("Sprite").sprite_frames.get_frame_texture("comet",0).get_width()
|
var comet_width = scan_commet.get_node("Sprite").sprite_frames.get_frame_texture("comet",0).get_width()
|
||||||
@@ -100,24 +110,35 @@ func spawn_word():
|
|||||||
var offset = comet_width
|
var offset = comet_width
|
||||||
scan_commet.queue_free()
|
scan_commet.queue_free()
|
||||||
|
|
||||||
for char in new_word:
|
for chara in new_word:
|
||||||
if char != " ":
|
if chara != " ":
|
||||||
var new_commet = comet_source.instantiate()
|
var new_commet = comet_source.instantiate()
|
||||||
total_comets += 1
|
total_comets += 1
|
||||||
new_commet.position = Vector2(offset,-128)
|
new_commet.position = Vector2(offset,-128)
|
||||||
new_commet.get_node("Sprite").get_node("Label").text = char
|
new_commet.get_node("Sprite").get_node("Label").text = chara
|
||||||
new_commet.speed = comet_speed
|
new_commet.speed = comet_speed
|
||||||
add_child(new_commet)
|
add_child(new_commet)
|
||||||
comets.append(new_commet)
|
comets.append(new_commet)
|
||||||
offset += dist
|
offset += dist
|
||||||
|
|
||||||
delay = randf_range(0.75,max_delay)
|
delay = randf_range(min_delay,max_delay)
|
||||||
|
|
||||||
func take_damage():
|
func miss(comet):
|
||||||
pass
|
$Miss.play()
|
||||||
|
health -= comet.damage
|
||||||
|
comets_processed += 1
|
||||||
|
miss_count += 1.0
|
||||||
|
calculate_accuracy()
|
||||||
|
comets.erase(comet)
|
||||||
|
comet.queue_free()
|
||||||
|
|
||||||
func game_over():
|
func game_over():
|
||||||
pass
|
active = false
|
||||||
|
$BackgroundMusic.stop()
|
||||||
|
self.get_node("OnTop").get_node("GameOver").visible = true
|
||||||
|
$Lose.play()
|
||||||
|
await $Lose.finished
|
||||||
|
$Sad.play()
|
||||||
|
|
||||||
func _input(event):
|
func _input(event):
|
||||||
if event is InputEventKey and event.pressed:
|
if event is InputEventKey and event.pressed:
|
||||||
@@ -126,6 +147,9 @@ func _input(event):
|
|||||||
if len(comets) > 0:
|
if len(comets) > 0:
|
||||||
var comet = comets[0]
|
var comet = comets[0]
|
||||||
if event.as_text() == comet.get_node("Sprite").get_node("Label").text:
|
if event.as_text() == comet.get_node("Sprite").get_node("Label").text:
|
||||||
|
comets_processed += 1
|
||||||
|
hit_count += 1
|
||||||
|
calculate_accuracy()
|
||||||
comet.self_active = false
|
comet.self_active = false
|
||||||
var laser = Line2D.new()
|
var laser = Line2D.new()
|
||||||
laser.default_color = Color.RED
|
laser.default_color = Color.RED
|
||||||
|
|||||||
@@ -2,15 +2,25 @@
|
|||||||
|
|
||||||
[ext_resource type="Script" uid="uid://c7vntfq6dyb2k" path="res://scenes/game/comet_zap.gd" id="1_eyb20"]
|
[ext_resource type="Script" uid="uid://c7vntfq6dyb2k" path="res://scenes/game/comet_zap.gd" id="1_eyb20"]
|
||||||
[ext_resource type="Texture2D" uid="uid://b0jndopqfkddu" path="res://assets/visual/backgrounds/omori/Battle Backgrounds/battleback_ow_outskirts.png" id="2_2j0xl"]
|
[ext_resource type="Texture2D" uid="uid://b0jndopqfkddu" path="res://assets/visual/backgrounds/omori/Battle Backgrounds/battleback_ow_outskirts.png" id="2_2j0xl"]
|
||||||
[ext_resource type="AudioStream" uid="uid://b2l55uknctgo6" path="res://assets/audio/music/game/comet_zap/Ranma Nibun-no-ichi Bakuretsu Rantouhen - King's Casino [Qk0v_NIqVPg].mp3" id="2_ije4o"]
|
[ext_resource type="AudioStream" uid="uid://dr0f3y1aux6nd" path="res://assets/audio/music/game/comet_zap/04 Ranma's Home.mp3" id="3_6eapk"]
|
||||||
[ext_resource type="AudioStream" uid="uid://ckr4pf3etle0p" path="res://assets/audio/sfx/SYS_cancel.ogg" id="4_2j0xl"]
|
[ext_resource type="AudioStream" uid="uid://ckr4pf3etle0p" path="res://assets/audio/sfx/SYS_cancel.ogg" id="4_2j0xl"]
|
||||||
[ext_resource type="Texture2D" uid="uid://jd2rnhvq6gl6" path="res://original data/images/tux/tux-yes2.png" id="4_yib6v"]
|
[ext_resource type="Texture2D" uid="uid://jd2rnhvq6gl6" path="res://original data/images/tux/tux-yes2.png" id="4_yib6v"]
|
||||||
[ext_resource type="AudioStream" uid="uid://t6tbvilcrwy8" path="res://assets/audio/sfx/SE_Push.ogg" id="5_62k7v"]
|
[ext_resource type="AudioStream" uid="uid://t6tbvilcrwy8" path="res://assets/audio/sfx/SE_Push.ogg" id="5_62k7v"]
|
||||||
|
[ext_resource type="AudioStream" uid="uid://b2xxkgi6bcfh2" path="res://assets/audio/sfx/break.mp3" id="6_6eapk"]
|
||||||
[ext_resource type="PackedScene" uid="uid://dm6jp4gjboooc" path="res://scenes/menus/pause/pause.tscn" id="6_cjaft"]
|
[ext_resource type="PackedScene" uid="uid://dm6jp4gjboooc" path="res://scenes/menus/pause/pause.tscn" id="6_cjaft"]
|
||||||
|
[ext_resource type="AudioStream" uid="uid://podscahsf0d4" path="res://assets/audio/sfx/MenuAccept.wav" id="7_4elh0"]
|
||||||
|
[ext_resource type="AudioStream" uid="uid://cboj3eff78kep" path="res://assets/audio/music/game/comet_zap/game_over/Finish Line (Lose) - Mario Kart Wii (Soundtrack) [Znjt4LvF4js].mp3" id="8_jnvlf"]
|
||||||
|
[ext_resource type="AudioStream" uid="uid://c4drvuieit6x5" path="res://assets/audio/music/game/comet_zap/game_over/Romeo Santos Eres Mía Audio [vY_3YrKtUUE].mp3" id="9_rlh21"]
|
||||||
|
[ext_resource type="Script" uid="uid://or8mcd735o0r" path="res://scenes/game/restart.gd" id="10_apana"]
|
||||||
|
[ext_resource type="Script" uid="uid://crxm56favhwos" path="res://scenes/game/exit.gd" id="11_jnvlf"]
|
||||||
|
[ext_resource type="Texture2D" uid="uid://cif65rts2oljo" path="res://assets/visual/sprites/Hornet_Idle.png" id="12_rlh21"]
|
||||||
|
|
||||||
[sub_resource type="LabelSettings" id="LabelSettings_2j0xl"]
|
[sub_resource type="LabelSettings" id="LabelSettings_2j0xl"]
|
||||||
font_size = 50
|
font_size = 50
|
||||||
|
|
||||||
|
[sub_resource type="LabelSettings" id="LabelSettings_xsyba"]
|
||||||
|
font_size = 128
|
||||||
|
|
||||||
[node name="CometZap" type="Node2D" unique_id=1227404695]
|
[node name="CometZap" type="Node2D" unique_id=1227404695]
|
||||||
script = ExtResource("1_eyb20")
|
script = ExtResource("1_eyb20")
|
||||||
|
|
||||||
@@ -38,7 +48,8 @@ expand_mode = 1
|
|||||||
metadata/_edit_use_anchors_ = true
|
metadata/_edit_use_anchors_ = true
|
||||||
|
|
||||||
[node name="BackgroundMusic" type="AudioStreamPlayer2D" parent="." unique_id=1814622732]
|
[node name="BackgroundMusic" type="AudioStreamPlayer2D" parent="." unique_id=1814622732]
|
||||||
stream = ExtResource("2_ije4o")
|
stream = ExtResource("3_6eapk")
|
||||||
|
volume_db = 5.0
|
||||||
autoplay = true
|
autoplay = true
|
||||||
parameters/looping = true
|
parameters/looping = true
|
||||||
|
|
||||||
@@ -48,6 +59,19 @@ stream = ExtResource("4_2j0xl")
|
|||||||
[node name="CometBreakSound" type="AudioStreamPlayer2D" parent="." unique_id=169663936]
|
[node name="CometBreakSound" type="AudioStreamPlayer2D" parent="." unique_id=169663936]
|
||||||
stream = ExtResource("5_62k7v")
|
stream = ExtResource("5_62k7v")
|
||||||
|
|
||||||
|
[node name="Miss" type="AudioStreamPlayer2D" parent="." unique_id=1721176045]
|
||||||
|
stream = ExtResource("6_6eapk")
|
||||||
|
|
||||||
|
[node name="ButtonPress" type="AudioStreamPlayer2D" parent="." unique_id=1890596377]
|
||||||
|
stream = ExtResource("7_4elh0")
|
||||||
|
volume_db = -10.0
|
||||||
|
|
||||||
|
[node name="Lose" type="AudioStreamPlayer2D" parent="." unique_id=1672401064]
|
||||||
|
stream = ExtResource("8_jnvlf")
|
||||||
|
|
||||||
|
[node name="Sad" type="AudioStreamPlayer2D" parent="." unique_id=228584401]
|
||||||
|
stream = ExtResource("9_rlh21")
|
||||||
|
|
||||||
[node name="Tux" type="Sprite2D" parent="." unique_id=1799546830]
|
[node name="Tux" type="Sprite2D" parent="." unique_id=1799546830]
|
||||||
position = Vector2(960, 990)
|
position = Vector2(960, 990)
|
||||||
scale = Vector2(3.583, 3)
|
scale = Vector2(3.583, 3)
|
||||||
@@ -97,6 +121,81 @@ label_settings = SubResource("LabelSettings_2j0xl")
|
|||||||
[node name="Pause" parent="OnTop" unique_id=1227462733 instance=ExtResource("6_cjaft")]
|
[node name="Pause" parent="OnTop" unique_id=1227462733 instance=ExtResource("6_cjaft")]
|
||||||
visible = false
|
visible = false
|
||||||
|
|
||||||
|
[node name="GameOver" type="Control" parent="OnTop" unique_id=2084475928]
|
||||||
|
visible = false
|
||||||
|
layout_mode = 3
|
||||||
|
anchors_preset = 15
|
||||||
|
anchor_right = 1.0
|
||||||
|
anchor_bottom = 1.0
|
||||||
|
grow_horizontal = 2
|
||||||
|
grow_vertical = 2
|
||||||
|
|
||||||
|
[node name="Dim" type="ColorRect" parent="OnTop/GameOver" unique_id=651690269]
|
||||||
|
layout_mode = 1
|
||||||
|
anchors_preset = 15
|
||||||
|
anchor_right = 1.0
|
||||||
|
anchor_bottom = 1.0
|
||||||
|
grow_horizontal = 2
|
||||||
|
grow_vertical = 2
|
||||||
|
color = Color(0, 0, 0, 0.29411766)
|
||||||
|
|
||||||
|
[node name="Label" type="Label" parent="OnTop/GameOver" unique_id=1830840075]
|
||||||
|
layout_mode = 1
|
||||||
|
anchors_preset = 8
|
||||||
|
anchor_left = 0.5
|
||||||
|
anchor_top = 0.5
|
||||||
|
anchor_right = 0.5
|
||||||
|
anchor_bottom = 0.5
|
||||||
|
offset_left = -277.0
|
||||||
|
offset_top = -290.0
|
||||||
|
offset_right = 277.0
|
||||||
|
offset_bottom = -114.99994
|
||||||
|
grow_horizontal = 2
|
||||||
|
grow_vertical = 2
|
||||||
|
text = "GIT GUD!"
|
||||||
|
label_settings = SubResource("LabelSettings_xsyba")
|
||||||
|
|
||||||
|
[node name="Buttons" type="BoxContainer" parent="OnTop/GameOver" unique_id=812956524]
|
||||||
|
layout_mode = 1
|
||||||
|
anchors_preset = 8
|
||||||
|
anchor_left = 0.5
|
||||||
|
anchor_top = 0.5
|
||||||
|
anchor_right = 0.5
|
||||||
|
anchor_bottom = 0.5
|
||||||
|
offset_left = -267.0
|
||||||
|
offset_top = -118.75
|
||||||
|
offset_right = 267.0
|
||||||
|
offset_bottom = 118.75
|
||||||
|
grow_horizontal = 2
|
||||||
|
grow_vertical = 2
|
||||||
|
alignment = 1
|
||||||
|
vertical = true
|
||||||
|
|
||||||
|
[node name="Restart" type="Button" parent="OnTop/GameOver/Buttons" unique_id=702028007]
|
||||||
|
layout_mode = 2
|
||||||
|
size_flags_vertical = 3
|
||||||
|
theme_override_font_sizes/font_size = 32
|
||||||
|
text = "Restart
|
||||||
|
"
|
||||||
|
script = ExtResource("10_apana")
|
||||||
|
|
||||||
|
[node name="Exit" type="Button" parent="OnTop/GameOver/Buttons" unique_id=1929956127]
|
||||||
|
layout_mode = 2
|
||||||
|
size_flags_vertical = 3
|
||||||
|
theme_override_font_sizes/font_size = 32
|
||||||
|
text = "Back To Title
|
||||||
|
"
|
||||||
|
script = ExtResource("11_jnvlf")
|
||||||
|
|
||||||
|
[node name="silson" type="TextureRect" parent="OnTop/GameOver" unique_id=761029797]
|
||||||
|
layout_mode = 0
|
||||||
|
offset_left = 1270.0
|
||||||
|
offset_top = 394.0
|
||||||
|
offset_right = 1863.0
|
||||||
|
offset_bottom = 1185.0
|
||||||
|
texture = ExtResource("12_rlh21")
|
||||||
|
stretch_mode = 4
|
||||||
|
|
||||||
[node name="Fade" type="ColorRect" parent="OnTop" unique_id=1872046404]
|
[node name="Fade" type="ColorRect" parent="OnTop" unique_id=1872046404]
|
||||||
visible = false
|
visible = false
|
||||||
anchors_preset = 15
|
anchors_preset = 15
|
||||||
@@ -106,3 +205,6 @@ grow_horizontal = 2
|
|||||||
grow_vertical = 2
|
grow_vertical = 2
|
||||||
mouse_filter = 2
|
mouse_filter = 2
|
||||||
color = Color(0, 0, 0, 1)
|
color = Color(0, 0, 0, 1)
|
||||||
|
|
||||||
|
[connection signal="pressed" from="OnTop/GameOver/Buttons/Restart" to="OnTop/GameOver/Buttons/Restart" method="_on_pressed"]
|
||||||
|
[connection signal="pressed" from="OnTop/GameOver/Buttons/Exit" to="OnTop/GameOver/Buttons/Exit" method="_on_pressed"]
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
[gd_scene format=3 uid="uid://dm6jp4gjboooc"]
|
[gd_scene format=3 uid="uid://dm6jp4gjboooc"]
|
||||||
|
|
||||||
[ext_resource type="Script" uid="uid://15e0tr7en3iq" path="res://scenes/menus/pause/pause.gd" id="1_8lsyj"]
|
[ext_resource type="Script" uid="uid://15e0tr7en3iq" path="res://scenes/menus/pause/pause.gd" id="1_8lsyj"]
|
||||||
|
[ext_resource type="Script" uid="uid://or8mcd735o0r" path="res://scenes/game/restart.gd" id="2_miayh"]
|
||||||
[ext_resource type="AudioStream" uid="uid://podscahsf0d4" path="res://assets/audio/sfx/MenuAccept.wav" id="2_y88h8"]
|
[ext_resource type="AudioStream" uid="uid://podscahsf0d4" path="res://assets/audio/sfx/MenuAccept.wav" id="2_y88h8"]
|
||||||
|
|
||||||
[node name="Pause" type="Control" unique_id=1227462733]
|
[node name="Pause" type="Control" unique_id=1227462733]
|
||||||
@@ -43,6 +44,14 @@ size_flags_vertical = 3
|
|||||||
theme_override_font_sizes/font_size = 32
|
theme_override_font_sizes/font_size = 32
|
||||||
text = "Resume"
|
text = "Resume"
|
||||||
|
|
||||||
|
[node name="Restart" type="Button" parent="BoxContainer" unique_id=1217720724]
|
||||||
|
layout_mode = 2
|
||||||
|
size_flags_vertical = 3
|
||||||
|
theme_override_font_sizes/font_size = 32
|
||||||
|
text = "Restart
|
||||||
|
"
|
||||||
|
script = ExtResource("2_miayh")
|
||||||
|
|
||||||
[node name="Options" type="Button" parent="BoxContainer" unique_id=1573468039]
|
[node name="Options" type="Button" parent="BoxContainer" unique_id=1573468039]
|
||||||
layout_mode = 2
|
layout_mode = 2
|
||||||
size_flags_vertical = 3
|
size_flags_vertical = 3
|
||||||
@@ -61,5 +70,6 @@ stream = ExtResource("2_y88h8")
|
|||||||
volume_db = -10.0
|
volume_db = -10.0
|
||||||
|
|
||||||
[connection signal="pressed" from="BoxContainer/Back" to="." method="_on_back_pressed"]
|
[connection signal="pressed" from="BoxContainer/Back" to="." method="_on_back_pressed"]
|
||||||
|
[connection signal="pressed" from="BoxContainer/Restart" to="BoxContainer/Restart" method="_on_pressed"]
|
||||||
[connection signal="pressed" from="BoxContainer/Options" to="." method="_on_options_pressed"]
|
[connection signal="pressed" from="BoxContainer/Options" to="." method="_on_options_pressed"]
|
||||||
[connection signal="pressed" from="BoxContainer/Exit" to="." method="_on_exit_pressed"]
|
[connection signal="pressed" from="BoxContainer/Exit" to="." method="_on_exit_pressed"]
|
||||||
|
|||||||
@@ -16,7 +16,4 @@ func _process(delta: float) -> void:
|
|||||||
self.position.y += speed*delta
|
self.position.y += speed*delta
|
||||||
|
|
||||||
if self.position.y >= get_viewport_rect().size.y:
|
if self.position.y >= get_viewport_rect().size.y:
|
||||||
scene.health -= damage
|
scene.miss(self)
|
||||||
scene.miss_count += 1.0
|
|
||||||
scene.comets.erase(self)
|
|
||||||
self.queue_free()
|
|
||||||
|
|||||||
@@ -44,7 +44,6 @@ outline_color = Color(0.9529412, 0.16078432, 1, 1)
|
|||||||
script = ExtResource("1_0gpin")
|
script = ExtResource("1_0gpin")
|
||||||
|
|
||||||
[node name="Sprite" type="AnimatedSprite2D" parent="." unique_id=1849187873]
|
[node name="Sprite" type="AnimatedSprite2D" parent="." unique_id=1849187873]
|
||||||
self_modulate = Color(1, 1, 1, 0)
|
|
||||||
position = Vector2(0, -1)
|
position = Vector2(0, -1)
|
||||||
sprite_frames = SubResource("SpriteFrames_ggplc")
|
sprite_frames = SubResource("SpriteFrames_ggplc")
|
||||||
animation = &"comet"
|
animation = &"comet"
|
||||||
|
|||||||
Reference in New Issue
Block a user