0:01 / 0:30
Playback speed

Air control

Try left, neutral and right steering. Which part of the arc is identical on all three runs?

Interactive demo#Platformers

The ability to steer sideways after leaving the ground.

Every run starts with the same jump. At the top, the steering input starts adding sideways acceleration. Changing that input moves the landing spot while the height and duration stay the same.

Code

src/demos/air_control.goose
namespace air_control_lesson;
import stage;
import std;
import math;

// Sideways acceleration starts at the apex. The takeoff is always identical.
fn steered_x(time: f64, steer: f64) -> f64 {
    let after_apex = max(0.0, time - 0.8);
    return 18.0 + 59.0 * time + steer * 95.0 * after_apex * after_apex / 2.0;
}

export "air-control" fn draw(time: f64, dt: f64, px: f64, py: f64, hover: bool) {
    artwork("valley");
    let t = min(time % 2.3, 1.6);
    let x = steered_x(t, number_control("steer", 0));
    ledge(0, 85, 160, 15);
    actor(x, 85 - rise(t, 136, 170), if t >= 1.6 { STAND } else { air_pose(136 - 170 * t) }, 2, "base", "runner");
}

Stage drawing helpers · All demos on GitHub

Comments

No comments yet.