Independent upper body

Circle the courier with your pointer. Watch which heel stays planted as the hips catch up with the lamp.
Interactive demo#TopDownHotline Miami
The feet can keep walking one way while the torso turns another way.
Small aim changes turn the shoulders first. As the ring moves farther around, the hips follow and the boots step into a new stance, one at a time. Lock the layers to make the lamp turn with the hips.
Code
namespace independent_upper_body_lesson;
import stage;
import std;
import math;
var body = CourierTurn {};
export "independent-upper-body" fn draw(time: f64, dt: f64, px: f64, py: f64, hover: bool) {
let phase = time * 0.55;
let x = 80 + 36 * sin(phase);
let tx = if hover { px } else { x + 28 * sin(phase) };
let ty = if hover { py } else { 65 - 28 * cos(phase) };
let split = toggle("split");
// The open stance lets either foot lead when the courier changes direction.
let stance = if split { -PI / 2 } else { -acos(clamp(cos(phase) * 5, -1.0, 1.0)) };
let aim = if split { atan2(ty - 65, tx - x) } else { stance };
let facing = steer_courier(body, time, x, 65, 0, stance, aim, 1.6, !split);
tiles();
line(36, 78, 124, 78, MINT, 2, 4);
for tick in 9 {
let mark = 44 + 9 * tick;
line(mark, 77, mark, 79, "#648583");
}
ring(tx, ty, 4, PINK);
beam(x, 65, facing, 0.38, 41);
draw_steering_courier(body, 1.6);
}

Comments
No comments yet.