Beat the coyote with an ACME-branded mallet.

This commit is contained in:
2026-02-25 16:59:53 +11:00
parent 14d73418eb
commit 9961dc6ed4

View File

@@ -16,9 +16,9 @@ var just_bounced: bool = false #allow max bounce height (i.e. ignore jump input)
const MAX_MOVE_SPEED: int = 300 const MAX_MOVE_SPEED: int = 300
const MAX_FALL_SPEED: int = 500 const MAX_FALL_SPEED: int = 500
#look and feel tweaks #game-feel
const COYOTE_DELAY: float = 0.0 var buffer_grounded: int = 0
var coyote_drop: bool = true var buffer_jumping: int = 0
#boilerplate #boilerplate
func _ready(): func _ready():
@@ -26,21 +26,29 @@ func _ready():
#movement #movement
func _physics_process(_delta) -> void: func _physics_process(_delta) -> void:
print(Engine.get_frames_per_second()) #coyote time
#fall off a ledge (with coyote time)
if is_on_floor(): if is_on_floor():
coyote_drop = false buffer_grounded = 6
else: else:
get_tree().create_timer(COYOTE_DELAY).timeout.connect(_coyote_timer_callback) buffer_grounded -= 1
#jump buffering
if Input.is_action_just_pressed("input_jump"):
buffer_jumping = 6
else:
buffer_jumping -= 1
#process coyote and jump buffers
if buffer_grounded > 0 and buffer_jumping > 0:
print(buffer_grounded, " ", buffer_jumping)
velocity.y = -JUMP_FORCE
buffer_grounded = 0
buffer_jumping = 0
#jump input
if is_on_floor() and Input.is_action_just_pressed("input_jump"):
velocity.y -= JUMP_FORCE
coyote_drop = true
#normally, fall faster than you rise #normally, fall faster than you rise
elif velocity.y < 0 and (Input.is_action_pressed("input_jump") or just_bounced): elif velocity.y < 0 and (Input.is_action_pressed("input_jump") or just_bounced):
velocity.y += GRAVITY_RISING velocity.y += GRAVITY_RISING
elif just_bounced or coyote_drop: else:
velocity.y += GRAVITY_FALLING velocity.y += GRAVITY_FALLING
just_bounced = false just_bounced = false
@@ -75,7 +83,5 @@ func _on_animation_finished() -> void:
func apply_bounce() -> void: func apply_bounce() -> void:
velocity.y = BOUNCE_FORCE velocity.y = BOUNCE_FORCE
just_bounced = true just_bounced = true
buffer_grounded = 0
func _coyote_timer_callback() -> void: buffer_jumping = 0
coyote_drop = !is_on_floor()
print("set to ", coyote_drop)