Skip to content

Commit

Permalink
feat: Game Over screen
Browse files Browse the repository at this point in the history
  • Loading branch information
FLuplow committed Jul 9, 2023
1 parent 2208b67 commit 5aa0ff2
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 1 deletion.
9 changes: 8 additions & 1 deletion global.gd
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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()
Expand Down
2 changes: 2 additions & 0 deletions scenes/World.gd
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
21 changes: 21 additions & 0 deletions scenes/main.tscn
Original file line number Diff line number Diff line change
Expand Up @@ -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"]

0 comments on commit 5aa0ff2

Please sign in to comment.