diff --git a/global.gd b/global.gd index 1098ce3..b70bcc1 100644 --- a/global.gd +++ b/global.gd @@ -33,10 +33,15 @@ func _process(delta): if(Input.is_action_just_pressed("pause")): if(Main.pauseMenu.isOpen): Main.pauseMenu.close() - + if(Global.gameState == Global.GameStates.FINISHED): + Main.gameOver.show() else: + if(Global.gameState == Global.GameStates.FINISHED): + Main.gameOver.hide() Main.pauseMenu.open() Main.toggle_pause(Main.pauseMenu.isOpen) + + func start_game(): gameState = GameStates.RUNNING @@ -46,6 +51,8 @@ func start_game(): func finish_game(): gameState = GameStates.FINISHED + Main.finalTime.text = formattedTime + Main.gameOver.show() func init_music(): musicNode = AudioStreamPlayer.new() diff --git a/scenes/World.gd b/scenes/World.gd index 643e428..8ccb8da 100644 --- a/scenes/World.gd +++ b/scenes/World.gd @@ -7,6 +7,8 @@ extends Node3D @onready var music: AudioStreamPlayer = $Music @onready var pauseMenu: Control = $pause_menu @onready var timer: RichTextLabel = $UI/Timer +@onready var finalTime: Label = $"UI/Game Over/VBoxContainer/Time" +@onready var gameOver: CenterContainer = $"UI/Game Over" var target_rot: float = 0.0 @export_range(1, 10) var snappiness: float = 1.0 @export_range(2, 20) var rotation_speed: float = 10 diff --git a/scenes/main.tscn b/scenes/main.tscn index 855958d..cbfdca8 100644 --- a/scenes/main.tscn +++ b/scenes/main.tscn @@ -493,5 +493,26 @@ fit_content = true scroll_active = false autowrap_mode = 0 +[node name="Game Over" type="CenterContainer" parent="UI"] +visible = false +anchors_preset = 15 +anchor_right = 1.0 +anchor_bottom = 1.0 +grow_horizontal = 2 +grow_vertical = 2 + +[node name="VBoxContainer" type="VBoxContainer" parent="UI/Game Over"] +layout_mode = 2 + +[node name="Game Over" type="Label" parent="UI/Game Over/VBoxContainer"] +layout_mode = 2 +theme_override_font_sizes/font_size = 72 +text = "Game Over!" + +[node name="Time" type="Label" parent="UI/Game Over/VBoxContainer"] +layout_mode = 2 +text = "Time 00:00:000" +horizontal_alignment = 1 + [connection signal="body_entered" from="NPC" to="NPC" method="_on_body_entered"] [connection signal="resume" from="pause_menu" to="." method="_on_pause_menu_resume"]