Moved is_paused from player to GlobalSettings so that other game functions knows when it's paused

This commit is contained in:
2024-08-15 02:02:09 -05:00
parent 939399e2da
commit bcd7a629a2
3 changed files with 8 additions and 8 deletions

View File

@ -19,8 +19,10 @@ func pause_game_button():
$"Pause Menu".hide() $"Pause Menu".hide()
hide() hide()
Input.mouse_mode = Input.MOUSE_MODE_CAPTURED Input.mouse_mode = Input.MOUSE_MODE_CAPTURED
GlobalSettings.is_paused = false
emit_signal("unpaused") emit_signal("unpaused")
else: else:
GlobalSettings.is_paused = true
show() show()
$"Pause Menu".show() $"Pause Menu".show()
Input.mouse_mode = Input.MOUSE_MODE_VISIBLE Input.mouse_mode = Input.MOUSE_MODE_VISIBLE

View File

@ -1,11 +1,11 @@
extends Node3D extends Node3D
func _on_pause_menu_paused(): func _on_pause_menu_paused():
$"player".is_paused = true GlobalSettings.is_paused = true
func _on_pause_menu_unpaused(): func _on_pause_menu_unpaused():
$"player".is_paused = false GlobalSettings.is_paused = false
func GameOver(): func GameOver():
$"Game Over".show() $"Game Over".show()
$player.is_paused = true GlobalSettings.is_paused = true

View File

@ -21,13 +21,11 @@ var vapes_per_min = 0
var mouse_sensitivity = 0.02 var mouse_sensitivity = 0.02
var joystick_sensitity = 2 var joystick_sensitity = 2
var is_paused = false
# Get the gravity from the project settings to be synced with RigidBody nodes. # Get the gravity from the project settings to be synced with RigidBody nodes.
var gravity = ProjectSettings.get_setting("physics/3d/default_gravity") var gravity = ProjectSettings.get_setting("physics/3d/default_gravity")
func _physics_process(delta): func _physics_process(delta):
if not is_paused: if not GlobalSettings.is_paused:
# Add the gravity. # Add the gravity.
if not is_on_floor(): if not is_on_floor():
velocity.y -= gravity * delta velocity.y -= gravity * delta
@ -60,7 +58,7 @@ func _process(delta):
if vapes_per_min == randi_range(10,20): if vapes_per_min == randi_range(10,20):
will_cough = true will_cough = true
vapes_per_min = 0 vapes_per_min = 0
if is_paused: if GlobalSettings.is_paused:
$Head/Crosshair.hide() $Head/Crosshair.hide()
$Head/RayCast3D/Prompt.hide() $Head/RayCast3D/Prompt.hide()
elif not $Head/Crosshair.visible: elif not $Head/Crosshair.visible:
@ -70,7 +68,7 @@ func _process(delta):
func _input(event): func _input(event):
if event.is_action("ui_text_backspace"): if event.is_action("ui_text_backspace"):
respawn() respawn()
if not is_paused: if not GlobalSettings.is_paused:
if event is InputEventMouseMotion: if event is InputEventMouseMotion:
rotate_y(-event.relative.x * (GlobalSettings.GetSetting(GlobalSettings.Setting.Mouse_Speed)) / 100) rotate_y(-event.relative.x * (GlobalSettings.GetSetting(GlobalSettings.Setting.Mouse_Speed)) / 100)