0:01 / 0:30
Playback speed

Coyote time

Watch the jump indicator just after the feet leave the ledge. Try the same late press with the grace period off.

Interactive demo#PlatformersCeleste

A split second after running off a ledge when you can still jump.

Players press jump a few frames late more often than they realise. Honouring that press makes the game feel fair instead of fussy. The square lights when jump is pressed, just past the edge. Turn the grace period off to see that press ignored.

Code

src/demos/coyote_time.goose
namespace coyote_time_lesson;
import stage;
import std;
import math;

// Compare the press timestamp with the instant support was lost.
fn coyote_accepts(edge: f64, press: f64, grace: f64) -> bool {
    let elapsed = press - edge;
    return elapsed >= 0.0 && elapsed <= grace;
}

export "coyote-time" fn draw(time: f64, dt: f64, px: f64, py: f64, hover: bool) {
    artwork("valley");
    let t = time % 3.2;
    let x = 8 + 50 * t;
    let edge = (60.0 - 8.0) / 50.0;
    let press = 1.2;
    let since = max(0.0, t - edge);
    let enabled = toggle("on");
    var y = 60 + 137.5 * since * since;
    if enabled && coyote_accepts(edge, press, 0.2) && t >= press {
        y = 60 + 137.5 * (press - edge) * (press - edge) - rise(t - press, 110, 275);
        if x >= 104 {
            y = min(y, 60.0);
        }
    }
    ledge(0, 60, 60, 40);
    ledge(104, 60, 56, 40);
    actor(x, y, if y == 60 { walk(t) } else if enabled && t >= press { air_pose(110 - 275 * (t - press)) } else { DESCEND }, 2, "base", "runner");
    if enabled && t > edge && since < 0.2 {
        rect(x - 10, y - 32, 20, 3, INK);
        rect(x - 10, y - 32, 20 * (1 - since / 0.2), 3, MOSS);
    }
    signal_jump(t >= press && t < press + 0.15);
    line(60.5, 60, 60.5, 100, MAG, 2, 2);
}

Stage drawing helpers · All demos on GitHub

Comments

No comments yet.