Added game over screen
This commit is contained in:
@@ -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()
|
||||
|
||||
@@ -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"]
|
||||
|
||||
Reference in New Issue
Block a user