feat: add state machine movement classes, double barrel shotgun weapon, and test level builder utility

This commit is contained in:
DottsGit
2026-06-04 01:21:50 -04:00
parent a54b3d89b1
commit 45fb7f0f38
6 changed files with 177 additions and 42 deletions
+27 -27
View File
@@ -26,6 +26,33 @@ func update(delta: float) -> void:
var player := machine.player
var vel: Vector3 = player.velocity
# ── Jump (coyote time + jump buffer) ──────────────────────────────────
if machine.input_jump_just_pressed and machine.coyote_timer > 0.0:
player.velocity.y = params.jump_velocity
machine.current_jump_count = 1
machine.on_ground = false
machine.coyote_timer = 0.0
machine.register_chain_mechanic("jump")
machine.switch_to("air")
return
# Jump buffer: player pressed jump just before landing
if machine.on_ground and machine.jump_buffer_time > 0.0:
player.velocity.y = params.jump_velocity
machine.current_jump_count = 1
machine.on_ground = false
machine.jump_buffer_time = 0.0
machine.register_chain_mechanic("jump")
machine.switch_to("air")
return
# ── Slide (crouch while moving fast enough) ───────────────────────────
if machine.input_crouch and machine.slide_cooldown_timer <= 0.0:
var hspeed := Vector3(player.velocity.x, 0.0, player.velocity.z).length()
if hspeed > params.slide_min_speed:
machine.switch_to("slide")
return
# ── Determine target speed ────────────────────────────────────────────
var wish_dir: Vector3 = machine.wish_dir_world
var speed := params.walk_speed
@@ -66,38 +93,11 @@ func update(delta: float) -> void:
else:
machine.on_ground = false
# ── Jump (coyote time + jump buffer) ──────────────────────────────────
if machine.input_jump_just_pressed and machine.coyote_timer > 0.0:
player.velocity.y = params.jump_velocity
machine.current_jump_count = 1
machine.on_ground = false
machine.coyote_timer = 0.0
machine.register_chain_mechanic("jump")
machine.switch_to("air")
return
# Jump buffer: player pressed jump just before landing
if machine.on_ground and machine.jump_buffer_time > 0.0:
player.velocity.y = params.jump_velocity
machine.current_jump_count = 1
machine.on_ground = false
machine.jump_buffer_time = 0.0
machine.register_chain_mechanic("jump")
machine.switch_to("air")
return
# ── Falling off ledge → air state ─────────────────────────────────────
if not machine.on_ground and machine.coyote_timer <= 0.0:
machine.switch_to("air")
return
# ── Slide (crouch while moving fast enough) ───────────────────────────
if machine.input_crouch and machine.slide_cooldown_timer <= 0.0:
var hspeed := Vector3(player.velocity.x, 0.0, player.velocity.z).length()
if hspeed > params.slide_min_speed:
machine.switch_to("slide")
return
# ── Wall run check ────────────────────────────────────────────────────
var wall_n := machine.detect_wall_horizontal()
if wall_n != Vector3.ZERO and machine.input_dir.length() > 0.1: