Beat the coyote with an ACME-branded mallet.
This commit is contained in:
@@ -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_FALL_SPEED: int = 500
|
||||
|
||||
#look and feel tweaks
|
||||
const COYOTE_DELAY: float = 0.0
|
||||
var coyote_drop: bool = true
|
||||
#game-feel
|
||||
var buffer_grounded: int = 0
|
||||
var buffer_jumping: int = 0
|
||||
|
||||
#boilerplate
|
||||
func _ready():
|
||||
@@ -26,21 +26,29 @@ func _ready():
|
||||
|
||||
#movement
|
||||
func _physics_process(_delta) -> void:
|
||||
print(Engine.get_frames_per_second())
|
||||
#fall off a ledge (with coyote time)
|
||||
#coyote time
|
||||
if is_on_floor():
|
||||
coyote_drop = false
|
||||
buffer_grounded = 6
|
||||
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
|
||||
elif velocity.y < 0 and (Input.is_action_pressed("input_jump") or just_bounced):
|
||||
velocity.y += GRAVITY_RISING
|
||||
elif just_bounced or coyote_drop:
|
||||
else:
|
||||
velocity.y += GRAVITY_FALLING
|
||||
just_bounced = false
|
||||
|
||||
@@ -75,7 +83,5 @@ func _on_animation_finished() -> void:
|
||||
func apply_bounce() -> void:
|
||||
velocity.y = BOUNCE_FORCE
|
||||
just_bounced = true
|
||||
|
||||
func _coyote_timer_callback() -> void:
|
||||
coyote_drop = !is_on_floor()
|
||||
print("set to ", coyote_drop)
|
||||
buffer_grounded = 0
|
||||
buffer_jumping = 0
|
||||
|
||||
Reference in New Issue
Block a user