Added game over screen

This commit is contained in:
2026-06-29 21:28:55 +03:00
parent dae6853e4f
commit 4bccabb7ee
18 changed files with 260 additions and 6 deletions
+5 -1
View File
@@ -76,6 +76,11 @@ func _ready() -> void:
func _physics_process(delta: float) -> void:
if position.y > 0.0:
velocity.x = 0.0
move_and_slide()
return
if is_on_floor():
floor_coyote_time_timer.start()
_last_wall_normal = 0.0
@@ -157,4 +162,3 @@ func _attack() -> void:
_slow_down_tween.tween_property(self, "_max_speed", move_max_speed_slowed, slow_down_sustain)
_slow_down_tween.tween_property(self, "_max_speed", move_max_speed_normal, slow_down_release)
_slow_down_tween.tween_property(sprite, "visible", false, 0.0)
+27
View File
@@ -14,9 +14,11 @@ var _corruption_x: float
@onready var player : Player = $Player
@onready var pause_menu : PauseMenu = $%PauseMenu
@onready var game_over_menu : GameOverMenu = $%GameOverMenu
@onready var health_bar : HealthBar = $%HealthBar
@onready var corruption_timer : Timer = $CorruptionTimer
@onready var death_fall_timer : Timer = $DeathFallTimer
@onready var level_material : ShaderMaterial = $%LevelColorRect.material
@@ -24,9 +26,13 @@ var _corruption_x: float
func _ready() -> void:
_corruption_x = initial_corruption_x
pause_menu.hide()
game_over_menu.hide()
health_bar.initialize(player.MAX_HEALTH, player.MAX_HEALTH)
player.health_changed.connect(health_bar.set_current_value)
Input.mouse_mode = Input.MOUSE_MODE_HIDDEN
#TODO Add gameplay music
@@ -44,6 +50,11 @@ func _physics_process(delta: float) -> void:
corruption_timer.start()
else:
corruption_timer.stop()
if player.position.y > 0.0:
if death_fall_timer.is_stopped():
death_fall_timer.start()
SoundManager.play_sfx_stream(SoundManager.sfx_stream_fall, player.global_position)
func _input(event: InputEvent) -> void:
@@ -54,5 +65,21 @@ func _input(event: InputEvent) -> void:
Input.mouse_mode = Input.MOUSE_MODE_VISIBLE
func _show_game_over() -> void:
get_tree().paused = true
game_over_menu.show()
Input.mouse_mode = Input.MOUSE_MODE_VISIBLE
func _on_corruption_timer_timeout() -> void:
player.deal_damage(CORRUPTION_DAMAGE)
SoundManager.play_sfx_stream(SoundManager.sfx_stream_corruption, player.global_position)
func _on_player_dead() -> void:
_show_game_over()
SoundManager.play_sfx_stream(SoundManager.sfx_stream_game_over, player.global_position)
func _on_death_fall_timer_timeout() -> void:
_show_game_over()
+14 -4
View File
@@ -6,6 +6,7 @@
[ext_resource type="Shader" uid="uid://brudtlwas6x66" path="res://game/shaders/glitch.gdshader" id="4_6b8cu"]
[ext_resource type="Texture2D" uid="uid://b8rm1kxgci4l1" path="res://images/level/beams.png" id="4_pi5fd"]
[ext_resource type="PackedScene" uid="uid://b1x0tmnf7hx7h" path="res://game/hud/health_bar.tscn" id="6_x8k35"]
[ext_resource type="PackedScene" uid="uid://cl7vqh8j2f5py" path="res://game/menu/game_over_menu.tscn" id="7_l0xih"]
[sub_resource type="TileSetAtlasSource" id="TileSetAtlasSource_6b8cu"]
resource_name = "Beams"
@@ -1193,14 +1194,23 @@ material = SubResource("ShaderMaterial_yeikn")
offset_right = 640.0
offset_bottom = 360.0
[node name="PauseMenu" parent="CanvasLayer" unique_id=1815975678 instance=ExtResource("3_fnnmn")]
unique_name_in_owner = true
process_mode = 2
[node name="HealthBar" parent="CanvasLayer" unique_id=256637218 instance=ExtResource("6_x8k35")]
unique_name_in_owner = true
position = Vector2(51, 19)
[node name="PauseMenu" parent="CanvasLayer" unique_id=1815975678 instance=ExtResource("3_fnnmn")]
unique_name_in_owner = true
process_mode = 2
[node name="GameOverMenu" parent="CanvasLayer" unique_id=795145041 instance=ExtResource("7_l0xih")]
unique_name_in_owner = true
process_mode = 2
[node name="CorruptionTimer" type="Timer" parent="." unique_id=783383429]
[node name="DeathFallTimer" type="Timer" parent="." unique_id=519159888]
one_shot = true
[connection signal="dead" from="Player" to="." method="_on_player_dead"]
[connection signal="timeout" from="CorruptionTimer" to="." method="_on_corruption_timer_timeout"]
[connection signal="timeout" from="DeathFallTimer" to="." method="_on_death_fall_timer_timeout"]
+3
View File
@@ -24,6 +24,9 @@ const MUSIC_BUS = "Music"
@export var ui_stream_select : AudioStream
@export_group("SFX Streams", "sfx_stream")
@export var sfx_stream_corruption : AudioStream
@export var sfx_stream_fall : AudioStream
@export var sfx_stream_game_over : AudioStream
@export var sfx_stream_jump : AudioStream
@export var sfx_stream_land : AudioStream
@export var sfx_stream_swing : AudioStream
+6
View File
@@ -4,8 +4,11 @@
[ext_resource type="AudioStream" uid="uid://cwmibbhy2fpq2" path="res://sound/ui/accept.wav" id="2_ge1il"]
[ext_resource type="AudioStream" uid="uid://d2tsomsqmhf0h" path="res://sound/ui/decline.wav" id="3_agyxs"]
[ext_resource type="AudioStream" uid="uid://cfb2adf5hft7b" path="res://sound/ui/select.wav" id="4_0i6kl"]
[ext_resource type="AudioStream" uid="uid://dg38c1dh27a80" path="res://sound/sfx/corruption.wav" id="5_ab171"]
[ext_resource type="AudioStream" uid="uid://bcc0textvn2lx" path="res://sound/sfx/jump.wav" id="5_fpnh3"]
[ext_resource type="AudioStream" uid="uid://b6q00ggpln0k5" path="res://sound/sfx/game_over.wav" id="6_6ll5c"]
[ext_resource type="AudioStream" uid="uid://b6xkhskx5gi0w" path="res://sound/sfx/land.wav" id="6_22ptj"]
[ext_resource type="AudioStream" uid="uid://ellnbrkpn47a" path="res://sound/sfx/fall.wav" id="6_q7cyi"]
[ext_resource type="AudioStream" uid="uid://bj6ausg5hyuyg" path="res://sound/sfx/swing.wav" id="7_ab171"]
[ext_resource type="AudioStream" uid="uid://33unutlwsika" path="res://sound/sfx/wall_jump.wav" id="8_22ptj"]
@@ -21,6 +24,9 @@ player_count_sfx = 32
ui_stream_accept = ExtResource("2_ge1il")
ui_stream_decline = ExtResource("3_agyxs")
ui_stream_select = ExtResource("4_0i6kl")
sfx_stream_corruption = ExtResource("5_ab171")
sfx_stream_fall = ExtResource("6_q7cyi")
sfx_stream_game_over = ExtResource("6_6ll5c")
sfx_stream_jump = ExtResource("5_fpnh3")
sfx_stream_land = ExtResource("6_22ptj")
sfx_stream_swing = ExtResource("7_ab171")
+37
View File
@@ -0,0 +1,37 @@
class_name GameOverMenu
extends Control
@onready var retry_button : Button = $%RetryButton
@onready var main_menu_button : Button = $%MainMenuButton
@onready var focus_timer : Timer = $FocusTimer
func _on_gui_focus_changed(_node: Control) -> void:
SoundManager.play_ui_stream(SoundManager.ui_stream_select)
func _on_retry_button_pressed() -> void:
SoundManager.play_ui_stream(SoundManager.ui_stream_accept)
get_tree().paused = false
get_tree().change_scene_to_file(get_tree().current_scene.scene_file_path)
func _on_main_menu_button_pressed() -> void:
SoundManager.play_ui_stream(SoundManager.ui_stream_accept)
get_tree().paused = false
get_tree().change_scene_to_file("res://game/menu/main_menu.tscn")
func _on_visibility_changed() -> void:
if not is_node_ready(): return
if visible:
focus_timer.start()
get_viewport().gui_focus_changed.connect(_on_gui_focus_changed)
elif get_viewport().gui_focus_changed.is_connected(_on_gui_focus_changed):
get_viewport().gui_focus_changed.disconnect(_on_gui_focus_changed)
func _on_focus_timer_timeout() -> void:
if main_menu_button != null:
retry_button.grab_focus()
+1
View File
@@ -0,0 +1 @@
uid://coqb1xl7lngo5
+58
View File
@@ -0,0 +1,58 @@
[gd_scene format=3 uid="uid://cl7vqh8j2f5py"]
[ext_resource type="Theme" uid="uid://bqj884yfvhhft" path="res://game/themes/main_menu.tres" id="1_htxfh"]
[ext_resource type="Script" uid="uid://coqb1xl7lngo5" path="res://game/menu/game_over_menu.gd" id="2_m1ad0"]
[node name="GameOverMenu" type="Control" unique_id=795145041]
layout_mode = 3
anchors_preset = 15
anchor_right = 1.0
anchor_bottom = 1.0
grow_horizontal = 2
grow_vertical = 2
theme = ExtResource("1_htxfh")
script = ExtResource("2_m1ad0")
[node name="ColorRect" type="ColorRect" parent="." unique_id=851679792]
layout_mode = 1
anchors_preset = 15
anchor_right = 1.0
anchor_bottom = 1.0
grow_horizontal = 2
grow_vertical = 2
color = Color(0.19607843, 0.19215687, 0.23137255, 1)
[node name="MarginContainer" type="MarginContainer" parent="." unique_id=1675617760]
layout_mode = 1
anchors_preset = 15
anchor_right = 1.0
anchor_bottom = 1.0
grow_horizontal = 2
grow_vertical = 2
[node name="VBoxContainer" type="VBoxContainer" parent="MarginContainer" unique_id=1046629699]
layout_mode = 2
alignment = 1
[node name="Label" type="Label" parent="MarginContainer/VBoxContainer" unique_id=641992920]
layout_mode = 2
text = "GAME OVER"
horizontal_alignment = 1
[node name="RetryButton" type="Button" parent="MarginContainer/VBoxContainer" unique_id=538467341]
unique_name_in_owner = true
layout_mode = 2
text = "RETRY"
[node name="MainMenuButton" type="Button" parent="MarginContainer/VBoxContainer" unique_id=1995734325]
unique_name_in_owner = true
layout_mode = 2
text = "MAIN MENU"
[node name="FocusTimer" type="Timer" parent="." unique_id=1727491464]
one_shot = true
[connection signal="visibility_changed" from="." to="." method="_on_visibility_changed"]
[connection signal="pressed" from="MarginContainer/VBoxContainer/RetryButton" to="." method="_on_retry_button_pressed"]
[connection signal="pressed" from="MarginContainer/VBoxContainer/MainMenuButton" to="." method="_on_main_menu_button_pressed"]
[connection signal="timeout" from="FocusTimer" to="." method="_on_focus_timer_timeout"]
+9 -1
View File
@@ -14,6 +14,15 @@ grow_vertical = 2
theme = ExtResource("1_5d27k")
script = ExtResource("2_qnvmd")
[node name="ColorRect" type="ColorRect" parent="." unique_id=669952833]
layout_mode = 1
anchors_preset = 15
anchor_right = 1.0
anchor_bottom = 1.0
grow_horizontal = 2
grow_vertical = 2
color = Color(0.19607843, 0.19215687, 0.23137255, 1)
[node name="MarginContainer" type="MarginContainer" parent="." unique_id=1180781679]
layout_mode = 1
anchors_preset = 15
@@ -24,7 +33,6 @@ grow_vertical = 2
[node name="VBoxContainer" type="VBoxContainer" parent="MarginContainer" unique_id=736037128]
layout_mode = 2
size_flags_horizontal = 4
alignment = 1
[node name="StartButton" type="Button" parent="MarginContainer/VBoxContainer" unique_id=1504018605]
+10
View File
@@ -19,6 +19,15 @@ grow_vertical = 2
theme = ExtResource("1_e2bp2")
script = ExtResource("1_lq2ks")
[node name="ColorRect" type="ColorRect" parent="." unique_id=1883678162]
layout_mode = 1
anchors_preset = 15
anchor_right = 1.0
anchor_bottom = 1.0
grow_horizontal = 2
grow_vertical = 2
color = Color(0.19607843, 0.19215687, 0.23137255, 1)
[node name="MarginContainer" type="MarginContainer" parent="." unique_id=2127037660]
layout_mode = 1
anchors_preset = 15
@@ -138,6 +147,7 @@ alignment = 1
[node name="BackButton" type="Button" parent="MarginContainer/VBoxContainer/HBoxContainer" unique_id=131108983]
unique_name_in_owner = true
layout_mode = 2
size_flags_horizontal = 3
shortcut = SubResource("Shortcut_e2bp2")
text = "BACK"
+9
View File
@@ -13,6 +13,15 @@ grow_vertical = 2
theme = ExtResource("1_i4rg2")
script = ExtResource("2_e1jsn")
[node name="ColorRect" type="ColorRect" parent="." unique_id=1984802285]
layout_mode = 1
anchors_preset = 15
anchor_right = 1.0
anchor_bottom = 1.0
grow_horizontal = 2
grow_vertical = 2
color = Color(0.19607843, 0.19215687, 0.23137255, 1)
[node name="MarginContainer" type="MarginContainer" parent="." unique_id=2013458760]
layout_mode = 1
anchors_preset = 15
Binary file not shown.
+24
View File
@@ -0,0 +1,24 @@
[remap]
importer="wav"
type="AudioStreamWAV"
uid="uid://dg38c1dh27a80"
path="res://.godot/imported/corruption.wav-cb6aa0ed749327181f5011fc7985178f.sample"
[deps]
source_file="res://sound/sfx/corruption.wav"
dest_files=["res://.godot/imported/corruption.wav-cb6aa0ed749327181f5011fc7985178f.sample"]
[params]
force/8_bit=false
force/mono=false
force/max_rate=false
force/max_rate_hz=44100
edit/trim=false
edit/normalize=false
edit/loop_mode=0
edit/loop_begin=0
edit/loop_end=-1
compress/mode=2
BIN
View File
Binary file not shown.
BIN
View File
Binary file not shown.
+24
View File
@@ -0,0 +1,24 @@
[remap]
importer="wav"
type="AudioStreamWAV"
uid="uid://ellnbrkpn47a"
path="res://.godot/imported/fall.wav-42d30ae4f15f539d7b6bbe2536aff44d.sample"
[deps]
source_file="res://sound/sfx/fall.wav"
dest_files=["res://.godot/imported/fall.wav-42d30ae4f15f539d7b6bbe2536aff44d.sample"]
[params]
force/8_bit=false
force/mono=false
force/max_rate=false
force/max_rate_hz=44100
edit/trim=false
edit/normalize=false
edit/loop_mode=0
edit/loop_begin=0
edit/loop_end=-1
compress/mode=2
BIN
View File
Binary file not shown.
+24
View File
@@ -0,0 +1,24 @@
[remap]
importer="wav"
type="AudioStreamWAV"
uid="uid://b6q00ggpln0k5"
path="res://.godot/imported/game_over.wav-b6e22464a799bf25d91835b339e8f159.sample"
[deps]
source_file="res://sound/sfx/game_over.wav"
dest_files=["res://.godot/imported/game_over.wav-b6e22464a799bf25d91835b339e8f159.sample"]
[params]
force/8_bit=false
force/mono=false
force/max_rate=false
force/max_rate_hz=44100
edit/trim=false
edit/normalize=false
edit/loop_mode=0
edit/loop_begin=0
edit/loop_end=-1
compress/mode=2