added pause menu
This commit is contained in:
@@ -51,6 +51,7 @@ var start_sensitivity
|
||||
|
||||
var gun : Node
|
||||
|
||||
@onready var pause_menu: Control = $Head/Recoil/Camera3D/PauseMenu
|
||||
@onready var gun_ray = $Head/Recoil/Camera3D/GunRay
|
||||
@onready var level_control = get_tree().current_scene
|
||||
@onready var interact_ray = $Head/Recoil/Camera3D/InteractRay
|
||||
@@ -121,15 +122,23 @@ func _ready():
|
||||
AudioServer.set_bus_volume_db(0,-80)
|
||||
|
||||
func _input(event) -> void:
|
||||
if event is InputEventMouseMotion:
|
||||
self.rotate_y(-event.relative.x * SENSITIVITY)
|
||||
head.rotate_x(-event.relative.y * SENSITIVITY)
|
||||
head.rotation.x = clamp(head.rotation.x, deg_to_rad(-90), deg_to_rad(85))
|
||||
mouse_input = event.relative
|
||||
|
||||
if !level_control.paused:
|
||||
if event is InputEventMouseMotion:
|
||||
self.rotate_y(-event.relative.x * SENSITIVITY)
|
||||
head.rotate_x(-event.relative.y * SENSITIVITY)
|
||||
head.rotation.x = clamp(head.rotation.x, deg_to_rad(-90), deg_to_rad(85))
|
||||
mouse_input = event.relative
|
||||
else:
|
||||
if event is InputEventMouseMotion:
|
||||
self.rotate_y(-event.relative.x * .00001)
|
||||
head.rotate_x(-event.relative.y * .00001)
|
||||
head.rotation.x = clamp(head.rotation.x, deg_to_rad(-90), deg_to_rad(85))
|
||||
mouse_input = event.relative
|
||||
|
||||
func _physics_process(delta):
|
||||
|
||||
if !dead:
|
||||
if !dead and !level_control.paused:
|
||||
|
||||
# Add the gravity.
|
||||
if is_on_floor():
|
||||
@@ -219,26 +228,27 @@ func _physics_process(delta):
|
||||
moving_fast = false
|
||||
|
||||
# Game Speed
|
||||
if Input.is_action_pressed("slow_down") and remaining_stamina >0:
|
||||
Engine.time_scale = lerp(0, 1, SLOWSPEED)
|
||||
gun.random_spread_amt = 0
|
||||
AudioServer.set_bus_effect_enabled(0,0,true)
|
||||
camera.fov = lerp(camera.fov, camera.fov * gun.fov_zoom_amt, delta * 100)
|
||||
if sensitivity_shift == true:
|
||||
SENSITIVITY = lerp(SENSITIVITY, SENSITIVITY * .998, delta * 100)
|
||||
if remaining_stamina >0:
|
||||
remaining_stamina -= 1000 * delta
|
||||
else:
|
||||
Engine.time_scale = 1
|
||||
gun.random_spread_amt = gun.random_spread_start
|
||||
AudioServer.set_bus_effect_enabled(0,0,false)
|
||||
if sensitivity_shift == true:
|
||||
camera.fov = lerp(camera.fov, BASE_FOV, delta * .5)
|
||||
SENSITIVITY = start_sensitivity
|
||||
if remaining_stamina < MAX_STAMINA:
|
||||
remaining_stamina += STAMINA_DRAIN * delta
|
||||
elif remaining_stamina > MAX_STAMINA * 1.01:
|
||||
remaining_stamina -= (STAMINA_DRAIN)/2 * delta
|
||||
if !level_control.paused:
|
||||
if Input.is_action_pressed("slow_down") and remaining_stamina >0:
|
||||
Engine.time_scale = lerp(0, 1, SLOWSPEED)
|
||||
gun.random_spread_amt = 0
|
||||
AudioServer.set_bus_effect_enabled(0,0,true)
|
||||
camera.fov = lerp(camera.fov, camera.fov * gun.fov_zoom_amt, delta * 100)
|
||||
if sensitivity_shift == true:
|
||||
SENSITIVITY = lerp(SENSITIVITY, SENSITIVITY * .998, delta * 100)
|
||||
if remaining_stamina >0:
|
||||
remaining_stamina -= 1000 * delta
|
||||
else:
|
||||
Engine.time_scale = 1
|
||||
gun.random_spread_amt = gun.random_spread_start
|
||||
AudioServer.set_bus_effect_enabled(0,0,false)
|
||||
if sensitivity_shift == true:
|
||||
camera.fov = lerp(camera.fov, BASE_FOV, delta * .5)
|
||||
SENSITIVITY = start_sensitivity
|
||||
if remaining_stamina < MAX_STAMINA:
|
||||
remaining_stamina += STAMINA_DRAIN * delta
|
||||
elif remaining_stamina > MAX_STAMINA * 1.01:
|
||||
remaining_stamina -= (STAMINA_DRAIN)/2 * delta
|
||||
|
||||
# Reloading
|
||||
if Input.is_action_just_pressed("reload"):
|
||||
@@ -286,34 +296,20 @@ func _physics_process(delta):
|
||||
|
||||
# Weapon Swap Number 1
|
||||
if Input.is_action_just_pressed("numb_1") and !gun.anim_player.is_playing():
|
||||
var gun_id = 0
|
||||
if level_control.held_guns[gun_id] != null and level_control.current_gun_index != gun_id:
|
||||
gun.anim_player.play("swap_out")
|
||||
level_control.gun_spawn(gun_id)
|
||||
weapon_select(0)
|
||||
|
||||
if Input.is_action_just_pressed("numb_2") and !gun.anim_player.is_playing():
|
||||
var gun_id = 1
|
||||
if level_control.held_guns[gun_id] != null and level_control.current_gun_index != gun_id:
|
||||
gun.anim_player.play("swap_out")
|
||||
level_control.gun_spawn(gun_id)
|
||||
weapon_select(1)
|
||||
|
||||
if Input.is_action_just_pressed("numb_3") and !gun.anim_player.is_playing():
|
||||
var gun_id = 2
|
||||
if level_control.held_guns[gun_id] != null and level_control.current_gun_index != gun_id:
|
||||
gun.anim_player.play("swap_out")
|
||||
level_control.gun_spawn(gun_id)
|
||||
weapon_select(2)
|
||||
|
||||
|
||||
if Input.is_action_just_pressed("numb_4") and !gun.anim_player.is_playing():
|
||||
var gun_id = 3
|
||||
if level_control.held_guns[gun_id] != null and level_control.current_gun_index != gun_id:
|
||||
gun.anim_player.play("swap_out")
|
||||
level_control.gun_spawn(gun_id)
|
||||
weapon_select(3)
|
||||
|
||||
if Input.is_action_just_pressed("numb_5") and !gun.anim_player.is_playing():
|
||||
var gun_id = 4
|
||||
if level_control.held_guns[gun_id] != null and level_control.current_gun_index != gun_id:
|
||||
gun.anim_player.play("swap_out")
|
||||
level_control.gun_spawn(gun_id)
|
||||
weapon_select(4)
|
||||
|
||||
#interact button
|
||||
if Input.is_action_just_pressed("interact"):
|
||||
@@ -330,9 +326,7 @@ func _physics_process(delta):
|
||||
kick_audio.play()
|
||||
interact_ray.get_collider().linear_velocity += transform.basis * Vector3(0,0,-KICK_AMOUNT)
|
||||
|
||||
#quit game and eventually go to menu
|
||||
if Input.is_action_just_pressed("escape"):
|
||||
get_tree().quit()
|
||||
|
||||
|
||||
if level_control.health <= 0:
|
||||
level_control.die()
|
||||
@@ -392,5 +386,7 @@ func weapon_bob(vel : float, delta):
|
||||
weapon_holder.position.y = lerp(weapon_holder.position.y, def_weapon_holder_pos.y, .1 * delta)
|
||||
weapon_holder.position.x = lerp(weapon_holder.position.x, def_weapon_holder_pos.x, .1 * delta)
|
||||
|
||||
func weapon_recoil():
|
||||
pass
|
||||
func weapon_select(gun_id):
|
||||
if level_control.held_guns.size() >= (gun_id + 1) and level_control.current_gun_index != gun_id:
|
||||
gun.anim_player.play("swap_out")
|
||||
level_control.gun_spawn(gun_id)
|
||||
|
||||
Reference in New Issue
Block a user