added pause menu
This commit is contained in:
@@ -21,6 +21,7 @@ var dead_player = preload("res://assets/dead_cam.tscn")
|
||||
const CLEARED_ANNOUNCE = preload("res://assets/cleared_announce.tscn")
|
||||
const DEAD_ANNOUNCE = preload("res://assets/dead_announce.tscn")
|
||||
|
||||
var paused = false
|
||||
var health = start_health
|
||||
var pickups = []
|
||||
var held_guns = []
|
||||
@@ -86,7 +87,9 @@ func _ready():
|
||||
|
||||
# Called every frame. 'delta' is the elapsed time since the previous frame.
|
||||
func _process(_delta):
|
||||
pass
|
||||
#quit game and eventually go to menu
|
||||
if Input.is_action_just_pressed("escape"):
|
||||
pause_menu()
|
||||
|
||||
|
||||
|
||||
@@ -151,3 +154,20 @@ func pickup_spawn():
|
||||
#var item_name = item_type[1][0]
|
||||
item_spawn.rand_amt = randi_range(25,100)
|
||||
return item_spawn
|
||||
|
||||
func pause_menu():
|
||||
if paused:
|
||||
Engine.time_scale = 1
|
||||
Input.set_mouse_mode(Input.MOUSE_MODE_CAPTURED)
|
||||
player.crosshair.visible = true
|
||||
player.pause_menu.hide()
|
||||
else:
|
||||
Engine.time_scale = 0
|
||||
Input.set_mouse_mode(Input.MOUSE_MODE_VISIBLE)
|
||||
player.crosshair.visible = false
|
||||
player.pause_menu.show()
|
||||
|
||||
paused = !paused
|
||||
|
||||
func save_quit():
|
||||
get_tree().quit()
|
||||
|
||||
@@ -39,17 +39,16 @@ func _on_body_entered(body: Node) -> void:
|
||||
|
||||
if !body.is_in_group("player"):
|
||||
print("BODY HIT - " + str(body))
|
||||
#Break Breakable Objects
|
||||
|
||||
#Break Breakable Objects
|
||||
if body.is_in_group("breakable"):
|
||||
body.breaking(linear_velocity)
|
||||
|
||||
if body.is_in_group("switch"):
|
||||
body.hit()
|
||||
|
||||
|
||||
|
||||
mesh.visible = false
|
||||
|
||||
|
||||
if ray.is_colliding() and !ray.get_collider().is_in_group("player"):
|
||||
#Bullet Hole Effect
|
||||
ray.get_collider().add_child(instance_bullethole)
|
||||
@@ -64,8 +63,5 @@ func _on_body_entered(body: Node) -> void:
|
||||
hit_indicator.play()
|
||||
enemy_particles.emitting = true
|
||||
ray.get_collider().hit(bullet_damage)
|
||||
|
||||
|
||||
#Switch Switches
|
||||
|
||||
|
||||
queue_free()
|
||||
|
||||
@@ -78,9 +78,6 @@ func _process(delta):
|
||||
camera.fov = lerp(camera.fov, respawn_fov, delta * 10)
|
||||
if global_position.distance_to(respawn_position) <= .5:
|
||||
animation_player.play("whiteout")
|
||||
|
||||
if Input.is_action_just_pressed("escape"):
|
||||
get_tree().quit()
|
||||
|
||||
|
||||
func _on_timer_timeout():
|
||||
|
||||
@@ -11,6 +11,7 @@ var taunts = ["hows your gut now you big cup of dumdum juice?",
|
||||
"hee hee",
|
||||
"stop trying",
|
||||
"you got hit with my bullet",
|
||||
"try dodging it next time",
|
||||
"yowza!"]
|
||||
|
||||
# Called when the node enters the scene tree for the first time.
|
||||
|
||||
20
scripts/pause_menu.gd
Normal file
20
scripts/pause_menu.gd
Normal file
@@ -0,0 +1,20 @@
|
||||
extends Control
|
||||
|
||||
@onready var level_control = get_tree().current_scene
|
||||
|
||||
# Called when the node enters the scene tree for the first time.
|
||||
func _ready() -> void:
|
||||
visible = false
|
||||
|
||||
|
||||
# Called every frame. 'delta' is the elapsed time since the previous frame.
|
||||
func _process(delta: float) -> void:
|
||||
pass
|
||||
|
||||
|
||||
func _on_resume_pressed() -> void:
|
||||
level_control.pause_menu()
|
||||
|
||||
|
||||
func _on_save__quit_pressed() -> void:
|
||||
level_control.save_quit()
|
||||
@@ -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