Wall jump

Follow the second button flash. Which two directions of movement change at once?
Interactive demo#PlatformersCeleste
Pushing off a wall to jump upward and away from it.
The first jump reaches the right wall. At the second button flash, the wall kick sends the player left and upward. Without the kick, the player drops beside the wall.
Code
namespace wall_jump_lesson;
import stage;
import std;
import math;
// At contact, the wall impulse reverses horizontal travel.
fn wall_jump_x(time: f64, enabled: bool) -> f64 {
let contact = 0.75;
if time < contact {
return 52.0 + 48.0 * time;
}
if enabled {
return max(19.0, 88.0 - 67.0 * (time - contact));
}
return 88.0;
}
export "wall-jump" fn draw(time: f64, dt: f64, px: f64, py: f64, hover: bool) {
artwork("cave");
let t = time % 2.8;
let launch = 0.75;
let elapsed = max(0.0, t - launch);
let enabled = toggle("on");
var y = 91 - rise(t, 108, 172);
if t >= launch { y = 91 - rise(launch, 108, 172) - rise(elapsed, if enabled { 105.0 } else { 0.0 }, 172); }
ledge(99, 6, 24, 94);
ledge(0, 91, 160, 9);
signal_jump(t < 0.1 || (t >= launch && elapsed < 0.1));
let velocity = if t < launch { 108 - 172 * t } else { (if enabled { 105.0 } else { 0.0 }) - 172 * elapsed };
let pose = if y >= 91 { STAND } else if !enabled && t >= launch { BRACE } else { air_pose(velocity) };
actor(wall_jump_x(t, enabled) + 3, min(91.0, y), pose, 2, "base", "runner", enabled && t >= launch);
}

Comments
No comments yet.