Added a basic test map, options menu, bug fixes, and much more.
This commit is contained in:
Patrick 2025-08-08 10:57:42 +02:00
parent d72b5ac57b
commit 2dce012535
34 changed files with 1268 additions and 84 deletions

View file

@ -5,16 +5,25 @@ const SPEED: float = 5.0
const JUMP_VELOCITY: float = 4.5
@onready var camera_x: Node3D = $ViewY/ViewX
@onready var camera: Camera3D = $ViewY/ViewX/View
@onready var spring_arm: SpringArm3D = $ViewY/ViewX/Arm
@onready var camera: Camera3D = $ViewY/ViewX/Arm/View
@onready var syringe: Node3D = $Syringe
@onready var needle: Area3D = $Syringe/SyringeNeedle
@onready var bag: Node3D = $Bag
@onready var captured: Node3D = $Bag/Captured
@onready var mesh: MeshInstance3D = $Mesh
@onready var collision: CollisionShape3D = $Collision
var hunter: bool = true
var caught_player: Player = null
var new_spawn: Vector3
var crouching: bool = false
var speed_penalty: float = 0.0
@export var health: int = 100
func _ready() -> void:
@ -31,9 +40,9 @@ func _ready() -> void:
func _physics_process(delta: float) -> void:
# Zoom
if Input.is_action_just_released("zoom_in") and camera.position.z > 0:
camera.position.z += -1
spring_arm.spring_length -= 1
elif Input.is_action_just_released("zoom_out"):
camera.position.z += 1
spring_arm.spring_length += 1
if is_multiplayer_authority():
# Focus
@ -49,15 +58,31 @@ func _physics_process(delta: float) -> void:
velocity += get_gravity() * delta
# Jumping
if Input.is_action_just_pressed("jump") and is_on_floor():
if Input.is_action_just_pressed("jump") and is_on_floor() and !crouching:
velocity.y = JUMP_VELOCITY
if hunter:
speed_penalty += 2.0
if speed_penalty > SPEED - 1.0:
speed_penalty = SPEED - 1.0
# Crouching
if Input.is_action_just_pressed("crouch") and is_on_floor() and !hunter:
if crouching:
mesh.rotation_degrees.x = 0.0
collision.rotation_degrees.x = 0.0
camera_x.position.y = 0.5
else:
mesh.rotation_degrees.x = -90.0
collision.rotation_degrees.x = -90.0
camera_x.position.y = 0.0
crouching = !crouching
# Movement
var input_dir: Vector2 = Input.get_vector("move_left", "move_right", "move_forwards", "move_backwards")
var direction: Vector3 = (transform.basis * Vector3(input_dir.x, 0, input_dir.y)).normalized()
velocity.x = direction.x * SPEED
velocity.z = direction.z * SPEED
velocity.x = direction.x * (SPEED - speed_penalty)
velocity.z = direction.z * (SPEED - speed_penalty)
# Hunter specific
if hunter:
@ -67,6 +92,11 @@ func _physics_process(delta: float) -> void:
syringe.position.z += 0.1
syringe.position.z = clampf(syringe.position.z, -0.8, -0.3)
if speed_penalty > 0.0:
speed_penalty -= delta / 3.0
if speed_penalty <= 0.0:
speed_penalty = 0.0
if move_and_slide():
pass
@ -127,7 +157,7 @@ func get_imprisoned(coffin_path: NodePath) -> void:
# This is called on any player that has just stabbed/caught another.
@rpc("any_peer", "call_local", "reliable")
func capture_player(player_path: NodePath) -> void:
if multiplayer.get_remote_sender_id() == 1:
if multiplayer.get_remote_sender_id() == 1 and !caught_player:
var player: Player = get_node(player_path)
caught_player = player
captured.visible = true