gun system + minigun

This commit is contained in:
Michael Campbell 2026-02-19 00:04:31 -05:00
parent 84415d5aca
commit f73f093ae2
13 changed files with 84 additions and 24 deletions

View file

@ -28,6 +28,8 @@ var state := State.NORMAL
var dash_direction: Vector2
var stamina := 1.0
@onready var gun: Gun = %MiniGun
func _init() -> void:
instance = self
@ -38,10 +40,14 @@ func _process_stamina(delta: float) -> void:
stamina = move_toward(stamina, 1., delta * 0.2)
%StaminaBar.value = stamina
func _process_movement() -> void:
func exp_lerp(a: Variant, b: Variant, decay: float, dt: float) -> Variant:
return lerp(a, b, 1 - exp(-decay * dt))
func _process_movement(delta: float) -> void:
var input = Input.get_vector("move_left", "move_right", "move_up", "move_down")
input.normalized()
velocity = Vector3(input.x, 0., input.y) * MOVE_SPEED
var desired_velocity = Vector3(input.x, 0., input.y) * MOVE_SPEED
velocity = exp_lerp(velocity, desired_velocity, 20, delta)
move_and_slide()
if Input.is_action_just_pressed("dash") and stamina >= 1. and not input.is_zero_approx():
@ -76,7 +82,6 @@ func _process_aim() -> void:
%Reticle.position = to_mouse_pos
var fire_clock := 0.
func _process_shoot(delta: float) -> void:
var clock_mul := 1.
@ -84,14 +89,9 @@ func _process_shoot(delta: float) -> void:
State.DASHING: clock_mul = 2.5
State.LOCKED: clock_mul = 2.5
fire_clock -= delta * clock_mul
if Input.is_action_pressed("fire") and fire_clock <= 0.:
var dir := Vector3.RIGHT.rotated(Vector3.UP, aim_angle)
var player_projectile: PlayerProjectile = preload("res://player/projectile/player_projectile.tscn").instantiate()
player_projectile.init(dir)
player_projectile.global_position = global_position + Vector3.UP * 0.5
add_sibling(player_projectile)
fire_clock = 60. / 125.
gun.fire_clock -= delta * clock_mul
if Input.is_action_pressed("fire") and gun.fire_clock <= 0.:
gun.fire(aim_angle)
func _process_cam_shake(delta: float) -> void:
shake_duration -= delta
@ -110,7 +110,7 @@ func _process_cam_shake(delta: float) -> void:
func _process(delta: float) -> void:
match state:
State.NORMAL: _process_movement()
State.NORMAL: _process_movement(delta)
State.DASHING: _process_dash()
State.LOCKED: pass