Midair dash refill

Watch the charge meter during the crossing. Disable the crystal and see which dash disappears.
Interactive demo#PlatformersCeleste
A pickup restores a spent dash and gives the player a second decision in midair.
The runner spends one charge to cross the first gap. At the crystal, refill restores that charge. The second dash spends it to reach the far ledge. The small meter tracks the available dash, including the reset on landing. This scripted crossing isolates the resource rule used in Celeste-style traversal.
Code
namespace dash_refill_lesson;
import stage;
import std;
import math;
export "dash-refill" fn draw(time: f64, dt: f64, px: f64, py: f64, hover: bool) {
artwork("cave");
let t = time % 3.4;
let refill = toggle("refill");
let first = clamp((t - 0.45) / 0.32, 0.0, 1.0);
let second = if refill { clamp((t - 1.1) / 0.32, 0.0, 1.0) } else { 0.0 };
let x = 31 + 49 * first + 48 * second;
let drop = max(0.0, t - 0.77);
let feet = min(if x >= 121 { 65.0 } else { 130.0 }, 75 - 35 * first - 13 * second + 28 * drop * drop);
ledge(0, 76, 40, 24);
ledge(120, 65, 40, 35);
if refill && first < 1.0 { draw_prop("crystal", 73, 26, 14, 18); }
let dashing = (first > 0 && first < 1) || (second > 0 && second < 1);
let pose = if dashing { DASH } else if t < 0.45 || (x >= 121 && feet == 65) { STAND } else { DESCEND };
actor(x, feet, pose, 1.5, "base", "runner");
let charged = t < 0.45 || (refill && t >= 0.77 && t < 1.1) || (x >= 121 && feet >= 65);
box(6, 6, 13, 6, WHITE);
if charged { rect(8, 8, 9, 2, MINT); }
}

Comments
No comments yet.