From 0b3f46ae0fcf56b9a4aa37322c9e781f7c4e8ec8 Mon Sep 17 00:00:00 2001 From: derek Date: Wed, 30 Oct 2024 15:52:02 -0500 Subject: [PATCH] added pause menu --- assets/blockout_2.tscn | 156 ++++++++++++++++++++++++++++++++++++- assets/bullet.tscn | 10 +-- assets/player.tscn | 9 ++- assets/revolver_1.tscn | 2 +- levels/switch_target.gd | 9 --- levels/switchcontroller.gd | 13 +++- pause_menu.gdshader | 14 ++++ pause_menu.tscn | 105 +++++++++++++++++++++++++ scripts/LevelManager.gd | 22 +++++- scripts/bullet.gd | 12 +-- scripts/dead_cam.gd | 3 - scripts/enemy_taunt.gd | 1 + scripts/pause_menu.gd | 20 +++++ scripts/player.gd | 98 +++++++++++------------ 14 files changed, 391 insertions(+), 83 deletions(-) create mode 100644 pause_menu.gdshader create mode 100644 pause_menu.tscn create mode 100644 scripts/pause_menu.gd diff --git a/assets/blockout_2.tscn b/assets/blockout_2.tscn index 5ebdc66..e466211 100644 --- a/assets/blockout_2.tscn +++ b/assets/blockout_2.tscn @@ -1,4 +1,4 @@ -[gd_scene load_steps=68 format=4 uid="uid://6agmt1hqlhww"] +[gd_scene load_steps=84 format=4 uid="uid://6agmt1hqlhww"] [ext_resource type="Script" path="res://scripts/LevelManager.gd" id="1_sbpvn"] [ext_resource type="PackedScene" uid="uid://brl0bsqjl5dg3" path="res://assets/mac_10.tscn" id="2_fn4vb"] @@ -31,6 +31,10 @@ [ext_resource type="Texture2D" uid="uid://bervxllx4mjqe" path="res://assets/Textures/dickbutt.png" id="22_i7w8i"] [ext_resource type="PackedScene" uid="uid://c7vrpfdh603kr" path="res://assets/bottle_1.tscn" id="23_khhfu"] [ext_resource type="PackedScene" uid="uid://dvlpc0mrx16l" path="res://assets/table1.tscn" id="24_eaw7j"] +[ext_resource type="Script" path="res://levels/switchcontroller.gd" id="32_dncpy"] +[ext_resource type="Script" path="res://scripts/switch_door.gd" id="33_1m5er"] +[ext_resource type="Script" path="res://scripts/switch_interactandshoot.gd" id="35_ybetb"] +[ext_resource type="Script" path="res://levels/switch_target.gd" id="36_fuepo"] [sub_resource type="ProceduralSkyMaterial" id="ProceduralSkyMaterial_eiud5"] sky_horizon_color = Color(0.64625, 0.65575, 0.67075, 1) @@ -635,6 +639,114 @@ _surfaces = [{ blend_shape_mode = 0 shadow_mesh = SubResource("ArrayMesh_02xub") +[sub_resource type="BoxMesh" id="BoxMesh_iy4xk"] +size = Vector3(11.605, 4.25, 0.61) + +[sub_resource type="BoxShape3D" id="BoxShape3D_uer68"] +size = Vector3(9.26855, 4.28711, 0.640869) + +[sub_resource type="Animation" id="Animation_d2bci"] +resource_name = "open" +tracks/0/type = "value" +tracks/0/imported = false +tracks/0/enabled = true +tracks/0/path = NodePath(".:position") +tracks/0/interp = 2 +tracks/0/loop_wrap = true +tracks/0/keys = { +"times": PackedFloat32Array(0, 1), +"transitions": PackedFloat32Array(1, 1), +"update": 0, +"values": [Vector3(0, 28.5934, 14.0814), Vector3(0, 32.6882, 14.0814)] +} + +[sub_resource type="Animation" id="Animation_0aerp"] +length = 0.001 +tracks/0/type = "value" +tracks/0/imported = false +tracks/0/enabled = true +tracks/0/path = NodePath(".:position") +tracks/0/interp = 1 +tracks/0/loop_wrap = true +tracks/0/keys = { +"times": PackedFloat32Array(0), +"transitions": PackedFloat32Array(1), +"update": 0, +"values": [Vector3(0, 28.5934, 14.0814)] +} + +[sub_resource type="Animation" id="Animation_iqxx0"] +resource_name = "close" +tracks/0/type = "value" +tracks/0/imported = false +tracks/0/enabled = true +tracks/0/path = NodePath(".:position") +tracks/0/interp = 2 +tracks/0/loop_wrap = true +tracks/0/keys = { +"times": PackedFloat32Array(0, 1), +"transitions": PackedFloat32Array(1, 1), +"update": 0, +"values": [Vector3(0, 32.6882, 14.0814), Vector3(0, 28.5934, 14.0814)] +} + +[sub_resource type="AnimationLibrary" id="AnimationLibrary_m24x1"] +_data = { +"RESET": SubResource("Animation_0aerp"), +"close": SubResource("Animation_iqxx0"), +"open": SubResource("Animation_d2bci") +} + +[sub_resource type="StandardMaterial3D" id="StandardMaterial3D_mpvpj"] +albedo_color = Color(0, 0, 0, 1) +emission_enabled = true +emission = Color(1, 0, 0, 1) +emission_energy_multiplier = 5.0 + +[sub_resource type="SphereMesh" id="SphereMesh_wh8x7"] +material = SubResource("StandardMaterial3D_mpvpj") + +[sub_resource type="SphereShape3D" id="SphereShape3D_w8su1"] +radius = 0.505049 + +[sub_resource type="Animation" id="Animation_vx7i8"] +length = 0.001 +tracks/0/type = "value" +tracks/0/imported = false +tracks/0/enabled = true +tracks/0/path = NodePath(".:position") +tracks/0/interp = 1 +tracks/0/loop_wrap = true +tracks/0/keys = { +"times": PackedFloat32Array(0), +"transitions": PackedFloat32Array(1), +"update": 0, +"values": [Vector3(16.9397, 33.7018, 12.3882)] +} + +[sub_resource type="Animation" id="Animation_xdrt1"] +resource_name = "movingswitch" +length = 2.0 +loop_mode = 1 +tracks/0/type = "value" +tracks/0/imported = false +tracks/0/enabled = true +tracks/0/path = NodePath(".:position") +tracks/0/interp = 1 +tracks/0/loop_wrap = true +tracks/0/keys = { +"times": PackedFloat32Array(0, 0.5, 1, 1.5, 2), +"transitions": PackedFloat32Array(1, 1, 1, 1, 1), +"update": 0, +"values": [Vector3(16.9397, 33.7018, 12.3882), Vector3(16.9397, 33.7018, -21.8538), Vector3(-16.8287, 33.7018, -21.8538), Vector3(-16.8287, 33.7018, 11.5906), Vector3(16.9397, 33.7018, 12.3882)] +} + +[sub_resource type="AnimationLibrary" id="AnimationLibrary_vwmy0"] +_data = { +"RESET": SubResource("Animation_vx7i8"), +"movingswitch": SubResource("Animation_xdrt1") +} + [node name="BLOCKOUT2Test" type="Node3D" node_paths=PackedStringArray("player")] transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0.016016, 0.0225029, -0.0192337) script = ExtResource("1_sbpvn") @@ -1592,3 +1704,45 @@ transform = Transform3D(-0.846676, 0, -0.532108, 0, 1, 0, 0.532108, 0, -0.846676 transform = Transform3D(0.015, -7.86969e-07, 2.74274e-07, 7.86945e-07, 0.015, 1.33284e-06, -2.74274e-07, -1.33283e-06, 0.015, -92.901, 0, 147.822) mesh = SubResource("ArrayMesh_dt3jf") skeleton = NodePath("") + +[node name="Switch 1" type="Node" parent="." node_paths=PackedStringArray("door")] +script = ExtResource("32_dncpy") +door = NodePath("Door1") + +[node name="Door1" type="MeshInstance3D" parent="Switch 1" node_paths=PackedStringArray("anim_player")] +transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 28.5934, 14.0814) +mesh = SubResource("BoxMesh_iy4xk") +skeleton = NodePath("") +script = ExtResource("33_1m5er") +anim_player = NodePath("AnimationPlayer") + +[node name="StaticBody3D" type="StaticBody3D" parent="Switch 1/Door1"] + +[node name="CollisionShape3D" type="CollisionShape3D" parent="Switch 1/Door1/StaticBody3D"] +shape = SubResource("BoxShape3D_uer68") + +[node name="AnimationPlayer" type="AnimationPlayer" parent="Switch 1/Door1"] +libraries = { +"": SubResource("AnimationLibrary_m24x1") +} + +[node name="switch" type="MeshInstance3D" parent="Switch 1" groups=["interact", "switch"]] +transform = Transform3D(1.655, 0, 0, 0, 1.655, 0, 0, 0, 1.655, 16.9397, 33.7018, 12.3882) +mesh = SubResource("SphereMesh_wh8x7") +skeleton = NodePath("../..") +script = ExtResource("35_ybetb") + +[node name="StaticBody3D" type="StaticBody3D" parent="Switch 1/switch" groups=["interact", "switch"]] +collision_layer = 3 +script = ExtResource("36_fuepo") + +[node name="CollisionShape3D" type="CollisionShape3D" parent="Switch 1/switch/StaticBody3D"] +shape = SubResource("SphereShape3D_w8su1") + +[node name="AnimationPlayer" type="AnimationPlayer" parent="Switch 1/switch"] +libraries = { +"": SubResource("AnimationLibrary_vwmy0") +} +autoplay = "movingswitch" + +[connection signal="switch_hit" from="Switch 1/switch/StaticBody3D" to="Switch 1/switch" method="_on_static_body_3d_switch_hit"] diff --git a/assets/bullet.tscn b/assets/bullet.tscn index 567da7a..0a6efe6 100644 --- a/assets/bullet.tscn +++ b/assets/bullet.tscn @@ -49,10 +49,10 @@ blend_shape_mode = 0 shadow_mesh = SubResource("ArrayMesh_dtlcm") [sub_resource type="StandardMaterial3D" id="StandardMaterial3D_x6v7s"] -albedo_color = Color(0.26779, 0.26779, 0.26779, 1) metallic = 1.0 -emission = Color(0.944624, 0.755365, 0, 1) -emission_energy_multiplier = 8.0 +emission_enabled = true +emission = Color(1, 0.607843, 0.364706, 1) +emission_energy_multiplier = 4.0 [sub_resource type="ParticleProcessMaterial" id="ParticleProcessMaterial_3wvag"] direction = Vector3(0, 0, 1) @@ -60,7 +60,7 @@ initial_velocity_min = 3.0 initial_velocity_max = 5.0 [sub_resource type="BoxMesh" id="BoxMesh_qy3jk"] -size = Vector3(0.05, 0.05, 0.05) +size = Vector3(0.025, 0.025, 0.025) [sub_resource type="StandardMaterial3D" id="StandardMaterial3D_ywt21"] transparency = 1 @@ -79,7 +79,7 @@ radius = 0.055 [node name="Bullet" type="RigidBody3D"] top_level = true -collision_layer = 32 +collision_layer = 0 collision_mask = 109 axis_lock_angular_x = true axis_lock_angular_y = true diff --git a/assets/player.tscn b/assets/player.tscn index 0c49345..ceaa718 100644 --- a/assets/player.tscn +++ b/assets/player.tscn @@ -1,4 +1,4 @@ -[gd_scene load_steps=24 format=3 uid="uid://drwae3loscbw7"] +[gd_scene load_steps=25 format=3 uid="uid://drwae3loscbw7"] [ext_resource type="Script" path="res://scripts/player.gd" id="1_x7wms"] [ext_resource type="PackedScene" uid="uid://dcmno6wafk5hg" path="res://assets/dead_player.tscn" id="2_4hoys"] @@ -15,6 +15,7 @@ [ext_resource type="AudioStream" uid="uid://bl8yg1d3bsxs3" path="res://assets/Audio/constant-natural-strong-wind-looping-SBA-300062687.wav" id="11_he7p5"] [ext_resource type="AudioStream" uid="uid://cy150nsjqp7lt" path="res://assets/Audio/grunt-male-SBA-300282985.wav" id="12_f51u4"] [ext_resource type="AudioStream" uid="uid://cwre1dq8gsvbg" path="res://assets/Audio/Foley Sports/Boxing/Gloves Block Intense.wav" id="12_qhd01"] +[ext_resource type="PackedScene" uid="uid://cfbwx2fsdp0b3" path="res://pause_menu.tscn" id="13_xrfwr"] [ext_resource type="AudioStream" uid="uid://t50i483xmj3a" path="res://assets/Audio/Weapons/toy-click-spin-SBA-300071143.wav" id="14_pnsbm"] [ext_resource type="AudioStream" uid="uid://c1e6vr2hndho7" path="res://assets/Audio/Weapons/Misc (Ammo Boxes, Holsters, Etc)/Kydex Unholster 002.wav" id="17_1fyjm"] @@ -41,7 +42,7 @@ radius = 7.0 [node name="Player" type="CharacterBody3D" node_paths=PackedStringArray("weapon_holder") groups=["player"]] transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1.11359, 0) -collision_layer = 11 +collision_layer = 6 collision_mask = 11 script = ExtResource("1_x7wms") dead_player = ExtResource("2_4hoys") @@ -156,6 +157,10 @@ collide_with_areas = true [node name="Kick" type="AudioStreamPlayer3D" parent="Head/Recoil/Camera3D/Audio"] stream = ExtResource("12_qhd01") +[node name="PauseMenu" parent="Head/Recoil/Camera3D" instance=ExtResource("13_xrfwr")] +offset_right = 0.0 +offset_bottom = 0.0 + [node name="pick_up_detection" type="Area3D" parent="."] collision_layer = 0 collision_mask = 16 diff --git a/assets/revolver_1.tscn b/assets/revolver_1.tscn index b6b3602..eadccd0 100644 --- a/assets/revolver_1.tscn +++ b/assets/revolver_1.tscn @@ -1081,7 +1081,7 @@ recoil_amount = Vector3(0.5, 0.1, 0.1) max_ammo = 6 bullet_damage = 5 bullet_force_mod = 10 -bullet_speed = 1200 +bullet_speed = 1500 bullet_drop = 0.0 random_spread_amt = 0.1 chamber = NodePath("revolver1/Chamber") diff --git a/levels/switch_target.gd b/levels/switch_target.gd index 330eddb..8a89878 100644 --- a/levels/switch_target.gd +++ b/levels/switch_target.gd @@ -2,14 +2,5 @@ extends StaticBody3D signal switch_hit() -# Called when the node enters the scene tree for the first time. -func _ready() -> void: - pass # Replace with function body. - - -# Called every frame. 'delta' is the elapsed time since the previous frame. -func _process(delta: float) -> void: - pass - func hit(): emit_signal("switch_hit") diff --git a/levels/switchcontroller.gd b/levels/switchcontroller.gd index 85e5b01..1445e9d 100644 --- a/levels/switchcontroller.gd +++ b/levels/switchcontroller.gd @@ -39,8 +39,7 @@ func _on_switch_changed() -> void: else: if door.door_open == true: door.close() - - #Otherwise follow standard switches + #Otherwise follow standard switches elif switches_on == switches_needed: print("switch check run with " + str(switches_on) + "switches on") if door.door_open == false: @@ -49,3 +48,13 @@ func _on_switch_changed() -> void: print("switch check run with " + str(switches_on) + "switches on") if door.door_open == true: door.close() + + #Otherwise follow standard switches + elif switches_on == switches_needed: + print("switch check run with " + str(switches_on) + "switches on") + if door.door_open == false: + door.open() + else: + print("switch check run with " + str(switches_on) + "switches on") + if door.door_open == true: + door.close() diff --git a/pause_menu.gdshader b/pause_menu.gdshader new file mode 100644 index 0000000..932c04f --- /dev/null +++ b/pause_menu.gdshader @@ -0,0 +1,14 @@ +shader_type canvas_item; + +uniform sampler2D screen_texture: hint_screen_texture, filter_linear_mipmap; +uniform float amount: hint_range(0.0,5.0); + +void fragment() { + vec4 color =textureLod(screen_texture, SCREEN_UV, amount); + COLOR = color; +} + +//void light() { + // Called for every pixel for every light affecting the CanvasItem. + // Uncomment to replace the default light processing function with this one. +//} diff --git a/pause_menu.tscn b/pause_menu.tscn new file mode 100644 index 0000000..369e533 --- /dev/null +++ b/pause_menu.tscn @@ -0,0 +1,105 @@ +[gd_scene load_steps=6 format=3 uid="uid://cfbwx2fsdp0b3"] + +[ext_resource type="Script" path="res://scripts/pause_menu.gd" id="1_57eae"] +[ext_resource type="Shader" path="res://assets/crtTest.gdshader" id="1_t8tc5"] +[ext_resource type="FontFile" uid="uid://d2h2tjhxiv5wo" path="res://assets/fonts/White On Black.ttf" id="3_4nq4f"] + +[sub_resource type="ShaderMaterial" id="ShaderMaterial_62ipe"] +shader = ExtResource("1_t8tc5") +shader_parameter/overlay = true +shader_parameter/scanlines_opacity = 0.4 +shader_parameter/scanlines_width = 0.25 +shader_parameter/grille_opacity = 0.3 +shader_parameter/resolution = Vector2(640, 480) +shader_parameter/pixelate = true +shader_parameter/roll = true +shader_parameter/roll_speed = 8.0 +shader_parameter/roll_size = 15.0 +shader_parameter/roll_variation = 1.8 +shader_parameter/distort_intensity = 0.05 +shader_parameter/noise_opacity = 0.4 +shader_parameter/noise_speed = 5.0 +shader_parameter/static_noise_intensity = 0.06 +shader_parameter/aberration = 0.03 +shader_parameter/brightness = 1.4 +shader_parameter/discolor = true +shader_parameter/warp_amount = 1.0 +shader_parameter/clip_warp = false +shader_parameter/vignette_intensity = 0.4 +shader_parameter/vignette_opacity = 0.5 + +[sub_resource type="ShaderMaterial" id="ShaderMaterial_nsure"] +shader = ExtResource("1_t8tc5") +shader_parameter/overlay = true +shader_parameter/scanlines_opacity = 0.025 +shader_parameter/scanlines_width = 0.315 +shader_parameter/grille_opacity = 0.1 +shader_parameter/resolution = Vector2(640, 480) +shader_parameter/pixelate = true +shader_parameter/roll = true +shader_parameter/roll_speed = 8.0 +shader_parameter/roll_size = 15.0 +shader_parameter/roll_variation = 1.8 +shader_parameter/distort_intensity = 0.05 +shader_parameter/noise_opacity = 0.4 +shader_parameter/noise_speed = 5.0 +shader_parameter/static_noise_intensity = 0.06 +shader_parameter/aberration = 0.03 +shader_parameter/brightness = 1.4 +shader_parameter/discolor = true +shader_parameter/warp_amount = 0.0 +shader_parameter/clip_warp = true +shader_parameter/vignette_intensity = 0.4 +shader_parameter/vignette_opacity = 0.235 + +[node name="PauseMenu" type="Control"] +material = SubResource("ShaderMaterial_62ipe") +layout_mode = 3 +anchors_preset = 15 +anchor_right = 1.0 +anchor_bottom = 1.0 +offset_right = 2688.0 +offset_bottom = 1512.0 +grow_horizontal = 2 +grow_vertical = 2 +script = ExtResource("1_57eae") + +[node name="ColorRect" type="ColorRect" parent="."] +material = SubResource("ShaderMaterial_nsure") +layout_mode = 0 +offset_right = 3840.0 +offset_bottom = 2160.0 + +[node name="MarginContainer" type="MarginContainer" parent="."] +layout_mode = 1 +anchors_preset = 8 +anchor_left = 0.5 +anchor_top = 0.5 +anchor_right = 0.5 +anchor_bottom = 0.5 +offset_left = -277.018 +offset_top = -174.68 +offset_right = 277.018 +offset_bottom = 174.68 +grow_horizontal = 2 +grow_vertical = 2 + +[node name="VBoxContainer" type="VBoxContainer" parent="MarginContainer"] +layout_mode = 2 +size_flags_horizontal = 4 +size_flags_vertical = 4 + +[node name="Resume" type="Button" parent="MarginContainer/VBoxContainer"] +layout_mode = 2 +theme_override_fonts/font = ExtResource("3_4nq4f") +theme_override_font_sizes/font_size = 150 +text = "Resume" + +[node name="Save & Quit" type="Button" parent="MarginContainer/VBoxContainer"] +layout_mode = 2 +theme_override_fonts/font = ExtResource("3_4nq4f") +theme_override_font_sizes/font_size = 150 +text = "Save & Quit" + +[connection signal="pressed" from="MarginContainer/VBoxContainer/Resume" to="." method="_on_resume_pressed"] +[connection signal="pressed" from="MarginContainer/VBoxContainer/Save & Quit" to="." method="_on_save__quit_pressed"] diff --git a/scripts/LevelManager.gd b/scripts/LevelManager.gd index a77c935..701f166 100644 --- a/scripts/LevelManager.gd +++ b/scripts/LevelManager.gd @@ -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() diff --git a/scripts/bullet.gd b/scripts/bullet.gd index 8a7686d..f87723f 100644 --- a/scripts/bullet.gd +++ b/scripts/bullet.gd @@ -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() diff --git a/scripts/dead_cam.gd b/scripts/dead_cam.gd index 8a57748..7726558 100644 --- a/scripts/dead_cam.gd +++ b/scripts/dead_cam.gd @@ -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(): diff --git a/scripts/enemy_taunt.gd b/scripts/enemy_taunt.gd index 4b90b1e..e8f5244 100644 --- a/scripts/enemy_taunt.gd +++ b/scripts/enemy_taunt.gd @@ -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. diff --git a/scripts/pause_menu.gd b/scripts/pause_menu.gd new file mode 100644 index 0000000..62ff29e --- /dev/null +++ b/scripts/pause_menu.gd @@ -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() diff --git a/scripts/player.gd b/scripts/player.gd index 8d2eebc..d6d5070 100644 --- a/scripts/player.gd +++ b/scripts/player.gd @@ -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)