CHALLENGE 2: A Real Game Over Screen ==================================================================== TASK ---- Extend main.gd's _on_player_died so that, instead of only printing "Game over," it also shows a Control-based "Game Over" screen (built the same way as the PauseMenu) with the final score displayed on a Label. SETUP ----- Add a GameOverScreen (Control) under HUD, hidden by default, with a child Label named "FinalScoreLabel". Anchor it to "Full Rect" or "Center" via the Layout menu, matching the PauseMenu's own setup. SCENE ADDITION --------------- HUD (CanvasLayer) |-- HealthBar (ProgressBar) |-- ScoreLabel (Label) |-- PauseMenu (Control, hidden) |-- GameOverScreen (Control, hidden) |-- FinalScoreLabel (Label) SOLUTION CODE - game_over_screen.gd (attached to GameOverScreen) ------------------------------------------------------------------------ extends Control func _ready() -> void: hide() func show_game_over(final_score: int) -> void: $FinalScoreLabel.text = "Game Over - Final Score: " + str(final_score) show() SOLUTION CODE - the updated part of main.gd ------------------------------------------------ func _on_player_died() -> void: print("Game over") $HUD/GameOverScreen.show_game_over(score) get_tree().paused = true WHY THIS WORKS AS AN ANSWER ---------------------------- GameOverScreen starts hidden in its own _ready(), exactly like PauseMenu (Chapter 8) - the same hide()-by-default pattern reused for a second, unrelated Control node. show_game_over(final_score) is a small public function on the GameOverScreen itself, rather than main.gd reaching directly into its Label with a hardcoded path - main.gd only needs to know GameOverScreen has a show_game_over() method that takes a score, not how that screen is internally structured. This mirrors the capstone's own "main.gd wires things together, but each piece stays independently responsible for itself" principle: GameOverScreen owns its own FinalScoreLabel and the exact wording of its own message. Passing score (main.gd's own running total, already updated by every _on_coin_collected() call) directly into show_game_over() means the final score displayed is guaranteed to be accurate at the exact moment the player dies, with no separate score-tracking logic duplicated inside GameOverScreen itself.