0:01 / 0:30
Playback speed

Door knockdown

Move the target beyond the tip of the door. At what distance does it stop falling?

Interactive demo#TopDownHotline Miami

A swinging door can turn a doorway into a one-use knockdown zone.

A Hotline Miami-style doorway rewards choosing the right side to enter from. In this example the panel rotates a quarter turn about its hinge. The target falls when the leading edge passes its angle and the target lies within the door’s reach. Checking the swept angle catches a hit even if a frame skips over the target.

Code

src/demos/door_sweep.goose
namespace door_sweep_lesson;
import stage;
import std;
import math;

var opener = CourierTurn {};

export "door-sweep" fn draw(time: f64, dt: f64, px: f64, py: f64, hover: bool) {
    let t = time % 3.0;
    let angle = clamp((t - 0.7) / 0.42, 0.0, 1.0) * PI / 2;
    let distance = number_control("distance", 22);
    let target_angle = PI / 4;
    let hit = angle >= target_angle && distance <= 34;
    let tx = 76 + distance * cos(target_angle);
    let ty = 39 + distance * sin(target_angle);
    tiles();
    artwork("parquet", 0, 33, 76, 6);
    line(0, 39, 76, 39, "#a4896a");
    artwork("parquet", 111, 33, 49, 6);
    line(111, 39, 160, 39, "#a4896a");
    let walk = min(t / 0.9, 1.0) * 24;
    steer_courier(opener, time, 91, 14 + walk, PI / 2, PI / 2, PI / 2);
    draw_steering_courier(opener);
    save();
    translate(76, 39);
    rotate(angle);
    rect(0, -2, 34, 4, "#785044");
    rect(1, -1, 32, 1, "#d5ad76");
    ell(29, 1, 1.4, 1.4, GOLD);
    restore();
    ring(76, 39, 2, WHITE);
    if hit {
        save();
        translate(tx + 2, ty + 2);
        rotate(0.7);
        scale(1.1, 0.56);
        courier(0, 0, PI, PI);
        restore();
        ring(tx, ty - 5, 3.2, GOLD, 1, 2);
    }
    else { courier(tx, ty, PI, PI); }
}

Stage drawing helpers · All demos on GitHub

Comments

No comments yet.