Blob shadow

Lift the character to its highest point. Use the oval to predict where its feet will land.
Interactive demo#Shadows#Shadow
A plain dark oval under a character. The cheapest shadow, and often enough.
No light is calculated at all. The oval stays on the ground while the character jumps, and shrinks and fades with height, so you can always see where they’ll land.
Code
namespace blob_shadow_lesson;
import stage;
import std;
import math;
export "blob-shadow" fn draw(time: f64, dt: f64, px: f64, py: f64, hover: bool) {
artwork("hall", 0, 0, W, 99);
ground(62);
let height = if hover { clamp(78.0 - py, 0.0, 44.0) } else { abs(sin(time * 2)) * 40 };
let size = 1 - height / 70;
opacity(0.35 + 0.4 * size);
ell(80, 80, 17 * size, 4.5 * size, INK);
opacity(1);
actor(80, 81 - height, if height < 2 { LAND } else if hover { TUCK } else { air_pose(sin(time * 2) * cos(time * 2) * 160) }, 3);
}

Comments
No comments yet.