Strafing

Pause at the right side of the circle. Compare the direction of the lamp with the direction of the feet.
Interactive demo#TopDown
Moving sideways relative to the direction a character is facing.
The courier follows a circular path around a record player. With target lock, the lamp points inward while the feet move along the circle. Release the lock and the same walk becomes ordinary forward movement.
Code
namespace strafing_lesson;
import stage;
import std;
import math;
var skater = CourierTurn {};
// Travel is tangent to the orbit; locked aim points toward its centre.
fn strafe_angle(orbit: f64, locked: bool) -> f64 {
let pi = 3.141592653589793;
if locked {
return orbit + pi;
}
return orbit + pi / 2.0;
}
export "strafing" fn draw(time: f64, dt: f64, px: f64, py: f64, hover: bool) {
let angle = time * 0.50;
let x = 80 + 34 * cos(angle);
let y = 50 + 34 * sin(angle);
let face = strafe_angle(angle, toggle("lock"));
tiles();
ring(80, 50, 34, "#607183", 1, 4);
ell(80, 50, 8, 8, "#151622");
ring(80, 50, 6, PINK);
ell(80, 50, 2, 2, GOLD);
let facing = steer_courier(skater, time, x, y, angle + PI / 2, face, face);
beam(x, y, facing, 0.23, 34);
draw_steering_courier(skater);
}

Comments
No comments yet.