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()
|
||||
|
||||
Reference in New Issue
Block a user