mirror of
https://github.com/jparkerweb/plan2code.git
synced 2026-12-03 08:15:41 -08:00
Move Ghoul Rush into activities/ghoul-rush/ and split ghoul.js
Every Ghoul Rush file moves under activities/ghoul-rush/, sorted into core, arms, draw, story, sfx, stages/<stage> and rides/<ride>, with names unchanged. ghoul.js is now a facade over seven parts in core/, taking it from over the 3,000 line cap to 50 lines. Also in this tree: the Drowned Lantern replaces the Bog Runner, the "Use a Lucky Die?" question, the Old Mother Bog rework, Rapid fire at 60 ms, the rules for the finale's first kill (not plugged in yet), and small fixes the suites asked for (the Stilt House's and Drowning Pool's weapons). AI Assisted
This commit is contained in:
1 parent
0454bdd19a
commit
903fbf5680
160 files changed
+11022
-7061
No files matched your search
@@ -0,0 +1,140 @@
|
||||
// Plan2Code Web Console - Ghoul Rush's Holy Roller, its course: the fixed, seeded run down the Chapel's nave, laid out by TIME and turned into distance. No imports, no random numbers.
|
||||
//
|
||||
// The ride speeds up with the distance it has covered (speedAt: V0 at the start, climbing by ACC every
|
||||
// second), so a second of ride time is a place (xAt). The course is written in seconds, a row of up to three
|
||||
// things across the three lanes at a time, and every gap between two rows is long enough for a player to
|
||||
// answer the first and get to the second (the tests walk the whole course to prove a safe path exists
|
||||
// at every moment). Nothing here draws a random number: the same course every time.
|
||||
//
|
||||
// Output (all frozen), x being distance down the aisle and `lane` 0 (left), 1 (middle) or 2 (right):
|
||||
// - `items`: [x, lane, kind, len] for every thing in the way, sorted by x. `x` is the thing's near
|
||||
// edge and `len` how deep it runs (0 for the kind's own depth, see KINDS in ghoul-pew.js). Kinds:
|
||||
// "pillar", "confessional", "pewx" (SWITCH), "kneeler", "stand", "cracks", "hatch" (JUMP), "censer",
|
||||
// "banner", "beam" (SLIDE), "garg" (SHOOT or switch) and "bell" (a rope: SHOOT, harmless).
|
||||
// - `souls`: [x, lane, h, type] wax souls (type 0) and halos (type 1, a magnet) with their height.
|
||||
// - `checks`: the checkpoints' x; `finish`: where the ride ends; `rows`: [x, [kinds...]] for the art/tests.
|
||||
|
||||
export const PEW_START = 8;
|
||||
export const V0 = 34;
|
||||
export const ACC = 0.7;
|
||||
export const V_MAX = 84;
|
||||
export const RIDE_S = 66;
|
||||
|
||||
// Where the ride is `t` seconds in, and how fast it rolls at distance `x`.
|
||||
export const xAt = (t) => PEW_START + V0 * t + (ACC * t * t) / 2;
|
||||
export const speedAt = (x) => Math.min(V_MAX, Math.sqrt(V0 * V0 + 2 * ACC * Math.max(0, x - PEW_START)));
|
||||
|
||||
const r1 = (n) => Math.round(n * 10) / 10;
|
||||
const SOUL_STEP = 0.14;
|
||||
|
||||
function build() {
|
||||
const items = [];
|
||||
const souls = [];
|
||||
const rows = [];
|
||||
const it = (t, lane, kind, len = 0) => items.push([r1(xAt(t)), lane, kind, len]);
|
||||
const row = (t, kinds) => {
|
||||
kinds.forEach((kind, lane) => kind && it(t, lane, kind, kind === "cracks" ? 7 : 0));
|
||||
rows.push([r1(xAt(t)), kinds]);
|
||||
};
|
||||
const line = (t0, t1, lane, h = 1.5) => {
|
||||
for (let t = t0; t <= t1 + 1e-9; t += SOUL_STEP) souls.push([r1(xAt(t)), lane, h, 0]);
|
||||
};
|
||||
// Souls rising over a jump and coming down again, centered at time t.
|
||||
const arc = (t, lane, peak = 4.4, half = 0.42) => {
|
||||
for (let u = -half; u <= half + 1e-9; u += SOUL_STEP) souls.push([r1(xAt(t + u + 0.1)), lane, 1.4 + peak * (1 - (u / half) ** 2), 0]);
|
||||
};
|
||||
const halo = (t, lane) => souls.push([r1(xAt(t)), lane, 2.4, 1]);
|
||||
const [K, X, P, C, B, I, M, S, H, G, R, CR] = ["kneeler", "pewx", "pillar", "confessional", "banner", "censer", "beam", "stand", "hatch", "garg", "bell", "cracks"];
|
||||
const _ = null;
|
||||
|
||||
// Act one: each answer on its own. JUMP, SWITCH, SLIDE, SWITCH again, a row that asks for all three, SHOOT.
|
||||
row(3.4, [K, K, K]);
|
||||
arc(3.4, 1);
|
||||
row(6, [X, X, _]);
|
||||
line(5.5, 6.6, 2);
|
||||
row(8.5, [B, B, B]);
|
||||
line(8.1, 8.9, 0, 0.9);
|
||||
line(8.1, 8.9, 2, 0.9);
|
||||
row(11, [_, C, C]);
|
||||
line(10.4, 11.8, 0);
|
||||
row(13.4, [P, K, I]);
|
||||
arc(13.4, 1);
|
||||
line(13, 13.8, 2, 0.9);
|
||||
row(15.8, [_, G, _]);
|
||||
line(15.2, 16.2, 0);
|
||||
line(15.2, 16.2, 2);
|
||||
// Act two: a bell rope that clears the gargoyles after it, staggered switching, jump-then-slide.
|
||||
it(18.2, 0, R);
|
||||
row(20.8, [G, G, _]);
|
||||
line(20.2, 21.4, 2);
|
||||
halo(22.2, 2);
|
||||
row(23, [X, _, X]);
|
||||
line(22.6, 23.4, 1);
|
||||
row(24.6, [_, X, X]);
|
||||
line(24.3, 24.9, 0);
|
||||
row(26.2, [X, X, _]);
|
||||
line(25.9, 26.5, 2);
|
||||
row(28.2, [K, K, K]);
|
||||
arc(28.2, 0);
|
||||
arc(28.2, 1);
|
||||
arc(28.2, 2);
|
||||
row(29.6, [B, B, B]);
|
||||
line(29.3, 29.9, 1, 0.9);
|
||||
row(31.4, [H, CR, H]);
|
||||
arc(31.4, 0);
|
||||
arc(31.4, 2);
|
||||
row(33.4, [I, P, I]);
|
||||
line(33, 33.8, 0, 0.9);
|
||||
line(33, 33.8, 2, 0.9);
|
||||
halo(34.6, 0);
|
||||
line(35, 36, 0);
|
||||
line(35, 36, 1);
|
||||
line(35, 36, 2);
|
||||
row(37, [M, M, M]);
|
||||
line(36.7, 37.5, 1, 0.9);
|
||||
row(38.8, [C, _, C]);
|
||||
line(38.4, 39.4, 1);
|
||||
row(40.4, [S, K, S]);
|
||||
arc(40.4, 1);
|
||||
// Act three: faster and closer. Mixed rows, a second bell, gargoyles on both flanks.
|
||||
it(42, 1, R);
|
||||
row(44, [_, G, G]);
|
||||
line(43.6, 44.6, 0);
|
||||
row(45.6, [P, _, B]);
|
||||
line(45.2, 46, 1);
|
||||
row(47, [K, B, K]);
|
||||
arc(47, 0);
|
||||
arc(47, 2);
|
||||
row(48.4, [_, C, _]);
|
||||
line(48, 48.8, 0);
|
||||
line(48, 48.8, 2);
|
||||
row(49.8, [X, _, _]);
|
||||
line(49.4, 50.2, 2);
|
||||
row(51.2, [H, H, H]);
|
||||
arc(51.2, 1);
|
||||
row(52.6, [B, B, B]);
|
||||
line(52.3, 52.9, 0, 0.9);
|
||||
halo(53.8, 2);
|
||||
row(54.6, [P, P, _]);
|
||||
line(54.2, 55, 2);
|
||||
row(56, [_, P, P]);
|
||||
line(55.6, 56.4, 0);
|
||||
row(57.4, [G, _, G]);
|
||||
line(57, 57.8, 1);
|
||||
row(59, [I, K, I]);
|
||||
arc(59, 1);
|
||||
row(60.6, [P, _, P]);
|
||||
line(60.2, 61, 1);
|
||||
row(62, [M, M, M]);
|
||||
line(61.7, 62.5, 1, 0.9);
|
||||
row(63.5, [_, P, _]);
|
||||
line(63.1, 63.9, 0);
|
||||
line(63.1, 63.9, 2);
|
||||
line(64.4, 65.4, 1, 2);
|
||||
items.sort((a, b) => a[0] - b[0] || a[1] - b[1]);
|
||||
souls.sort((a, b) => a[0] - b[0] || a[1] - b[1]);
|
||||
return { items, souls, rows, checks: [16.5, 31, 46, 58].map((t) => r1(xAt(t))), finish: r1(xAt(RIDE_S)) };
|
||||
}
|
||||
|
||||
const deep = (v) => (Array.isArray(v) ? Object.freeze(v.map(deep)) : v);
|
||||
export const COURSE = Object.freeze(Object.fromEntries(Object.entries(build()).map(([k, v]) => [k, deep(v)])));
|
||||
@@ -0,0 +1,249 @@
|
||||
// Plan2Code Web Console - Ghoul Rush's Holy Roller, its drawing: the Chapel's runaway pew seen from behind, an endless-runner down the nave in three lanes. The whole field is drawn by this ride's own art (`field`, in pseudo-3D by ghoul-pew-world.js) the way the Carnival's dark ride draws its gallery; ghoul-draw.js hands it the frame and then draws the hearts, the cards, the banner and the HUD pills on top.
|
||||
//
|
||||
// ghoul-draw.js plugs it in. LOOKS, VOICES, EVENT_VOICE, LOSE_WORDS and LOSE_SOUNDS are plain data;
|
||||
// pewArt(d) takes ghoul-draw.js's drawing helpers (`d`) and hands back the pack the usual way plus `field`, so
|
||||
// this file never reaches back into it (it reads only the rules' numbers from ghoul-pew.js). Everything of
|
||||
// the ride's own is read off `round.runner` (see ghoul-pew.js) and the room's `ride`; the events leave
|
||||
// short-lived bits in the view's `fx` (floats, bursts and rings in field units, y counted up from the field's bottom).
|
||||
|
||||
import { SOUL_SHARE, V0, V_MAX, soulShare, soulTotal } from "./ghoul-pew.js";
|
||||
import { HOR, LW, worldArt } from "./ghoul-pew-world.js";
|
||||
|
||||
const freeze = (o) => Object.freeze(o);
|
||||
const clamp = (x, lo, hi) => Math.min(hi, Math.max(lo, x));
|
||||
|
||||
const look = (o) => freeze({ pack: "pew", custom: true, noMoon: true, pit: "#07040c", ...o });
|
||||
export const LOOKS = freeze({
|
||||
pew: look({ wallTop: "#0c0816", wallLow: "#1c1230", paper: "#2a1c40", wainscot: "#1a1020", floorTop: "#6a6070", floor: "#2e2834", floorEdge: "#0c0a10", shelf: "#4a3220", shelfTop: "#8a6440", window: "#d8a0f0", decor: "pews", color: "#f0c870", dark: 0.3 }),
|
||||
});
|
||||
|
||||
// How each new kind sounds, by act (the sounds in ghoul-sfx-pew.js).
|
||||
export const VOICES = freeze({
|
||||
pew: freeze({
|
||||
lane: "ghoulPewLane", bump: "ghoulPewBump", jump: "ghoulPewJump", land: "ghoulPewLand", slide: "ghoulPewSlide", dive: "ghoulPewDive",
|
||||
soul: "ghoulPewSoul", halo: "ghoulPewHalo", crash: "ghoulPewCrash", check: "ghoulPewCheck", finish: "ghoulPewFinish", speed: "ghoulPewSpeed",
|
||||
}),
|
||||
pewgarg: freeze({ warn: "ghoulPewGargWarn", drop: "ghoulPewGargDrop", chip: "ghoulPewGargChip", hit: "ghoulPewGargHit" }),
|
||||
pewbell: freeze({ ring: "ghoulPewBell" }),
|
||||
});
|
||||
|
||||
// What each of the pack's events plays: [kind, act], once.
|
||||
export const EVENT_VOICE = freeze({
|
||||
pewLane: ["pew", "lane"],
|
||||
pewBump: ["pew", "bump"],
|
||||
pewJump: ["pew", "jump"],
|
||||
pewLand: ["pew", "land"],
|
||||
pewSlide: ["pew", "slide"],
|
||||
pewDive: ["pew", "dive"],
|
||||
pewSoul: ["pew", "soul"],
|
||||
pewHalo: ["pew", "halo"],
|
||||
pewCrash: ["pew", "crash"],
|
||||
pewCheck: ["pew", "check"],
|
||||
pewFinish: ["pew", "finish"],
|
||||
pewSpeed: ["pew", "speed"],
|
||||
pewGargWarn: ["pewgarg", "warn"],
|
||||
pewGargDrop: ["pewgarg", "drop"],
|
||||
pewGargChip: ["pewgarg", "chip"],
|
||||
pewGargHit: ["pewgarg", "hit"],
|
||||
pewBell: ["pewbell", "ring"],
|
||||
});
|
||||
export const LOSE_WORDS = freeze({
|
||||
pewPillar: "Ran into a pillar", pewConfessional: "Into a confessional", pewCrosswise: "Crashed into a pew", pewKneeler: "Tripped on a kneeler",
|
||||
pewCandle: "Hit a candle stand", pewFlagstone: "Cracked on a flagstone", pewHatch: "Fell down a crypt hatch", pewCenser: "Censer to the head",
|
||||
pewBanner: "Banner to the face", pewBeam: "Struck by a beam", pewGargoyle: "Flattened by a gargoyle",
|
||||
});
|
||||
export const LOSE_SOUNDS = freeze({
|
||||
pewPillar: ["thud", 0.55, 0.8],
|
||||
pewConfessional: ["thud", 0.5, 0.9],
|
||||
pewCrosswise: ["thud", 0.5, 1],
|
||||
pewKneeler: ["thud", 0.5, 1.1],
|
||||
pewCandle: ["clank", 0.5, 1.1],
|
||||
pewFlagstone: ["ghoulRockLand", 0.5, 0.9],
|
||||
pewHatch: ["ghoulPitFall", 0.55, 1],
|
||||
pewCenser: ["clank", 0.5, 0.8],
|
||||
pewBanner: ["thud", 0.4, 1.2],
|
||||
pewBeam: ["smash", 0.5, 0.8],
|
||||
pewGargoyle: ["crunch", 0.55, 0.7],
|
||||
});
|
||||
|
||||
// The progress track along the field's top: the ride, its checkpoints and where the pew is.
|
||||
export const BAR = freeze({ x0: 22, x1: 74, y: 3 });
|
||||
|
||||
export function pewArt(d) {
|
||||
const { label, GOLD, say } = d;
|
||||
const world = worldArt(d);
|
||||
const pewOf = (round) => (round && round.runner && round.runner.id === "pew" ? round.runner : null);
|
||||
|
||||
// The still layers never draw this room (the field is the ride's), so they only get the nave's dark.
|
||||
function backdrop(ctx, v, lk, x0, x1) {
|
||||
ctx.fillStyle = lk.wallLow;
|
||||
ctx.fillRect(x0, 0, x1 - x0, v.g.FIELD_H);
|
||||
}
|
||||
const ground = () => {};
|
||||
const shelf = () => {};
|
||||
const lights = () => {};
|
||||
const dim = () => 0;
|
||||
|
||||
/* ----------------------------------------------------------- the frame */
|
||||
|
||||
// The whole field: the nave in pseudo-3D, the ride's own HUD strip, then the effects the events left.
|
||||
function field(ctx, v) {
|
||||
const { round, g } = v;
|
||||
const c = pewOf(round);
|
||||
if (!c) return;
|
||||
const R = round.spec.ride;
|
||||
const you = round.you;
|
||||
ctx.save();
|
||||
if (v.shake) ctx.translate(v.shake.x * 0.6, v.shake.y * 0.6);
|
||||
world.paint(ctx, v);
|
||||
ctx.restore();
|
||||
const Y = (y) => g.FIELD_H - y;
|
||||
// The progress track with its checkpoints and the pew on it.
|
||||
const { x0, x1, y } = BAR;
|
||||
const p = clamp((you.x - round.spec.start) / (R.finish - round.spec.start), 0, 1);
|
||||
ctx.globalAlpha = 0.6;
|
||||
ctx.fillStyle = "#05060f";
|
||||
ctx.fillRect(x0 - 0.6, y - 0.9, x1 - x0 + 1.2, 1.8);
|
||||
ctx.globalAlpha = 1;
|
||||
const speedK = clamp((c.v - V0) / (V_MAX - V0), 0, 1);
|
||||
ctx.fillStyle = speedK > 0.66 ? "#ff8a4a" : speedK > 0.33 ? "#ffd36a" : "#7fd0ff";
|
||||
ctx.fillRect(x0, y - 0.45, (x1 - x0) * p, 0.9);
|
||||
for (const cx of R.checks) {
|
||||
const k = (cx - round.spec.start) / (R.finish - round.spec.start);
|
||||
ctx.fillStyle = cx <= you.x ? "#7dffa0" : "#cdbfe6";
|
||||
ctx.fillRect(x0 + (x1 - x0) * k - 0.15, y - 1.1, 0.3, 2.2);
|
||||
}
|
||||
ctx.fillStyle = GOLD;
|
||||
ctx.beginPath();
|
||||
ctx.arc(x0 + (x1 - x0) * p, y, 0.9, 0, Math.PI * 2);
|
||||
ctx.fill();
|
||||
// Souls on the left, the combo on the right.
|
||||
label(ctx, `SOULS ${c.got}/${soulTotal(R)}`, 3, 6.2, 2, soulShare(R, c) >= SOUL_SHARE ? "#7dffa0" : "#f0e8d8", "left");
|
||||
if (c.combo > 1) {
|
||||
const pop = 1 + Math.max(0, 1 - (v.fx.clock - (v.fx.pewPop || -1e4)) / 220) * 0.3;
|
||||
label(ctx, `x${c.mult} ${c.combo} IN A ROW`, g.FIELD_W - 3, 6.4, 2.1 * pop, c.mult > 1 ? GOLD : "#f0e8d8", "right");
|
||||
}
|
||||
if (c.magnet > 0) label(ctx, "HALO", g.FIELD_W - 3, 9.6, 1.7, "#ffd75a", "right");
|
||||
// Floats, bursts and rings that events left (field units, y up).
|
||||
for (const q of v.fx.parts) {
|
||||
ctx.globalAlpha = Math.max(0, q.life / q.max);
|
||||
ctx.fillStyle = q.color;
|
||||
ctx.fillRect(q.x - q.size / 2, Y(q.y) - q.size / 2, q.size, q.size);
|
||||
}
|
||||
for (const r of v.fx.rings) {
|
||||
const k = 1 - r.life / r.max;
|
||||
ctx.globalAlpha = (1 - k) * 0.8;
|
||||
ctx.strokeStyle = r.color;
|
||||
ctx.lineWidth = 0.5 * (1 - k) + 0.15;
|
||||
ctx.beginPath();
|
||||
ctx.arc(r.x, Y(r.y), r.r0 + k * r.grow, 0, Math.PI * 2);
|
||||
ctx.stroke();
|
||||
}
|
||||
ctx.globalAlpha = 1;
|
||||
}
|
||||
|
||||
/* -------------------------------------------------------------- events */
|
||||
|
||||
// A throttle on a repeating cue.
|
||||
function gateOnce(fx, key, ms) {
|
||||
if ((fx[key] || 0) > fx.clock) return false;
|
||||
fx[key] = fx.clock + ms;
|
||||
return true;
|
||||
}
|
||||
// Where the pew is on the screen (x) and a height over its feet (y up from the field's bottom).
|
||||
const heroX = (lane) => 48 + (lane - 1) * 0.45 * LW;
|
||||
|
||||
// What the pack's events look and sound like; true when the event is its own. Each of its
|
||||
// sounds plays once, from EVENT_VOICE (a soul's tick climbs with the combo).
|
||||
function react(e, k) {
|
||||
const { tone, shake, flash, burst, float, ring, fx } = k;
|
||||
const voice = EVENT_VOICE[e.type];
|
||||
if (!voice) return false;
|
||||
if ((e.type === "pewSlide" || e.type === "pewLane") && !gateOnce(fx, `${e.type}Ms`, 90)) return true;
|
||||
if (e.type === "pewSoul") tone(VOICES.pew.soul, 0.28, 1 + 0.05 * Math.min(12, (e.combo || 1) - 1) + 0.12 * ((e.mult || 1) - 1));
|
||||
else say(tone, voice[0], voice[1], e.type === "pewSpeed" ? 0.4 : 0.5);
|
||||
const x = heroX(e.lane === undefined ? 1 : e.lane);
|
||||
const fy = 54 - 36;
|
||||
switch (e.type) {
|
||||
case "pewJump":
|
||||
burst(x, 54 - 6, "#b89a78", 5, 7, 300);
|
||||
break;
|
||||
case "pewLand":
|
||||
burst(x, 54 - 7, "#b0a4b8", e.big ? 14 : 6, e.big ? 12 : 8, 360);
|
||||
if (e.big) shake(180, 0.5);
|
||||
break;
|
||||
case "pewBump":
|
||||
shake(160, 0.5);
|
||||
burst(x + (e.dir || 0) * 5, 54 - 14, "#cfd2e6", 5, 6, 260);
|
||||
break;
|
||||
case "pewSoul":
|
||||
burst(heroX(e.lane), fy - (e.h || 1.5) * 2, "#ffd36a", 2, 5, 240);
|
||||
if (e.up) {
|
||||
fx.pewPop = fx.clock;
|
||||
ring(48, 54 - 22, "#ffd36a", 1, 9, 500);
|
||||
float(48, 54 - 14, `Combo x${e.mult}`, GOLD, 2.6);
|
||||
}
|
||||
break;
|
||||
case "pewHalo":
|
||||
ring(48, 54 - 24, "#ffd75a", 1, 14, 600);
|
||||
float(48, 54 - 16, "Halo!", GOLD, 2.6);
|
||||
break;
|
||||
case "pewCrash":
|
||||
shake(340, 1);
|
||||
flash("#ffe0a8", 220);
|
||||
burst(x, 54 - 16, e.what === "garg" ? "#8a96bc" : "#8a5a36", 18, 17, 520);
|
||||
if (e.lost > 5) float(48, 54 - 16, "Combo lost", "#cdbfe6", 2);
|
||||
break;
|
||||
case "pewCheck":
|
||||
float(48, 54 - 34, "Checkpoint", GOLD, 2.4);
|
||||
ring(48, 54 - 30, "#7dffa0", 1, 10, 500);
|
||||
break;
|
||||
case "pewFinish":
|
||||
shake(260, 0.7);
|
||||
burst(48, 54 - 24, "#ffd36a", 24, 14, 600);
|
||||
float(48, 54 - 30, e.share >= SOUL_SHARE ? "Amen! A full choir" : "Amen!", GOLD, 2.8);
|
||||
break;
|
||||
case "pewSpeed":
|
||||
ring(48, 54 - HOR, "#9ab0ff", 4, 40, 520);
|
||||
float(48, 54 - 40, "Faster!", "#ffb02e", 2.2);
|
||||
break;
|
||||
case "pewGargWarn":
|
||||
shake(120, 0.25);
|
||||
break;
|
||||
case "pewGargDrop":
|
||||
shake(200, 0.55);
|
||||
burst(heroX(e.lane), 54 - 22, "#8a96bc", 10, 9, 420);
|
||||
break;
|
||||
case "pewGargChip":
|
||||
burst(heroX(e.lane), 54 - 24, "#8a96bc", 6, 8, 300);
|
||||
break;
|
||||
case "pewGargHit":
|
||||
burst(heroX(e.lane), 54 - 24, "#8a96bc", 14, 14, 480);
|
||||
float(heroX(e.lane), 54 - 28, `+${e.points}`, GOLD, 2.2);
|
||||
break;
|
||||
case "pewBell":
|
||||
ring(heroX(e.lane), 54 - 26, "#ffd36a", 1, 14, 700);
|
||||
float(48, 54 - 30, e.stunned > 0 ? `+${e.points} Stunned!` : `+${e.points}`, GOLD, 2.4);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
return freeze({
|
||||
looks: LOOKS,
|
||||
backdrop,
|
||||
ground,
|
||||
shelf,
|
||||
dim,
|
||||
monsters: freeze({}),
|
||||
bosses: freeze({}),
|
||||
missiles: freeze({}),
|
||||
hazards: freeze({}),
|
||||
powers: freeze({}),
|
||||
lights,
|
||||
react,
|
||||
field,
|
||||
});
|
||||
}
|
||||
@@ -0,0 +1,947 @@
|
||||
// Plan2Code Web Console - Ghoul Rush's Holy Roller, its world: the nave seen from behind the pew, in pseudo-3D. Drawn by ghoul-pew-draw.js's `field`; reads the rules in ghoul-pew.js, draws no random number (every scatter is a hash).
|
||||
//
|
||||
// THE PROJECTION (reusable for any "run into the screen" view, field units, the field being 96 wide and 54 high):
|
||||
// a point is (l, dz, h): `l` across the aisle in lanes (0 the middle lane, +1 the right one), `dz` how far down the
|
||||
// aisle ahead of the pew (negative once passed), `h` its height. With scale = NEAR / (NEAR + dz) it lands at
|
||||
// x = VPX + (l - camL) * LW * scale, y = HOR + (GY0 - HOR) * scale - h * HS * scale
|
||||
// so the horizon (dz infinite) is the vanishing point (VPX, HOR) and the pew (dz 0) stands at scale 1 on the floor line GY0.
|
||||
// The camera slides a little with the pew's lane (camL). The scene goes far to near in CELL-deep cells anchored to the world
|
||||
// (so they scroll), each with its floor tiles, wall, window and its light, pews and pillar with a rib over the aisle, then the
|
||||
// things standing in the cell; fog is the cell's alpha going to nothing over FADE_D. The art of the things is in `thing`.
|
||||
|
||||
import { BUMP_MS, KINDS, LOW_Y, V0, V_MAX, cuesOf, gargRise } from "./ghoul-pew.js";
|
||||
|
||||
const TAU = Math.PI * 2;
|
||||
const clamp = (x, lo, hi) => Math.min(hi, Math.max(lo, x));
|
||||
|
||||
export const VPX = 48;
|
||||
export const HOR = 19;
|
||||
export const GY0 = 46;
|
||||
export const NEAR = 26;
|
||||
export const LW = 14.5;
|
||||
export const HS = 2.1;
|
||||
export const CELL = 16;
|
||||
export const TILE = 8;
|
||||
export const SEE = 290;
|
||||
export const FADE_D = 250;
|
||||
export const BPM = 132;
|
||||
export const BEAT_MS = 60000 / BPM;
|
||||
export const ANSWER_COLORS = Object.freeze({ JUMP: "#5fe3ff", SLIDE: "#ffb02e", SWITCH: "#ff5a6a", SHOOT: "#ff8a4a" });
|
||||
const GLASS = Object.freeze(["216,50,60", "60,111,224", "240,180,58", "63,181,106", "166,90,216"]);
|
||||
const WALL_L = 5.8;
|
||||
|
||||
// A number in 0..1 from two integers, the same every time (no random draws).
|
||||
export const rnd = (a, b = 0) => {
|
||||
let h = Math.imul((a | 0) + 0x9e37, 0x85ebca6b) ^ Math.imul((b | 0) + 0x7f4a, 0xc2b2ae35);
|
||||
h ^= h >>> 13;
|
||||
h = Math.imul(h, 0x5bd1e995);
|
||||
h ^= h >>> 15;
|
||||
return (h >>> 0) / 4294967296;
|
||||
};
|
||||
const grad = (make, stops) => {
|
||||
const g = make ? make() : null;
|
||||
if (!g || typeof g.addColorStop !== "function") return stops[stops.length >> 1][1];
|
||||
for (const [o, col] of stops) g.addColorStop(o, col);
|
||||
return g;
|
||||
};
|
||||
const vgrad = (c, y0, y1, stops) => grad(c.createLinearGradient && (() => c.createLinearGradient(0, y0, 0, y1)), stops);
|
||||
const rgrad = (c, x, y, r, stops) => grad(c.createRadialGradient && (() => c.createRadialGradient(x, y, 0, x, y, r)), stops);
|
||||
const quad = (c, a, b, e, f) => {
|
||||
c.beginPath();
|
||||
c.moveTo(a[0], a[1]);
|
||||
c.lineTo(b[0], b[1]);
|
||||
c.lineTo(e[0], e[1]);
|
||||
c.lineTo(f[0], f[1]);
|
||||
c.closePath();
|
||||
};
|
||||
const seg = (c, a, b) => {
|
||||
c.beginPath();
|
||||
c.moveTo(a[0], a[1]);
|
||||
c.lineTo(b[0], b[1]);
|
||||
c.stroke();
|
||||
};
|
||||
const disc = (c, x, y, r) => {
|
||||
c.beginPath();
|
||||
c.arc(x, y, Math.max(0.01, r), 0, TAU);
|
||||
c.fill();
|
||||
};
|
||||
|
||||
// The beat: 1 on the organ's stroke, falling away.
|
||||
export const pulse = (clock) => Math.exp(-((clock % BEAT_MS) / BEAT_MS) * 4.5);
|
||||
// How much of a thing `dz` ahead the fog leaves.
|
||||
export const fog = (dz) => (dz < 120 ? 1 : clamp(1 - (dz - 120) / (FADE_D - 120), 0, 1));
|
||||
|
||||
export function worldArt(d) {
|
||||
const { label, circle } = d;
|
||||
let camL = 0;
|
||||
let FW = 96;
|
||||
let FH = 54;
|
||||
let clock = 0;
|
||||
let beat = 0;
|
||||
// Where (l, dz, h) lands: [x, y, scale].
|
||||
// (The view narrows a little as the ride speeds up: `near` falls from NEAR.)
|
||||
let near = NEAR;
|
||||
const sc = (dz) => near / (near + Math.max(dz, -near * 0.55));
|
||||
const P = (l, dz, h = 0) => {
|
||||
const s = sc(dz);
|
||||
return [VPX + (l - camL) * LW * s, HOR + (GY0 - HOR) * s - h * HS * s, s];
|
||||
};
|
||||
// A box from lateral l0..l1, near depth z0 to far z1, height h0..h1: the faces the camera sees.
|
||||
function box(ctx, l0, l1, z0, z1, h0, h1, c) {
|
||||
const eye = (GY0 - HOR) / HS;
|
||||
const n = [P(l0, z0, h0), P(l1, z0, h0), P(l1, z0, h1), P(l0, z0, h1)];
|
||||
if (c.side) {
|
||||
const left = l1 <= camL;
|
||||
const l = left ? l1 : l0;
|
||||
if (left || l0 >= camL) {
|
||||
quad(ctx, P(l, z0, h0), P(l, z1, h0), P(l, z1, h1), P(l, z0, h1));
|
||||
ctx.fillStyle = c.side;
|
||||
ctx.fill();
|
||||
}
|
||||
}
|
||||
if (c.top && h1 < eye) {
|
||||
quad(ctx, P(l0, z0, h1), P(l1, z0, h1), P(l1, z1, h1), P(l0, z1, h1));
|
||||
ctx.fillStyle = c.top;
|
||||
ctx.fill();
|
||||
}
|
||||
quad(ctx, n[0], n[1], n[2], n[3]);
|
||||
ctx.fillStyle = c.front;
|
||||
ctx.fill();
|
||||
return n;
|
||||
}
|
||||
// A wall-plane (or floor) quad between two corners at depths za..zb.
|
||||
const wall = (ctx, l, za, zb, h0, h1, fill) => {
|
||||
quad(ctx, P(l, za, h0), P(l, zb, h0), P(l, zb, h1), P(l, za, h1));
|
||||
ctx.fillStyle = fill;
|
||||
ctx.fill();
|
||||
};
|
||||
const floor = (ctx, l0, l1, za, zb, fill) => {
|
||||
quad(ctx, P(l0, za, 0), P(l1, za, 0), P(l1, zb, 0), P(l0, zb, 0));
|
||||
ctx.fillStyle = fill;
|
||||
ctx.fill();
|
||||
};
|
||||
const glow = (ctx, x, y, r, rgb, a) => {
|
||||
if (a <= 0.01 || r < 0.2) return;
|
||||
ctx.globalAlpha = a;
|
||||
ctx.fillStyle = rgrad(ctx, x, y, r, [[0, `rgba(${rgb},0.9)`], [0.4, `rgba(${rgb},0.35)`], [1, `rgba(${rgb},0)`]]);
|
||||
ctx.fillRect(x - r, y - r, r * 2, r * 2);
|
||||
};
|
||||
|
||||
/* ------------------------------------------------------------ the room */
|
||||
|
||||
// The vault, the far altar's glow and the floor's base.
|
||||
function backdrop(ctx) {
|
||||
ctx.fillStyle = vgrad(ctx, 0, HOR + 8, [[0, "#070a18"], [0.7, "#141a38"], [1, "#2a3052"]]);
|
||||
ctx.fillRect(0, 0, FW, FH);
|
||||
ctx.fillStyle = vgrad(ctx, HOR, FH, [[0, "#242a4a"], [0.5, "#161a30"], [1, "#0c0e1c"]]);
|
||||
ctx.fillRect(0, HOR, FW, FH - HOR);
|
||||
// The altar at the end of the nave: a rose window and its warm blaze.
|
||||
const a = 0.75 + 0.25 * beat;
|
||||
glow(ctx, VPX, HOR - 1, 34, "255,196,120", 0.55 * a);
|
||||
glow(ctx, VPX, HOR - 1, 14, "255,236,190", 0.9 * a);
|
||||
ctx.globalAlpha = 1;
|
||||
ctx.fillStyle = "#1b1a2c";
|
||||
ctx.fillRect(VPX - 3, HOR - 3.4, 6, 3.4);
|
||||
ctx.fillStyle = "#ffe7a8";
|
||||
ctx.fillRect(VPX - 0.25, HOR - 3.4, 0.5, 2.2);
|
||||
ctx.fillRect(VPX - 1, HOR - 2.7, 2, 0.4);
|
||||
ctx.fillStyle = `rgba(255,214,130,${0.7 + 0.3 * beat})`;
|
||||
for (const k of [-2.2, -1.2, 1.2, 2.2]) disc(ctx, VPX + k, HOR - 3.8, 0.35);
|
||||
}
|
||||
|
||||
function cell(ctx, you, c, j) {
|
||||
const z0 = j * CELL - you.x;
|
||||
const f = fog(z0);
|
||||
if (f <= 0.02) return;
|
||||
ctx.globalAlpha = f;
|
||||
const warm = "255,190,110";
|
||||
// Floor: two tiles, flagstone then carpet.
|
||||
for (let t = 0; t < 2; t++) {
|
||||
const za = z0 + t * TILE;
|
||||
const zb = za + TILE;
|
||||
const alt = (j * 2 + t) % 2;
|
||||
floor(ctx, -WALL_L, WALL_L, za, zb, alt ? "#2b3150" : "#252a46");
|
||||
floor(ctx, -2.65, 2.65, za, zb, alt ? "#3a4166" : "#333a5e");
|
||||
floor(ctx, -1.5, 1.5, za, zb, alt ? "#6b1c2e" : "#5c1727");
|
||||
// Tile joints and the carpet's gold edge and lane stitching.
|
||||
ctx.strokeStyle = "rgba(8,10,24,0.55)";
|
||||
ctx.lineWidth = 0.22 * sc(za);
|
||||
seg(ctx, P(-2.65, za), P(2.65, za));
|
||||
}
|
||||
ctx.strokeStyle = "rgba(231,180,76,0.75)";
|
||||
ctx.lineWidth = Math.max(0.12, 0.34 * sc(z0));
|
||||
seg(ctx, P(-1.5, z0), P(-1.5, z0 + CELL));
|
||||
seg(ctx, P(1.5, z0), P(1.5, z0 + CELL));
|
||||
ctx.strokeStyle = "rgba(231,180,76,0.32)";
|
||||
ctx.lineWidth = Math.max(0.1, 0.22 * sc(z0));
|
||||
for (const l of [-0.5, 0.5]) {
|
||||
ctx.beginPath();
|
||||
for (let k = 0; k < 4; k++) {
|
||||
const a = P(l, z0 + k * 4);
|
||||
const b = P(l, z0 + k * 4 + 2.6);
|
||||
ctx.moveTo(a[0], a[1]);
|
||||
ctx.lineTo(b[0], b[1]);
|
||||
}
|
||||
ctx.stroke();
|
||||
}
|
||||
for (const side of [-1, 1]) {
|
||||
const wl = side * WALL_L;
|
||||
// The wall, its wainscot and cornice, and the clerestory's lancet window with its light.
|
||||
wall(ctx, wl, z0, z0 + CELL, 0, 44, side < 0 ? "#222844" : "#262c4a");
|
||||
wall(ctx, wl, z0, z0 + CELL, 0, 5.5, "#161a30");
|
||||
box(ctx, side < 0 ? -WALL_L : WALL_L - 0.55, side < 0 ? -WALL_L + 0.55 : WALL_L, z0, z0 + CELL, 13.2, 14.4, { front: "#59629a", side: "#6f7ab0", top: "#8a96c4" });
|
||||
// The slim shaft that carries a rib up the wall.
|
||||
box(ctx, side < 0 ? -WALL_L : WALL_L - 0.5, side < 0 ? -WALL_L + 0.5 : WALL_L, z0, z0 + 2, 14.4, 32, { front: "#4b5480", side: "#6a76a6" });
|
||||
const gi = Math.abs(j * 3 + (side > 0 ? 1 : 0)) % GLASS.length;
|
||||
const rgb = GLASS[(gi + (side > 0 ? 2 : 0)) % GLASS.length];
|
||||
const lit = 0.6 + 0.35 * beat;
|
||||
const w = [
|
||||
[z0 + 4, 16.5],
|
||||
[z0 + 12, 16.5],
|
||||
[z0 + 12, 27],
|
||||
[z0 + 8, 32],
|
||||
[z0 + 4, 27],
|
||||
];
|
||||
ctx.beginPath();
|
||||
w.forEach(([z, h], i) => {
|
||||
const p = P(wl, z, h);
|
||||
if (i) ctx.lineTo(p[0], p[1]);
|
||||
else ctx.moveTo(p[0], p[1]);
|
||||
});
|
||||
ctx.closePath();
|
||||
ctx.fillStyle = "#0d1020";
|
||||
ctx.fill();
|
||||
ctx.fillStyle = `rgba(${rgb},${lit})`;
|
||||
ctx.fill();
|
||||
ctx.strokeStyle = "rgba(10,12,28,0.85)";
|
||||
ctx.lineWidth = Math.max(0.08, 0.26 * sc(z0 + 8));
|
||||
ctx.stroke();
|
||||
seg(ctx, P(wl, z0 + 8, 16.5), P(wl, z0 + 8, 32));
|
||||
seg(ctx, P(wl, z0 + 4, 22), P(wl, z0 + 12, 22));
|
||||
// God rays: a slanted shaft from the window to a patch on the floor, in the glass's color.
|
||||
ctx.globalCompositeOperation = "lighter";
|
||||
const patch = side * 0.8;
|
||||
quad(ctx, P(wl, z0 + 4, 16.5), P(wl, z0 + 12, 16.5), P(patch, z0 + 14, 0), P(patch + side * 2.1, z0 + 5, 0));
|
||||
ctx.fillStyle = `rgba(${rgb},${0.05 + 0.04 * beat})`;
|
||||
ctx.fill();
|
||||
quad(ctx, P(patch + side * 2.1, z0 + 5, 0), P(patch, z0 + 14, 0), P(patch - side * 0.9, z0 + 15, 0), P(patch + side * 1.3, z0 + 6, 0));
|
||||
ctx.fillStyle = `rgba(${rgb},${0.1 + 0.07 * beat})`;
|
||||
ctx.fill();
|
||||
ctx.globalCompositeOperation = "source-over";
|
||||
// The pews along the aisle: seat and back.
|
||||
const l0 = side < 0 ? -4.2 : 3.1;
|
||||
const l1 = side < 0 ? -3.1 : 4.2;
|
||||
for (let k = 0; k < 2; k++) {
|
||||
const za = z0 + 8 * k + 0.8;
|
||||
const tint = (j + k) % 2;
|
||||
box(ctx, l0, l1, za, za + 6.4, 0, 1.7, { front: tint ? "#4a2c1a" : "#42261a", side: tint ? "#6a4128" : "#5e3a24", top: "#8a5a36" });
|
||||
const b0 = side < 0 ? l0 : l1 - 0.35;
|
||||
const b1 = side < 0 ? l0 + 0.35 : l1;
|
||||
box(ctx, b0, b1, za, za + 6.4, 1.7, 4.2, { front: "#3a2114", side: "#5a361f", top: "#7a4c2c" });
|
||||
}
|
||||
// The pillar, with a sconce on it, and the rib across the vault.
|
||||
const pl = side * 4.75;
|
||||
const stone = { front: "#4b5480", side: "#6a76a6", top: "#7e8ab8" };
|
||||
const cap = { front: "#59629a", side: "#77839f", top: "#8a96bc" };
|
||||
box(ctx, pl - 0.55, pl + 0.55, z0, z0 + 2.4, 0, 13, stone);
|
||||
box(ctx, pl - 0.8, pl + 0.8, z0 - 0.2, z0 + 2.6, 0, 1.6, cap);
|
||||
box(ctx, pl - 0.8, pl + 0.8, z0 - 0.2, z0 + 2.6, 11.6, 13.2, cap);
|
||||
const sp = P(pl - side * 0.6, z0 + 0.3, 8);
|
||||
glow(ctx, sp[0], sp[1], 9 * sp[2] + 0.5, warm, 0.5 * f * (0.8 + 0.2 * beat));
|
||||
ctx.globalAlpha = f;
|
||||
ctx.fillStyle = "#ffd890";
|
||||
disc(ctx, sp[0], sp[1], 0.4 * sp[2] + 0.1);
|
||||
if (side > 0) {
|
||||
ctx.strokeStyle = "#59629a";
|
||||
ctx.lineWidth = Math.max(0.2, 1.0 * sc(z0));
|
||||
const a = P(-5.4, z0 + 1, 32);
|
||||
const b = P(5.4, z0 + 1, 32);
|
||||
const m = P(0, z0 + 1, 45);
|
||||
ctx.beginPath();
|
||||
ctx.moveTo(a[0], a[1]);
|
||||
ctx.quadraticCurveTo(m[0], m[1] - 2 * m[2] * HS, b[0], b[1]);
|
||||
ctx.stroke();
|
||||
}
|
||||
}
|
||||
ctx.globalAlpha = 1;
|
||||
}
|
||||
|
||||
/* ----------------------------------------------------------- the things */
|
||||
|
||||
// A telegraph glyph over a thing: a colored mark, with its word on the first few.
|
||||
function glyph(ctx, kind, answer, l, dz, h, words, extra) {
|
||||
if (dz > 130 || dz < -6) return;
|
||||
const p = P(l, dz, h);
|
||||
const s = p[2];
|
||||
const col = ANSWER_COLORS[answer];
|
||||
const a = clamp((130 - dz) / 50, 0, 1) * (dz < 0 ? clamp(1 + dz / 6, 0, 1) : 1) * (0.72 + 0.28 * Math.sin(clock / 130));
|
||||
if (a < 0.03) return;
|
||||
ctx.globalAlpha = a;
|
||||
ctx.strokeStyle = col;
|
||||
ctx.fillStyle = col;
|
||||
ctx.lineWidth = Math.max(0.3, 0.7 * s);
|
||||
ctx.lineCap = "round";
|
||||
ctx.lineJoin = "round";
|
||||
const r = Math.max(0.7, 2.3 * s);
|
||||
const x = p[0];
|
||||
const y = p[1];
|
||||
if (answer === "JUMP") {
|
||||
ctx.beginPath();
|
||||
ctx.moveTo(x - r, y + r * 0.5);
|
||||
ctx.lineTo(x, y - r * 0.6);
|
||||
ctx.lineTo(x + r, y + r * 0.5);
|
||||
ctx.moveTo(x - r, y + r * 1.5);
|
||||
ctx.lineTo(x, y + r * 0.4);
|
||||
ctx.lineTo(x + r, y + r * 1.5);
|
||||
ctx.stroke();
|
||||
} else if (answer === "SLIDE") {
|
||||
ctx.beginPath();
|
||||
ctx.moveTo(x - r, y - r * 0.5);
|
||||
ctx.lineTo(x, y + r * 0.6);
|
||||
ctx.lineTo(x + r, y - r * 0.5);
|
||||
ctx.moveTo(x - r, y - r * 1.5);
|
||||
ctx.lineTo(x, y - r * 0.4);
|
||||
ctx.lineTo(x + r, y - r * 1.5);
|
||||
ctx.stroke();
|
||||
} else if (answer === "SHOOT") {
|
||||
circle(ctx, x, y, r);
|
||||
ctx.stroke();
|
||||
ctx.beginPath();
|
||||
ctx.moveTo(x - r * 1.5, y);
|
||||
ctx.lineTo(x + r * 1.5, y);
|
||||
ctx.moveTo(x, y - r * 1.5);
|
||||
ctx.lineTo(x, y + r * 1.5);
|
||||
ctx.stroke();
|
||||
} else {
|
||||
// SWITCH: an arrow toward each free lane beside it.
|
||||
for (const dir of extra) {
|
||||
ctx.beginPath();
|
||||
ctx.moveTo(x + dir * r * 0.4, y - r * 0.9);
|
||||
ctx.lineTo(x + dir * r * 1.6, y);
|
||||
ctx.lineTo(x + dir * r * 0.4, y + r * 0.9);
|
||||
ctx.moveTo(x - dir * r * 0.6, y);
|
||||
ctx.lineTo(x + dir * r * 1.6, y);
|
||||
ctx.stroke();
|
||||
}
|
||||
}
|
||||
if (words && s > 0.2) label(ctx, answer === "SWITCH" ? "MOVE" : answer, x, y - r * 2.1, clamp(2.8 * s, 1.2, 2.6), col, "center", 20);
|
||||
ctx.globalAlpha = 1;
|
||||
}
|
||||
|
||||
const trim = (ctx, pts, col, w) => {
|
||||
ctx.strokeStyle = col;
|
||||
ctx.lineWidth = w;
|
||||
ctx.beginPath();
|
||||
pts.forEach((p, i) => (i ? ctx.lineTo(p[0], p[1]) : ctx.moveTo(p[0], p[1])));
|
||||
ctx.stroke();
|
||||
};
|
||||
|
||||
// Red and white hazard stripes across a block's foot: the "go round me" mark.
|
||||
function hazard(ctx, l0, l1, z, h) {
|
||||
const n = 6;
|
||||
for (let k = 0; k < n; k++) {
|
||||
const a = l0 + ((l1 - l0) * k) / n;
|
||||
const b = l0 + ((l1 - l0) * (k + 1)) / n;
|
||||
const lo = P(a, z, 0.2);
|
||||
const hi = P(b, z, h);
|
||||
ctx.fillStyle = k % 2 ? "#e8e0d0" : "#d6303c";
|
||||
ctx.beginPath();
|
||||
ctx.moveTo(lo[0], lo[1]);
|
||||
ctx.lineTo(P(b, z, 0.2)[0], P(b, z, 0.2)[1]);
|
||||
ctx.lineTo(hi[0], hi[1]);
|
||||
ctx.lineTo(P(a, z, h)[0], P(a, z, h)[1]);
|
||||
ctx.closePath();
|
||||
ctx.fill();
|
||||
}
|
||||
}
|
||||
|
||||
function thing(ctx, you, c, q, openSides, words) {
|
||||
const k = KINDS[q.kind];
|
||||
const z0 = q.x - you.x;
|
||||
const z1 = q.end - you.x;
|
||||
const f = fog(z0);
|
||||
if (f <= 0.02 || z1 < -9) return;
|
||||
const l = q.lane - 1;
|
||||
ctx.globalAlpha = f;
|
||||
const col = ANSWER_COLORS[k.answer];
|
||||
const wide = 0.42;
|
||||
let top = 0;
|
||||
// The mark on the floor ahead of it, in its answer's color.
|
||||
if (k.answer !== "SHOOT" || q.kind === "garg") {
|
||||
ctx.globalAlpha = f * 0.3;
|
||||
floor(ctx, l - 0.47, l + 0.47, z0 - 5, z0 - 3.2, col);
|
||||
ctx.globalAlpha = f;
|
||||
}
|
||||
switch (q.kind) {
|
||||
case "pillar": {
|
||||
box(ctx, l - wide, l + wide, z0, z1, 0, 9, { front: "#7b86b4", side: "#59638f", top: "#a0aad0" });
|
||||
hazard(ctx, l - wide, l + wide, z0, 1.6);
|
||||
ctx.strokeStyle = "rgba(30,36,70,0.5)";
|
||||
ctx.lineWidth = Math.max(0.1, 0.2 * sc(z0));
|
||||
for (const o of [-0.25, 0, 0.25]) seg(ctx, P(l + o, z0, 1.7), P(l + o, z0, 8.6));
|
||||
top = 11;
|
||||
break;
|
||||
}
|
||||
case "confessional": {
|
||||
box(ctx, l - wide, l + wide, z0, z1, 0, 8.5, { front: "#4a2a1a", side: "#6a3c26", top: "#8a5636" });
|
||||
const a = P(l - 0.3, z0, 6.4);
|
||||
const b = P(l + 0.3, z0, 3.4);
|
||||
ctx.fillStyle = "#14090a";
|
||||
ctx.fillRect(a[0], a[1], b[0] - a[0], b[1] - a[1]);
|
||||
ctx.strokeStyle = "#a07a46";
|
||||
ctx.lineWidth = Math.max(0.1, 0.22 * sc(z0));
|
||||
ctx.strokeRect(a[0], a[1], b[0] - a[0], b[1] - a[1]);
|
||||
hazard(ctx, l - wide, l + wide, z0, 1.6);
|
||||
top = 10.5;
|
||||
break;
|
||||
}
|
||||
case "pewx": {
|
||||
box(ctx, l - wide - 0.03, l + wide + 0.03, z0, z1, 0, 2.6, { front: "#4a2c1a", side: "#6a4128", top: "#8a5a36" });
|
||||
box(ctx, l - wide - 0.03, l + wide + 0.03, z0 + 0.2, z1, 2.6, 5.6, { front: "#3a2114", side: "#5a361f", top: "#7a4c2c" });
|
||||
hazard(ctx, l - wide, l + wide, z0, 1.4);
|
||||
top = 7.5;
|
||||
break;
|
||||
}
|
||||
case "kneeler": {
|
||||
box(ctx, l - wide, l + wide, z0, z1, 0, 1.3, { front: "#3a2114", side: "#5a361f", top: "#7a4c2c" });
|
||||
box(ctx, l - wide + 0.04, l + wide - 0.04, z0, z1, 1.3, k.h, { front: "#a8283c", side: "#7c1a2c", top: "#d04a5c" });
|
||||
trim(ctx, [P(l - wide, z0, k.h), P(l + wide, z0, k.h)], col, Math.max(0.2, 0.55 * sc(z0)));
|
||||
top = k.h + 2.4;
|
||||
break;
|
||||
}
|
||||
case "stand": {
|
||||
box(ctx, l - 0.28, l + 0.28, z0, z1, 0, 0.9, { front: "#2a2a38", side: "#3c3c50", top: "#58586e" });
|
||||
ctx.strokeStyle = "#2c2c3c";
|
||||
ctx.lineWidth = Math.max(0.2, 0.5 * sc(z0));
|
||||
seg(ctx, P(l, z0 + 1, 0.8), P(l, z0 + 1, 3));
|
||||
box(ctx, l - 0.4, l + 0.4, z0, z1, 2.8, 3.4, { front: "#6a6a82", side: "#4a4a60", top: "#9a9ab4" });
|
||||
for (const o of [-0.26, 0, 0.26]) {
|
||||
const p = P(l + o, z0 + 1, 4.2);
|
||||
glow(ctx, p[0], p[1], 3.8 * p[2] + 0.3, "255,190,100", 0.7 * f);
|
||||
ctx.globalAlpha = f;
|
||||
ctx.fillStyle = "#fff0b8";
|
||||
ctx.beginPath();
|
||||
ctx.ellipse(p[0], p[1], Math.max(0.1, 0.4 * p[2]), Math.max(0.12, 0.8 * p[2]), 0, 0, TAU);
|
||||
ctx.fill();
|
||||
ctx.fillStyle = "#f4efe0";
|
||||
const w = P(l + o, z0 + 1, 3.4);
|
||||
ctx.fillRect(w[0] - 0.25 * w[2], w[1], 0.5 * w[2], Math.max(0.2, p[1] - w[1]) * -1);
|
||||
}
|
||||
trim(ctx, [P(l - 0.4, z0, 3.4), P(l + 0.4, z0, 3.4)], col, Math.max(0.2, 0.55 * sc(z0)));
|
||||
top = 6.4;
|
||||
break;
|
||||
}
|
||||
case "cracks":
|
||||
case "hatch": {
|
||||
const hatch = q.kind === "hatch";
|
||||
floor(ctx, l - 0.46, l + 0.46, z0, z1, hatch ? "#05060c" : "#4a5074");
|
||||
if (hatch) {
|
||||
box(ctx, l - 0.46, l + 0.46, z1 - 0.7, z1, 0, 2.3, { front: "#6a7090", side: "#4a5074", top: "#8a90b0" });
|
||||
ctx.globalCompositeOperation = "lighter";
|
||||
floor(ctx, l - 0.3, l + 0.3, z0 + 1, z1 - 1, "rgba(120,255,160,0.1)");
|
||||
ctx.globalCompositeOperation = "source-over";
|
||||
} else {
|
||||
ctx.strokeStyle = "#12142a";
|
||||
ctx.lineWidth = Math.max(0.12, 0.34 * sc(z0));
|
||||
for (let m = 0; m < 3; m++) {
|
||||
ctx.beginPath();
|
||||
for (let n = 0; n <= 6; n++) {
|
||||
const pp = P(l - 0.4 + m * 0.4 + (n % 2 ? 0.1 : -0.1), z0 + (n * (z1 - z0)) / 6, 0.05);
|
||||
if (n) ctx.lineTo(pp[0], pp[1]);
|
||||
else ctx.moveTo(pp[0], pp[1]);
|
||||
}
|
||||
ctx.stroke();
|
||||
}
|
||||
box(ctx, l - 0.4, l - 0.2, z0 + 1.2, z0 + 2.4, 0, 0.8, { front: "#7a82a8", side: "#5a628a", top: "#9aa2c8" });
|
||||
box(ctx, l + 0.1, l + 0.3, z1 - 2.6, z1 - 1.4, 0, 0.7, { front: "#7a82a8", side: "#5a628a", top: "#9aa2c8" });
|
||||
}
|
||||
trim(ctx, [P(l - 0.46, z0, 0), P(l + 0.46, z0, 0)], col, Math.max(0.25, 0.7 * sc(z0)));
|
||||
trim(ctx, [P(l - 0.46, z1, 0), P(l + 0.46, z1, 0)], col, Math.max(0.2, 0.5 * sc(z1)));
|
||||
top = 3.4;
|
||||
break;
|
||||
}
|
||||
case "censer": {
|
||||
const sway = Math.sin(clock / 380 + q.i * 1.7) * 0.22;
|
||||
const hang = P(l, z0 + 1, 34);
|
||||
const ball = P(l + sway, z0 + 1, LOW_Y + 1.3);
|
||||
ctx.strokeStyle = "#8a7a52";
|
||||
ctx.lineWidth = Math.max(0.15, 0.4 * ball[2]);
|
||||
seg(ctx, hang, ball);
|
||||
ctx.fillStyle = "#c79a3a";
|
||||
disc(ctx, ball[0], ball[1], 1.6 * HS * ball[2] * 0.5 + 0.2);
|
||||
ctx.fillStyle = "#6a4a14";
|
||||
disc(ctx, ball[0], ball[1] + 0.2 * ball[2], 0.7 * HS * ball[2] * 0.5);
|
||||
ctx.globalAlpha = f * 0.35;
|
||||
ctx.fillStyle = "#cfd2e6";
|
||||
for (let m = 0; m < 3; m++) disc(ctx, ball[0] + Math.sin(clock / 260 + m * 2) * 0.6 * ball[2], ball[1] - (1.6 + m * 1.4) * ball[2] * HS * 0.5, (0.5 + m * 0.3) * ball[2]);
|
||||
ctx.globalAlpha = f;
|
||||
trim(ctx, [P(l - 0.4, z0, LOW_Y), P(l + 0.4, z0, LOW_Y)], col, Math.max(0.2, 0.55 * sc(z0)));
|
||||
top = 8;
|
||||
break;
|
||||
}
|
||||
case "banner": {
|
||||
const a = P(l - 0.44, z0, 15);
|
||||
const b = P(l + 0.44, z0, 15);
|
||||
const lo0 = P(l - 0.44, z0, LOW_Y);
|
||||
const lo1 = P(l + 0.44, z0, LOW_Y);
|
||||
const tail = P(l, z0, LOW_Y - 0.9);
|
||||
ctx.fillStyle = "#5c1a6a";
|
||||
ctx.beginPath();
|
||||
ctx.moveTo(a[0], a[1]);
|
||||
ctx.lineTo(b[0], b[1]);
|
||||
ctx.lineTo(lo1[0], lo1[1]);
|
||||
ctx.lineTo(tail[0], tail[1]);
|
||||
ctx.lineTo(lo0[0], lo0[1]);
|
||||
ctx.closePath();
|
||||
ctx.fill();
|
||||
ctx.strokeStyle = "#e0b04a";
|
||||
ctx.lineWidth = Math.max(0.12, 0.3 * sc(z0));
|
||||
ctx.stroke();
|
||||
const cx = P(l, z0, 8.5);
|
||||
ctx.strokeStyle = "#f0d078";
|
||||
ctx.lineWidth = Math.max(0.2, 0.6 * cx[2]);
|
||||
seg(ctx, P(l, z0, 11), P(l, z0, 5.6));
|
||||
seg(ctx, P(l - 0.22, z0, 9.2), P(l + 0.22, z0, 9.2));
|
||||
trim(ctx, [lo0, tail, lo1], col, Math.max(0.2, 0.6 * sc(z0)));
|
||||
top = 17;
|
||||
break;
|
||||
}
|
||||
case "beam": {
|
||||
for (const o of [-0.4, 0.4]) {
|
||||
ctx.strokeStyle = "#8a7a52";
|
||||
ctx.lineWidth = Math.max(0.12, 0.3 * sc(z0));
|
||||
seg(ctx, P(l + o, z0 + 1, 5.2), P(l + o, z0 + 1, 34));
|
||||
}
|
||||
box(ctx, l - 0.5, l + 0.5, z0, z1, LOW_Y, 5.2, { front: "#6a4128", side: "#4a2c1a", top: "#8a5a36" });
|
||||
trim(ctx, [P(l - 0.5, z0, LOW_Y), P(l + 0.5, z0, LOW_Y)], col, Math.max(0.25, 0.7 * sc(z0)));
|
||||
top = 8;
|
||||
break;
|
||||
}
|
||||
case "garg":
|
||||
gargoyle(ctx, you, c, q, z0, f, col);
|
||||
top = ["stun", "broken"].includes(c.gargs[q.i].state) ? 0 : (c.gargs[q.i].state === "perch" || c.gargs[q.i].state === "warn" ? 17 : 11);
|
||||
break;
|
||||
case "bell":
|
||||
bell(ctx, c, q, z0, f);
|
||||
top = 0;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
// Its glyph, for what to do about it.
|
||||
if (top) {
|
||||
const free = [];
|
||||
if (k.answer === "SWITCH") for (const dir of [-1, 1]) if (q.lane + dir >= 0 && q.lane + dir <= 2 && !openSides.some((o) => o === q.lane + dir)) free.push(dir);
|
||||
glyph(ctx, q.kind, k.answer, l, z0 + 1, top, words, free);
|
||||
}
|
||||
ctx.globalAlpha = 1;
|
||||
}
|
||||
|
||||
// A gargoyle: perched in the arch above its lane, shuddering, dropping, standing, dazed or broken.
|
||||
function gargoyle(ctx, you, c, q, z0, f, col) {
|
||||
const g = c.gargs[q.i];
|
||||
const l = q.lane - 1;
|
||||
const rise = gargRise(g);
|
||||
const shake = g.state === "warn" ? Math.sin(clock / 22) * 0.18 : 0;
|
||||
const p = P(l + shake, z0 + 1.5, rise * 1.2 + (g.state === "perch" || g.state === "warn" ? 11 : 0));
|
||||
const s = p[2] * HS * 1.4;
|
||||
const x = p[0];
|
||||
const y = p[1];
|
||||
if (g.state === "broken") {
|
||||
ctx.fillStyle = "#59638f";
|
||||
for (const [ox, oy, r] of [[-0.6, 0, 0.5], [0.4, 0.05, 0.6], [0, -0.3, 0.4]]) disc(ctx, x + ox * s * 1.3, y + oy * s, r * s * 0.8);
|
||||
return;
|
||||
}
|
||||
// The shadow it will fall on.
|
||||
if (g.state === "perch" || g.state === "warn" || g.state === "drop") {
|
||||
const fl = P(l, z0 + 1.5, 0);
|
||||
ctx.globalAlpha = f * (g.state === "perch" ? 0.18 : 0.45);
|
||||
ctx.fillStyle = col;
|
||||
ctx.beginPath();
|
||||
ctx.ellipse(fl[0], fl[1], 4.4 * fl[2], 1.3 * fl[2], 0, 0, TAU);
|
||||
ctx.fill();
|
||||
ctx.globalAlpha = f;
|
||||
}
|
||||
const dazed = g.state === "stun";
|
||||
ctx.fillStyle = dazed ? "#7a84b0" : "#6f7aa8";
|
||||
ctx.strokeStyle = "#232a4a";
|
||||
ctx.lineWidth = Math.max(0.12, 0.3 * s);
|
||||
// Wings.
|
||||
for (const sd of [-1, 1]) {
|
||||
ctx.beginPath();
|
||||
ctx.moveTo(x + sd * s * 0.9, y - s * 2.6);
|
||||
ctx.lineTo(x + sd * s * 3.5, y - s * (dazed ? 2.2 : 4.4));
|
||||
ctx.lineTo(x + sd * s * 3.0, y - s * 1.0);
|
||||
ctx.lineTo(x + sd * s * 1.0, y - s * 1.2);
|
||||
ctx.closePath();
|
||||
ctx.fill();
|
||||
ctx.stroke();
|
||||
}
|
||||
// Body, head and horns.
|
||||
roundish(ctx, x, y - s * 1.6, s * 1.6, s * 2.1);
|
||||
ctx.fillStyle = dazed ? "#8a94c0" : "#8490c0";
|
||||
disc(ctx, x, y - s * 3.5, s * 1.15);
|
||||
ctx.fillStyle = "#59638f";
|
||||
for (const sd of [-1, 1]) {
|
||||
ctx.beginPath();
|
||||
ctx.moveTo(x + sd * s * 0.6, y - s * 4.3);
|
||||
ctx.lineTo(x + sd * s * 1.1, y - s * 5.6);
|
||||
ctx.lineTo(x + sd * s * 1.2, y - s * 4.1);
|
||||
ctx.fill();
|
||||
}
|
||||
const eye = dazed ? "#9ab0ff" : g.state === "perch" ? "#80402c" : "#ff4a30";
|
||||
ctx.fillStyle = eye;
|
||||
for (const sd of [-1, 1]) disc(ctx, x + sd * s * 0.45, y - s * 3.6, s * 0.22);
|
||||
if (!dazed && (g.state === "stand" || g.state === "drop")) {
|
||||
glow(ctx, x, y - s * 3.5, 4.5 * s, "255,70,40", 0.45 * f);
|
||||
ctx.globalAlpha = f;
|
||||
if (g.hp < 2) {
|
||||
ctx.strokeStyle = "#10142a";
|
||||
ctx.lineWidth = Math.max(0.1, 0.25 * s);
|
||||
seg(ctx, [x - s * 0.5, y - s * 2.6], [x + s * 0.3, y - s * 0.9]);
|
||||
}
|
||||
}
|
||||
if (dazed) {
|
||||
ctx.fillStyle = "#ffe48a";
|
||||
for (let m = 0; m < 3; m++) disc(ctx, x + Math.cos(clock / 200 + m * 2.1) * s * 1.6, y - s * 5.2 + Math.sin(clock / 200 + m * 2.1) * s * 0.4, s * 0.28);
|
||||
}
|
||||
}
|
||||
function roundish(ctx, x, y, rx, ry) {
|
||||
ctx.beginPath();
|
||||
ctx.ellipse(x, y, Math.max(0.05, rx), Math.max(0.05, ry), 0, 0, TAU);
|
||||
ctx.fill();
|
||||
ctx.stroke();
|
||||
}
|
||||
|
||||
// A bell rope: from the vault down to a tassel, the bell up in the dark; rung, it swings.
|
||||
function bell(ctx, c, q, z0, f) {
|
||||
const rung = c.bells[q.i];
|
||||
const l = q.lane - 1;
|
||||
const sw = rung ? Math.sin(clock / 90) * 0.18 : 0;
|
||||
const top = P(l, z0, 34);
|
||||
const bot = P(l + sw, z0, 5.6);
|
||||
ctx.strokeStyle = "#b9a374";
|
||||
ctx.lineWidth = Math.max(0.3, 1.0 * bot[2]);
|
||||
seg(ctx, top, bot);
|
||||
ctx.fillStyle = "#d9b45a";
|
||||
disc(ctx, bot[0], bot[1], Math.max(0.4, 0.9 * bot[2]));
|
||||
const b = P(l + sw * 2, z0, 14);
|
||||
ctx.fillStyle = rung ? "#ffe9a0" : "#c79a3a";
|
||||
ctx.beginPath();
|
||||
ctx.moveTo(b[0] - 1.5 * b[2] * HS * 0.8, b[1] + 1.2 * b[2] * HS * 0.8);
|
||||
ctx.quadraticCurveTo(b[0] - 1.2 * b[2] * HS * 0.8, b[1] - 1.8 * b[2] * HS * 0.8, b[0], b[1] - 1.8 * b[2] * HS * 0.8);
|
||||
ctx.quadraticCurveTo(b[0] + 1.2 * b[2] * HS * 0.8, b[1] - 1.8 * b[2] * HS * 0.8, b[0] + 1.5 * b[2] * HS * 0.8, b[1] + 1.2 * b[2] * HS * 0.8);
|
||||
ctx.closePath();
|
||||
ctx.fill();
|
||||
if (rung) glow(ctx, b[0], b[1], 7 * b[2] + 1, "255,226,140", 0.6 * f);
|
||||
ctx.globalAlpha = f;
|
||||
trim(ctx, [P(l - 0.3, z0, 6), P(l + 0.3, z0, 6)], ANSWER_COLORS.SHOOT, 0.3);
|
||||
if (!rung) glyph(ctx, "bell", "SHOOT", l, z0, 10.5, true, []);
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------- souls */
|
||||
|
||||
// A wax soul: a golden candle flame with a white core; a halo, a gold ring that draws souls in.
|
||||
function soul(ctx, c, you, s, i) {
|
||||
const [sx, lane, h, type] = s;
|
||||
let dz = sx - you.x;
|
||||
const f = fog(dz);
|
||||
if (f <= 0.02 || dz < -7) return;
|
||||
let l = lane - 1;
|
||||
let hh = h;
|
||||
if (c.magnet > 0 && dz < 26) {
|
||||
const k = clamp(1 - dz / 26, 0, 1) ** 2;
|
||||
l += (c.lane - 1 - l) * k;
|
||||
hh += (c.h + 2.2 - hh) * k;
|
||||
dz *= 1 - k * 0.5;
|
||||
}
|
||||
const p = P(l, dz, hh + Math.sin(clock / 260 + i) * 0.25);
|
||||
const r = p[2] * HS;
|
||||
ctx.globalAlpha = f;
|
||||
if (type === 1) {
|
||||
glow(ctx, p[0], p[1], 6 * r + 1, "255,220,120", 0.7 * f);
|
||||
ctx.globalAlpha = f;
|
||||
ctx.strokeStyle = "#ffd75a";
|
||||
ctx.lineWidth = Math.max(0.2, 0.55 * r);
|
||||
ctx.beginPath();
|
||||
ctx.ellipse(p[0], p[1], 1.5 * r, 0.55 * r, 0, 0, TAU);
|
||||
ctx.stroke();
|
||||
ctx.beginPath();
|
||||
ctx.ellipse(p[0], p[1] - 0.2 * r, 1.1 * r, 0.4 * r, 0, 0, TAU);
|
||||
ctx.stroke();
|
||||
ctx.fillStyle = "#fff4c0";
|
||||
disc(ctx, p[0], p[1] + 1.1 * r, 0.55 * r);
|
||||
return;
|
||||
}
|
||||
glow(ctx, p[0], p[1], 2.8 * r + 0.4, "255,190,70", 0.55 * f);
|
||||
ctx.globalAlpha = f;
|
||||
const w = Math.max(0.18, 0.55 * r);
|
||||
ctx.fillStyle = "#ffbc3a";
|
||||
ctx.beginPath();
|
||||
ctx.moveTo(p[0], p[1] - 1.3 * r);
|
||||
ctx.quadraticCurveTo(p[0] + w * 1.5, p[1] + 0.1 * r, p[0], p[1] + 0.9 * r);
|
||||
ctx.quadraticCurveTo(p[0] - w * 1.5, p[1] + 0.1 * r, p[0], p[1] - 1.3 * r);
|
||||
ctx.fill();
|
||||
ctx.fillStyle = "#fff6d0";
|
||||
ctx.beginPath();
|
||||
ctx.ellipse(p[0], p[1] + 0.25 * r, w * 0.55, 0.55 * r, 0, 0, TAU);
|
||||
ctx.fill();
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------- the pew */
|
||||
|
||||
// A bolt flying down its lane.
|
||||
function bolt(ctx, you, s) {
|
||||
const dz = s.x - you.x;
|
||||
if (dz < -4 || dz > 120) return;
|
||||
const lane = s.lane === undefined ? 1 : s.lane;
|
||||
const p = P(lane - 1, dz, 2.4);
|
||||
const q = P(lane - 1, dz - 6, 2.4);
|
||||
ctx.globalAlpha = 1;
|
||||
ctx.strokeStyle = "rgba(255,244,170,0.55)";
|
||||
ctx.lineWidth = Math.max(0.3, 1.1 * p[2]);
|
||||
ctx.lineCap = "round";
|
||||
seg(ctx, p, q);
|
||||
glow(ctx, p[0], p[1], 4 * p[2] + 0.5, "255,240,150", 0.8);
|
||||
ctx.globalAlpha = 1;
|
||||
ctx.fillStyle = "#fffbe0";
|
||||
disc(ctx, p[0], p[1], Math.max(0.3, 0.7 * p[2]));
|
||||
}
|
||||
|
||||
// The pew and YOU on it from behind: runners with sparks, the backrest ahead, the seat, the rear panel, then YOU,
|
||||
// a little blue square with stick arms, the flashlight out in front and its beam down the aisle.
|
||||
function hero(ctx, v, you, c) {
|
||||
const lean = c.lean;
|
||||
const hx = P(c.lane - 1, 0, 0)[0];
|
||||
const lift = c.h * HS;
|
||||
const gy = GY0;
|
||||
const slide = c.slide > 0 && c.h <= 0;
|
||||
const speedK = clamp((c.v - V0) / (V_MAX - V0), 0, 1);
|
||||
const bob = c.h > 0 ? 0 : Math.sin(clock / 55) * 0.18 * (0.5 + speedK);
|
||||
const bump = c.bump > 0 ? Math.sin(clock / 18) * 0.5 * (c.bump / BUMP_MS) : 0;
|
||||
const x = hx + bump;
|
||||
const y = gy - lift + bob;
|
||||
const blink = you.safeMs > 0 && Math.floor(v.clock / 90) % 2 === 0;
|
||||
// Shadow on the floor.
|
||||
ctx.globalAlpha = 0.4 / (1 + c.h * 0.12);
|
||||
ctx.fillStyle = "#04050c";
|
||||
ctx.beginPath();
|
||||
ctx.ellipse(hx, gy + 0.9, 6.2 / (1 + c.h * 0.05), 1.6, 0, 0, TAU);
|
||||
ctx.fill();
|
||||
ctx.globalAlpha = blink ? 0.45 : 1;
|
||||
ctx.save();
|
||||
ctx.translate(x, y);
|
||||
ctx.rotate(lean * 0.17 + (c.h > 0 ? clamp(c.vh / 260, -0.1, 0.1) : 0));
|
||||
// Beam of the flashlight, drawn first so everything of the pew is over it.
|
||||
ctx.globalCompositeOperation = "lighter";
|
||||
const beam = ctx.createLinearGradient ? ctx.createLinearGradient(0, -7, 0, -26) : null;
|
||||
if (beam && beam.addColorStop) {
|
||||
beam.addColorStop(0, "rgba(255,236,170,0.5)");
|
||||
beam.addColorStop(1, "rgba(255,236,170,0)");
|
||||
}
|
||||
ctx.fillStyle = beam || "rgba(255,236,170,0.2)";
|
||||
ctx.beginPath();
|
||||
ctx.moveTo(3.4, -7);
|
||||
ctx.lineTo(1.5, -26);
|
||||
ctx.lineTo(13, -26);
|
||||
ctx.closePath();
|
||||
ctx.fill();
|
||||
ctx.globalCompositeOperation = "source-over";
|
||||
// Runners and sparks.
|
||||
ctx.fillStyle = "#2a1a10";
|
||||
ctx.fillRect(-4.7, -0.9, 9.4, 0.9);
|
||||
if (c.h <= 0) {
|
||||
ctx.fillStyle = "#ffd36a";
|
||||
for (let k = 0; k < 2 + Math.floor(speedK * 5); k++) {
|
||||
const t = (clock / 120 + k * 0.37) % 1;
|
||||
const sx = (k % 2 ? 1 : -1) * (3.5 + rnd(k, 3) * 1.2);
|
||||
disc(ctx, sx + (k % 2 ? 1 : -1) * t * 2, -0.3 - t * 2.2, 0.28 * (1 - t));
|
||||
}
|
||||
}
|
||||
const sq = slide ? 0.55 : 1;
|
||||
// Backrest (ahead of him, seen from behind), the seat, the rear panel.
|
||||
ctx.fillStyle = "#3a2114";
|
||||
ctx.fillRect(-5.2, -8.2 * sq - 1, 10.4, 3.1 * sq);
|
||||
ctx.fillStyle = "#7a4c2c";
|
||||
ctx.fillRect(-5.2, -8.2 * sq - 1, 10.4, 0.6);
|
||||
ctx.fillStyle = "#6a4128";
|
||||
ctx.fillRect(-4.6, -3.2, 9.2, 0.8);
|
||||
ctx.fillStyle = "#4a2c1a";
|
||||
ctx.beginPath();
|
||||
ctx.moveTo(-4.8, -0.9);
|
||||
ctx.lineTo(4.8, -0.9);
|
||||
ctx.lineTo(4.8, -3.1);
|
||||
ctx.quadraticCurveTo(0, -4.2, -4.8, -3.1);
|
||||
ctx.closePath();
|
||||
ctx.fill();
|
||||
ctx.strokeStyle = "#8a5a36";
|
||||
ctx.lineWidth = 0.22;
|
||||
ctx.stroke();
|
||||
ctx.fillStyle = "#c9a24a";
|
||||
disc(ctx, 0, -2.1, 0.45);
|
||||
// YOU: legs, arms, the blue square back, the flashlight in the right hand.
|
||||
const ink = (v.colors && v.colors.ink) || "#1d1a17";
|
||||
const body = (v.colors && v.colors.you) || "#206cc3";
|
||||
ctx.save();
|
||||
ctx.translate(0, -3.2);
|
||||
ctx.scale(1, sq);
|
||||
ctx.strokeStyle = ink;
|
||||
ctx.lineWidth = 0.4;
|
||||
ctx.lineCap = "round";
|
||||
const step = Math.sin(clock / 70) * 0.25 * (c.h > 0 ? 0 : 1);
|
||||
seg(ctx, [-1.1, -1.2], [-1.4 + step, 0]);
|
||||
seg(ctx, [1.1, -1.2], [1.4 - step, 0]);
|
||||
ctx.fillStyle = ink;
|
||||
ctx.beginPath();
|
||||
ctx.ellipse(-1.5 + step, 0.1, 0.8, 0.4, 0, 0, TAU);
|
||||
ctx.ellipse(1.5 - step, 0.1, 0.8, 0.4, 0, 0, TAU);
|
||||
ctx.fill();
|
||||
ctx.fillStyle = body;
|
||||
ctx.strokeStyle = ink;
|
||||
ctx.lineWidth = 0.35;
|
||||
ctx.fillRect(-3, -7.6, 6, 6.4);
|
||||
ctx.strokeRect(-3, -7.6, 6, 6.4);
|
||||
ctx.fillStyle = "rgba(255,255,255,0.18)";
|
||||
ctx.fillRect(-2.6, -7.2, 1.4, 5.6);
|
||||
ctx.fillStyle = ink;
|
||||
ctx.fillRect(-1.2, -9.0, 2.4, 1.4);
|
||||
// Arms out ahead, bracing, the light in the right hand.
|
||||
ctx.lineWidth = 0.45;
|
||||
seg(ctx, [-3, -5.6], [-4.3, -7.4 + step]);
|
||||
seg(ctx, [3, -5.6], [4.2, -8.6]);
|
||||
ctx.fillStyle = "#e8e4d4";
|
||||
ctx.fillRect(3.4, -10.2, 1.6, 2);
|
||||
ctx.fillStyle = "#fff4c0";
|
||||
disc(ctx, 4.2, -10.4, 0.8);
|
||||
ctx.restore();
|
||||
ctx.restore();
|
||||
ctx.globalAlpha = 1;
|
||||
// Garlic and the halo's ring around him.
|
||||
if (c.magnet > 0) {
|
||||
ctx.strokeStyle = "rgba(255,215,90,0.8)";
|
||||
ctx.lineWidth = 0.35;
|
||||
ctx.beginPath();
|
||||
ctx.ellipse(hx, y - 5, 8 + Math.sin(clock / 120) * 0.6, 7, 0, 0, TAU);
|
||||
ctx.stroke();
|
||||
}
|
||||
}
|
||||
|
||||
/* ----------------------------------------------------------- the frame */
|
||||
|
||||
// Dust in the shafts, and the speed: streaks and a vignette that rise with the ride's pace.
|
||||
function air(ctx, you, c) {
|
||||
ctx.fillStyle = "#ffdca0";
|
||||
for (let i = 0; i < 46; i++) {
|
||||
const zz = ((rnd(i, 1) * SEE - you.x * 0.9) % SEE + SEE) % SEE;
|
||||
const l = (rnd(i, 2) - 0.5) * 8;
|
||||
const h = 1 + rnd(i, 3) * 20;
|
||||
const p = P(l + Math.sin(clock / 1700 + i) * 0.2, zz, h + Math.cos(clock / 1300 + i * 2) * 0.3);
|
||||
ctx.globalAlpha = fog(zz) * (0.1 + 0.3 * rnd(i, 4)) * (0.6 + 0.4 * beat);
|
||||
disc(ctx, p[0], p[1], Math.max(0.08, 0.28 * p[2]));
|
||||
}
|
||||
const k = clamp((c.v - V0) / (V_MAX - V0), 0, 1);
|
||||
ctx.globalAlpha = 1;
|
||||
// Streaks from the vanishing point, longer and brighter the faster it goes.
|
||||
ctx.lineCap = "round";
|
||||
for (let i = 0; i < 26; i++) {
|
||||
const a = rnd(i, 7) * TAU;
|
||||
const run = (you.x * 0.02 * (0.5 + rnd(i, 8)) + rnd(i, 9)) % 1;
|
||||
const r0 = 14 + run * run * 66;
|
||||
const r1 = r0 + 3 + k * 22 * run;
|
||||
ctx.strokeStyle = `rgba(200,220,255,${(0.1 + 0.6 * k) * run})`;
|
||||
ctx.lineWidth = 0.15 + 0.5 * run;
|
||||
ctx.beginPath();
|
||||
ctx.moveTo(VPX + Math.cos(a) * r0 * 1.5, HOR + 8 + Math.sin(a) * r0 * 0.75);
|
||||
ctx.lineTo(VPX + Math.cos(a) * r1 * 1.5, HOR + 8 + Math.sin(a) * r1 * 0.75);
|
||||
ctx.stroke();
|
||||
}
|
||||
ctx.fillStyle = rgrad(ctx, VPX, 30, 76, [[0.45, "rgba(3,4,14,0)"], [1, `rgba(3,4,14,${0.3 + 0.4 * k})`]]);
|
||||
ctx.fillRect(0, 0, FW, FH);
|
||||
}
|
||||
|
||||
function paint(ctx, v) {
|
||||
const { round } = v;
|
||||
const c = round.runner;
|
||||
const you = round.you;
|
||||
FW = v.g.FIELD_W;
|
||||
FH = v.g.FIELD_H;
|
||||
clock = v.fx && typeof v.fx.clock === "number" ? v.fx.clock : v.clock || 0;
|
||||
beat = pulse(clock);
|
||||
camL = (c.lane - 1) * 0.55;
|
||||
near = NEAR - 6 * clamp((c.v - V0) / (V_MAX - V0), 0, 1);
|
||||
const R = round.spec.ride;
|
||||
backdrop(ctx);
|
||||
const j1 = Math.floor((you.x + SEE) / CELL);
|
||||
const j0 = Math.floor((you.x - 10) / CELL);
|
||||
const cues = cuesOf(R);
|
||||
const flank = new Map();
|
||||
// Which lanes of a block's row stay open, for the arrows.
|
||||
for (const q of cues) {
|
||||
if (KINDS[q.kind].answer !== "SWITCH") continue;
|
||||
const key = Math.round(q.x);
|
||||
if (!flank.has(key)) flank.set(key, []);
|
||||
flank.get(key).push(q.lane);
|
||||
}
|
||||
// The things and souls bucketed by the cell their near end stands in, drawn far to near.
|
||||
const lo = (list, get, x) => {
|
||||
let a = 0;
|
||||
let b = list.length;
|
||||
while (a < b) {
|
||||
const m = (a + b) >> 1;
|
||||
if (get(list[m]) < x) a = m + 1;
|
||||
else b = m;
|
||||
}
|
||||
return a;
|
||||
};
|
||||
const first = lo(cues, (q) => q.x, you.x - 12);
|
||||
const sFirst = lo(R.souls, (s) => s[0], you.x - 8);
|
||||
const after = [];
|
||||
// The cues to draw, in order of depth, with the nearest (already passed) after the hero.
|
||||
const draw = [];
|
||||
for (let i = first; i < cues.length && cues[i].x < you.x + SEE; i++) draw.push(cues[i]);
|
||||
for (let i = Math.max(0, first - 8); i < first; i++) if (cues[i].end > you.x - 10) draw.push(cues[i]);
|
||||
draw.sort((a, b) => b.x - a.x);
|
||||
// Count the "words" in order of approach, nearest first.
|
||||
const order = {};
|
||||
for (const q of cues) {
|
||||
const a = KINDS[q.kind].answer;
|
||||
order[q.id] = ((order[a] = (order[a] || 0) + 1) <= 3);
|
||||
}
|
||||
let di = 0;
|
||||
let si = Math.min(R.souls.length, sFirst + 400);
|
||||
// Souls to draw, nearest first.
|
||||
while (si > sFirst && R.souls[si - 1][0] > you.x + SEE) si--;
|
||||
const soulsNear = [];
|
||||
for (let j = j1; j >= j0; j--) {
|
||||
cell(ctx, you, c, j);
|
||||
const zEnd = j * CELL;
|
||||
// Things and souls whose near end lies from this cell's start to the next one's.
|
||||
while (di < draw.length && draw[di].x >= zEnd) {
|
||||
const q = draw[di++];
|
||||
if ((q.x + q.end) / 2 < you.x - 1) after.push(q);
|
||||
else thing(ctx, you, c, q, flank.get(Math.round(q.x)) || [], order[q.id]);
|
||||
}
|
||||
while (si > sFirst && R.souls[si - 1][0] >= zEnd) {
|
||||
si--;
|
||||
if (c.souls[si] === 0) soulsNear.push(si);
|
||||
}
|
||||
// Draw this cell's souls (far end first) now.
|
||||
while (soulsNear.length) {
|
||||
const n = soulsNear.shift();
|
||||
soul(ctx, c, you, R.souls[n], n);
|
||||
}
|
||||
}
|
||||
while (di < draw.length) {
|
||||
const q = draw[di++];
|
||||
if ((q.x + q.end) / 2 < you.x - 1) after.push(q);
|
||||
else thing(ctx, you, c, q, flank.get(Math.round(q.x)) || [], order[q.id]);
|
||||
}
|
||||
for (const s of round.shots) if (!s.arm && !s.free) bolt(ctx, you, s);
|
||||
hero(ctx, v, you, c);
|
||||
for (const q of after) thing(ctx, you, c, q, flank.get(Math.round(q.x)) || [], false);
|
||||
air(ctx, you, c);
|
||||
ctx.globalAlpha = 1;
|
||||
}
|
||||
|
||||
return { paint };
|
||||
}
|
||||
@@ -0,0 +1,475 @@
|
||||
// Plan2Code Web Console - Ghoul Rush's Holy Roller, its rules: the Chapel's bonus round. YOU surf a runaway church pew down the nave's aisle, seen from behind, in three lanes that speed up the whole way: change lane, jump the kneelers, candle stands, flagstone cracks and crypt hatches, slide under the censers, banners and fallen beams, shoot the gargoyles that drop from the arches (or ring a bell rope to stun them), and gather the wax souls for a combo. A stage pack that ghoul.js plugs in.
|
||||
//
|
||||
// An endless-runner (a Subway Surfers) rather than a side-view ride, so it is handed a kit `k` of
|
||||
// ghoul.js's own helpers like the Coffin Sled (ghoul-sled.js) but never imports ghoul.js. Pack fields
|
||||
// used: `ride` (a hook that moves Planny himself, so no key walks him), `place` (Planny put down in a
|
||||
// room: a room set up or a respawn) and `target` (a bolt strikes something that is no monster: a
|
||||
// gargoyle or a bell rope). It adds no monster, boss or hazard kind, and it draws NO random number.
|
||||
// Its state lives in the shared ride slot `round.runner` (`id` "pew"), and its room says `runner: "pew"`.
|
||||
//
|
||||
// THE FIELD IS THE ART'S ALONE: ghoul-draw.js hands the whole field to pewArt's `field` (a pseudo-3D
|
||||
// view down the aisle from behind the pew), so Planny's (x, y) here is only the distance run (`you.x`) and
|
||||
// the floor under it; the lane and height are the pew's own (`c.lane`, `c.h`).
|
||||
//
|
||||
// THE COURSE (spec.ride, built by ghoul-pew-course.js, written in seconds and laid by the ramp):
|
||||
//
|
||||
// - `items`: [x, lane, kind, len] (see KINDS: SWITCH the lane for a block, JUMP a low thing, SLIDE under
|
||||
// a high one, SHOOT a gargoyle or a bell rope); `souls`: [x, lane, h, type] (type 1 a halo, a magnet);
|
||||
// `checks` and `finish` (the distance where the ride ends) and `time` (the clock, ms) and `how`.
|
||||
// - The ride speeds up with the distance covered, from V0 to about 80 over RIDE_S (speedAt): a clear
|
||||
// ramp, so a run is about 66 s whatever you do. The art reads `c.v` for its speed lines and vignette.
|
||||
//
|
||||
// THE PEW (`round.runner`, null in any other room): { id, room, v, lane (a float, 0 to 2, sliding
|
||||
// to `laneTo`), lean, h (height over the aisle), vh, slide (ms left), dive, bump, check, done,
|
||||
// souls (0 open, 1 taken, 2 missed), got, combo, best, mult, comboMs, magnet, gargs, bells, hit, ... }.
|
||||
// LEFT and RIGHT (a press) change lane (LANE_RATE lanes a second; a press at an edge lane bumps the
|
||||
// wall, `pewBump`), UP jumps (JUMP_V against JUMP_G, about 6 high and two thirds of a second), DOWN slides
|
||||
// for SLIDE_MS (in the air it fast-falls and slides on landing), hold fire to shoot straight down the lane.
|
||||
//
|
||||
// A hit costs one of the round's five hearts (ghoul-bonus.js), not a life, and the pew rolls on: it is
|
||||
// shoved to the nearest calm lane and blinks safe for BONUS_SAFE_MS; the last heart gone ends the round
|
||||
// with nothing, at once. A counted hit breaks the combo. Causes (the game shares them, all prefixed):
|
||||
// see KINDS. A gargoyle shot (two bolts) or stunned by a bell, a bell rung and the souls taken are
|
||||
// the grade's: `perf.total` obstacles, `perf.hits` the ids that cost a heart, `perf.acts` against
|
||||
// ACTS_GOAL, and `perf.steady` once SOUL_SHARE of the souls laid out are taken.
|
||||
//
|
||||
// WHAT THE ART READS: `spec.ride`, `round.runner` (above; gargs: [{ state "perch"|"warn"|"drop"|"stand"|
|
||||
// "stun"|"broken", t, hp }], bells: [rung]), `round.you` (`x`, `safeMs`), `round.shots` ({ x, lane }), the
|
||||
// events in EVENTS.
|
||||
|
||||
import { ACC, COURSE, PEW_START, RIDE_S, V0, V_MAX, speedAt, xAt } from "./ghoul-pew-course.js";
|
||||
|
||||
export { ACC, COURSE, PEW_START, RIDE_S, V0, V_MAX, speedAt, xAt };
|
||||
|
||||
const freeze = (o) => Object.freeze(o);
|
||||
const clamp = (v, lo, hi) => Math.min(hi, Math.max(lo, v));
|
||||
|
||||
export const MONSTERS = freeze({});
|
||||
|
||||
// Every event this pack puts on the field, for the art and the sounds to answer.
|
||||
export const EVENTS = freeze([
|
||||
"pewLane", "pewBump", "pewJump", "pewLand", "pewSlide", "pewDive", "pewSoul", "pewHalo", "pewCrash", "pewCheck", "pewFinish",
|
||||
"pewGargWarn", "pewGargDrop", "pewGargChip", "pewGargHit", "pewBell", "pewSpeed",
|
||||
]);
|
||||
|
||||
// The pew. Speeds are units down the aisle a second.
|
||||
export const LANES = 3;
|
||||
export const LANE_RATE = 6.5;
|
||||
export const LANE_HIT = 0.5;
|
||||
export const HIT_Z = 1.1;
|
||||
export const JUMP_V = 36;
|
||||
export const JUMP_G = 110;
|
||||
export const FAST_FALL = -62;
|
||||
export const STAND_H = 4.4;
|
||||
export const SLIDE_H = 2;
|
||||
export const SLIDE_MS = 700;
|
||||
export const BUMP_MS = 180;
|
||||
// The speeds at which the organ swells: the ride is picking up.
|
||||
export const SWELLS = freeze([44, 54, 64, 74]);
|
||||
// The things. `d` the depth of one (a row of cracks says its own), `h` the height of a low one
|
||||
// (clear it with your feet over `h`), `low` the underside of a high one over the aisle.
|
||||
export const LOW_Y = 2.8;
|
||||
export const KINDS = freeze({
|
||||
pillar: freeze({ answer: "SWITCH", d: 3.2, cause: "pewPillar" }),
|
||||
confessional: freeze({ answer: "SWITCH", d: 7, cause: "pewConfessional" }),
|
||||
pewx: freeze({ answer: "SWITCH", d: 3.6, cause: "pewCrosswise" }),
|
||||
kneeler: freeze({ answer: "JUMP", d: 3.2, h: 2, cause: "pewKneeler" }),
|
||||
stand: freeze({ answer: "JUMP", d: 2.2, h: 3.4, cause: "pewCandle" }),
|
||||
cracks: freeze({ answer: "JUMP", d: 7, h: 0.8, cause: "pewFlagstone" }),
|
||||
hatch: freeze({ answer: "JUMP", d: 5.5, h: 0.8, cause: "pewHatch" }),
|
||||
censer: freeze({ answer: "SLIDE", d: 2.6, low: LOW_Y, cause: "pewCenser" }),
|
||||
banner: freeze({ answer: "SLIDE", d: 1.8, low: LOW_Y, cause: "pewBanner" }),
|
||||
beam: freeze({ answer: "SLIDE", d: 3, low: LOW_Y, cause: "pewBeam" }),
|
||||
garg: freeze({ answer: "SHOOT", d: 3, h: 5, cause: "pewGargoyle" }),
|
||||
bell: freeze({ answer: "SHOOT", d: 1.6, cause: "" }),
|
||||
});
|
||||
// The gargoyles: wake GARG_LEAD_S seconds short, shudder, drop from GARG_PERCH up, take GARG_HP bolts.
|
||||
export const GARG_LEAD_S = 1.55;
|
||||
export const GARG_WARN_MS = 600;
|
||||
export const GARG_DROP_MS = 260;
|
||||
export const GARG_PERCH = 14;
|
||||
export const GARG_HP = 2;
|
||||
export const GARG_POINTS = 150;
|
||||
// A bell rung stuns every gargoyle still ahead of the pew within BELL_S seconds of the ride beyond the bell's rope.
|
||||
export const BELL_S = 3.4;
|
||||
export const BELL_POINTS = 100;
|
||||
// The wax souls: a combo of COMBO_STEP in a row adds one to the multiplier (to MULT_MAX), COMBO_MS to the next.
|
||||
export const SOUL_POINTS = 10;
|
||||
export const HALO_POINTS = 50;
|
||||
export const COMBO_STEP = 8;
|
||||
export const MULT_MAX = 5;
|
||||
export const COMBO_MS = 2200;
|
||||
export const MAG_MS = 4500;
|
||||
export const MAG_Z = 26;
|
||||
export const SOUL_SHARE = 0.6;
|
||||
// The shots at things (gargoyles shot or stunned, bells rung) worth a die.
|
||||
export const ACTS_GOAL = 6;
|
||||
|
||||
export const multOf = (n) => Math.min(MULT_MAX, 1 + Math.floor(n / COMBO_STEP));
|
||||
|
||||
// Notes for a bonus round that cue `id` cost a heart (once each).
|
||||
function noteHit(round, id) {
|
||||
const b = round.bonusRound;
|
||||
if (b && !b.perf.hits.includes(id)) b.perf.hits.push(id);
|
||||
}
|
||||
|
||||
// Every thing in the course as a cue, by x: { id, kind, i (among its kind), x, lane, len, end, answer }. Built once.
|
||||
const CUES = new WeakMap();
|
||||
export function cuesOf(R) {
|
||||
let cues = CUES.get(R);
|
||||
if (!cues) {
|
||||
const seen = {};
|
||||
cues = R.items.map(([x, lane, kind, len]) => {
|
||||
const i = seen[kind] || 0;
|
||||
seen[kind] = i + 1;
|
||||
const d = len || KINDS[kind].d;
|
||||
return freeze({ id: `${kind}${i}`, kind, i, x, lane, len: d, end: x + d, answer: KINDS[kind].answer });
|
||||
});
|
||||
CUES.set(R, freeze(cues));
|
||||
cues = CUES.get(R);
|
||||
}
|
||||
return cues;
|
||||
}
|
||||
// The cues that count for the grade (the bells are only for shooting).
|
||||
export const countedOf = (R) => cuesOf(R).filter((q) => q.kind !== "bell");
|
||||
export const gargsOf = (R) => cuesOf(R).filter((q) => q.kind === "garg");
|
||||
export const bellsOf = (R) => cuesOf(R).filter((q) => q.kind === "bell");
|
||||
export const soulTotal = (R) => R.souls.filter((s) => s[3] === 0).length;
|
||||
|
||||
/* -------------------------------------------------------------- placing */
|
||||
|
||||
// A fresh set of the course's creatures: each gargoyle perched, each bell hanging. What was shot,
|
||||
// stunned or rung stays so (`old`, the pew of an earlier try in the same room).
|
||||
function things(R, old) {
|
||||
const keep = (s) => s === "broken" || s === "stun";
|
||||
return {
|
||||
gargs: gargsOf(R).map((q, i) => ({ state: old && old.gargs[i] && keep(old.gargs[i].state) ? old.gargs[i].state : "perch", t: 0, hp: GARG_HP })),
|
||||
bells: bellsOf(R).map((q, i) => Boolean(old && old.bells[i])),
|
||||
souls: old ? old.souls : R.souls.map(() => 0),
|
||||
};
|
||||
}
|
||||
|
||||
// Planny put down in the room: on the pew at the start of a ride, or at the last checkpoint
|
||||
// passed (the same room).
|
||||
function place(round, k) {
|
||||
const R = round.spec.ride;
|
||||
if (!R || R.runner !== "pew") {
|
||||
// (Another ride's state in the shared slot is not ours to touch.)
|
||||
if (round.runner && round.runner.id === "pew") round.runner = null;
|
||||
return;
|
||||
}
|
||||
const again = round.runner && round.runner.id === "pew" && round.runner.room === round.room;
|
||||
const old = again ? round.runner : null;
|
||||
const check = again ? round.runner.check : -1;
|
||||
const x = check >= 0 ? R.checks[check] : round.spec.start;
|
||||
const set = things(R, old);
|
||||
Object.assign(round.you, { x, y: k.groundAt(round.spec, x), vy: 0, state: "run", shelf: -1, face: 1, ducking: false, coyote: 0, drop: -1 });
|
||||
// Souls laid before the checkpoint are behind us now.
|
||||
const next = R.souls.findIndex((s, i) => s[0] >= x - 1 || (set.souls[i] = set.souls[i] || 2, false));
|
||||
round.runner = {
|
||||
id: "pew", room: round.room, check, v: speedAt(x), lane: 1, laneTo: 1, lean: 0, h: 0, vh: 0, slide: 0, dive: false, bump: 0, bumpDir: 0,
|
||||
hl: false, hr: false, hd: false, done: false, swell: SWELLS.findIndex((s) => s > speedAt(x)) < 0 ? SWELLS.length : SWELLS.findIndex((s) => s > speedAt(x)),
|
||||
got: old ? old.got : 0, combo: 0, best: old ? old.best : 0, mult: 1, comboMs: 0, magnet: 0, sNext: next < 0 ? R.souls.length : next, hit: {}, shove: 0,
|
||||
...set,
|
||||
};
|
||||
const b = round.bonusRound;
|
||||
if (b && !b.perf.total) {
|
||||
b.perf.total = countedOf(R).length;
|
||||
b.perf.steady = false;
|
||||
b.perf.goal = ACTS_GOAL;
|
||||
}
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------ the ride */
|
||||
|
||||
// The pew's motion for one slice. Returns true once it has moved Planny (every slice of a ride);
|
||||
// false once the ride is over.
|
||||
function ride(round, ms, k) {
|
||||
const R = round.spec.ride;
|
||||
const c = round.runner;
|
||||
if (!R || R.runner !== "pew" || !c || c.id !== "pew" || c.done) return false;
|
||||
const you = round.you;
|
||||
const inp = round.input;
|
||||
const dt = ms / 1000;
|
||||
const ev = (type, extra = {}) => round.events.push({ type, x: you.x, y: you.y, lane: c.lane, h: c.h, ...extra });
|
||||
c.v = speedAt(you.x);
|
||||
while (c.swell < SWELLS.length && c.v >= SWELLS[c.swell]) ev("pewSpeed", { n: c.swell++, v: c.v });
|
||||
steerShots(round, c);
|
||||
// Lanes: a press (not a held key) moves one lane; at the edge it bumps the wall.
|
||||
const left = Boolean(inp.left);
|
||||
const right = Boolean(inp.right);
|
||||
for (const [now, was, dir] of [[left, c.hl, -1], [right, c.hr, 1]]) {
|
||||
if (!now || was) continue;
|
||||
const to = c.laneTo + dir;
|
||||
if (to < 0 || to >= LANES) {
|
||||
c.bump = BUMP_MS;
|
||||
c.bumpDir = dir;
|
||||
ev("pewBump", { dir });
|
||||
} else {
|
||||
c.laneTo = to;
|
||||
ev("pewLane", { dir, to });
|
||||
}
|
||||
}
|
||||
c.hl = left;
|
||||
c.hr = right;
|
||||
const dl = c.laneTo - c.lane;
|
||||
const step = LANE_RATE * dt;
|
||||
c.lane = Math.abs(dl) <= step ? c.laneTo : c.lane + Math.sign(dl) * step;
|
||||
c.lean += (clamp(c.laneTo - c.lane, -1, 1) - c.lean) * Math.min(1, dt * 16);
|
||||
c.bump = Math.max(0, c.bump - ms);
|
||||
// Jump and slide.
|
||||
const ground = c.h <= 0 && c.vh <= 0;
|
||||
if (inp.jump > 0 && ground) {
|
||||
inp.jump = 0;
|
||||
c.vh = JUMP_V;
|
||||
c.h = 0.001;
|
||||
c.slide = 0;
|
||||
ev("pewJump");
|
||||
} else if (inp.jump > 0) inp.jump = Math.max(0, inp.jump - ms);
|
||||
const down = Boolean(inp.down);
|
||||
if (down && !c.hd) {
|
||||
if (c.h <= 0 && c.vh <= 0) {
|
||||
if (c.slide <= 0) ev("pewSlide");
|
||||
c.slide = SLIDE_MS;
|
||||
} else if (!c.dive) {
|
||||
c.dive = true;
|
||||
c.vh = Math.min(c.vh, FAST_FALL);
|
||||
ev("pewDive");
|
||||
}
|
||||
}
|
||||
c.hd = down;
|
||||
c.slide = Math.max(0, c.slide - ms);
|
||||
if (c.h > 0 || c.vh > 0) {
|
||||
c.vh = Math.max(-120, c.vh - JUMP_G * dt);
|
||||
c.h += c.vh * dt;
|
||||
if (c.h <= 0) {
|
||||
ev("pewLand", { big: c.vh < -45 });
|
||||
c.h = 0;
|
||||
c.vh = 0;
|
||||
if (c.dive) {
|
||||
c.slide = SLIDE_MS;
|
||||
ev("pewSlide");
|
||||
}
|
||||
c.dive = false;
|
||||
}
|
||||
}
|
||||
you.x += c.v * dt;
|
||||
Object.assign(you, { y: k.groundAt(round.spec, you.x), vy: c.vh, state: c.h > 0 ? "air" : "run", ducking: c.slide > 0, face: 1 });
|
||||
if (you.x >= R.finish) return finish(round, c, R, k);
|
||||
while (c.check + 1 < R.checks.length && you.x >= R.checks[c.check + 1]) {
|
||||
c.check++;
|
||||
ev("pewCheck", { n: c.check + 1 });
|
||||
}
|
||||
obstacles(round, c, R, k);
|
||||
creatures(round, c, R, ms);
|
||||
souls(round, c, R, ms);
|
||||
return true;
|
||||
}
|
||||
|
||||
// The ride is over: Planny steps to the door, which the next slice walks through, and the card shows.
|
||||
function finish(round, c, R, k) {
|
||||
const you = round.you;
|
||||
c.done = true;
|
||||
round.hasKey = true;
|
||||
Object.assign(you, { x: round.spec.door, y: k.groundAt(round.spec, round.spec.door), vy: 0, state: "run", ducking: false });
|
||||
const b = round.bonusRound;
|
||||
const share = soulShare(R, c);
|
||||
if (b) b.perf.steady = share >= SOUL_SHARE;
|
||||
round.events.push({ type: "pewFinish", x: you.x, y: you.y, share, best: c.best, got: c.got });
|
||||
return true;
|
||||
}
|
||||
|
||||
export const soulShare = (R, c) => c.got / Math.max(1, soulTotal(R));
|
||||
|
||||
// A bolt flies straight down its lane, level: the lane is the pew's at the moment it is fired.
|
||||
function steerShots(round, c) {
|
||||
for (const s of round.shots) {
|
||||
if (s.arm || s.free) continue;
|
||||
if (s.lane === undefined) s.lane = clamp(Math.round(c.lane), 0, LANES - 1);
|
||||
s.vy = 0;
|
||||
s.y = round.you.y + 2.4;
|
||||
}
|
||||
}
|
||||
|
||||
// Whether the pew, in its lane and at its height, is in a cue's way right now.
|
||||
export function touching(c, q, x) {
|
||||
const kind = KINDS[q.kind];
|
||||
if (q.kind === "bell" || Math.abs(c.lane - q.lane) >= LANE_HIT) return false;
|
||||
if (x < q.x - HIT_Z || x > q.end + HIT_Z) return false;
|
||||
if (kind.answer === "SWITCH") return true;
|
||||
if (kind.answer === "JUMP") return c.h < kind.h;
|
||||
if (kind.answer === "SLIDE") return !(c.slide > 0 && c.h < 0.5);
|
||||
const g = c.gargs[q.i];
|
||||
return g.state === "stand" || (g.state === "drop" && g.t <= GARG_DROP_MS * 0.3);
|
||||
}
|
||||
|
||||
// The lane nearest `from` with nothing in the way a moment before and after `x`.
|
||||
export function calmLane(R, c, x, from) {
|
||||
const gone = (q) => q.kind === "garg" && (c.gargs[q.i].state === "broken" || c.gargs[q.i].state === "stun");
|
||||
const open = (lane) => !cuesOf(R).some((q) => q.lane === lane && q.kind !== "bell" && q.end > x - 4 && q.x < x + 14 && !gone(q));
|
||||
const order = [0, 1, 2].sort((a, b) => Math.abs(a - from) - Math.abs(b - from) || a - b);
|
||||
return order.find(open) ?? Math.round(from);
|
||||
}
|
||||
|
||||
// What the pew runs into. A counted hit shoves it to a calm lane; it does the heart's cost through k.struck.
|
||||
function obstacles(round, c, R, k) {
|
||||
const you = round.you;
|
||||
for (const q of cuesOf(R)) {
|
||||
if (q.x > you.x + 8) break;
|
||||
if (q.end < you.x - 8 || c.hit[q.id]) continue;
|
||||
if (!touching(c, q, you.x)) continue;
|
||||
if (!k.struck(round, KINDS[q.kind].cause)) continue;
|
||||
c.hit[q.id] = true;
|
||||
const lost = c.combo;
|
||||
c.combo = 0;
|
||||
c.mult = 1;
|
||||
c.comboMs = 0;
|
||||
noteHit(round, q.id);
|
||||
c.laneTo = calmLane(R, c, you.x, c.lane);
|
||||
c.vh = Math.min(c.vh, 0);
|
||||
round.events.push({ type: "pewCrash", what: q.kind, id: q.id, x: you.x, y: you.y, lane: q.lane, h: c.h, lost });
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
// The gargoyles in the arches wake when the pew comes near: shudder, drop, then stand in the lane.
|
||||
function creatures(round, c, R, ms) {
|
||||
const you = round.you;
|
||||
gargsOf(R).forEach((q, i) => {
|
||||
const g = c.gargs[i];
|
||||
if (g.state === "perch") {
|
||||
if ((q.x - you.x) / c.v < GARG_LEAD_S && q.end > you.x) {
|
||||
Object.assign(g, { state: "warn", t: GARG_WARN_MS });
|
||||
round.events.push({ type: "pewGargWarn", x: q.x, y: you.y, lane: q.lane });
|
||||
}
|
||||
} else if (g.state === "warn" || g.state === "drop") {
|
||||
g.t -= ms;
|
||||
if (g.t > 0) return;
|
||||
if (g.state === "warn") Object.assign(g, { state: "drop", t: GARG_DROP_MS });
|
||||
else {
|
||||
Object.assign(g, { state: "stand", t: 0 });
|
||||
round.events.push({ type: "pewGargDrop", x: q.x, y: you.y, lane: q.lane });
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// The wax souls: taken in passing (lane and height), or pulled in by a halo's magnet.
|
||||
function souls(round, c, R, ms) {
|
||||
const you = round.you;
|
||||
const S = R.souls;
|
||||
c.magnet = Math.max(0, c.magnet - ms);
|
||||
c.comboMs = Math.max(0, c.comboMs - ms);
|
||||
if (!c.comboMs && c.combo) {
|
||||
c.combo = 0;
|
||||
c.mult = 1;
|
||||
}
|
||||
const body = c.slide > 0 ? SLIDE_H : STAND_H;
|
||||
const reach = c.magnet > 0 ? MAG_Z : 1;
|
||||
for (let i = c.sNext; i < S.length && S[i][0] <= you.x + reach; i++) {
|
||||
if (c.souls[i] !== 0) continue;
|
||||
const [sx, lane, h, type] = S[i];
|
||||
const pulled = c.magnet > 0 && Math.abs(lane - c.lane) <= 1.05 && sx - you.x <= MAG_Z;
|
||||
const met = sx <= you.x + 1;
|
||||
if (!pulled && !met) continue;
|
||||
const hit = pulled || (Math.abs(lane - c.lane) < 0.6 && h >= c.h - 0.8 && h <= c.h + body + 0.8);
|
||||
if (!hit) {
|
||||
c.souls[i] = 2;
|
||||
continue;
|
||||
}
|
||||
c.souls[i] = 1;
|
||||
if (type === 1) {
|
||||
c.magnet = MAG_MS;
|
||||
round.score += HALO_POINTS;
|
||||
round.events.push({ type: "pewHalo", x: sx, y: you.y, lane, h, points: HALO_POINTS });
|
||||
continue;
|
||||
}
|
||||
c.got++;
|
||||
c.combo++;
|
||||
c.best = Math.max(c.best, c.combo);
|
||||
c.comboMs = COMBO_MS;
|
||||
const was = c.mult;
|
||||
c.mult = multOf(c.combo);
|
||||
round.score += SOUL_POINTS * c.mult;
|
||||
round.events.push({ type: "pewSoul", x: sx, y: you.y, lane, h, combo: c.combo, mult: c.mult, up: c.mult > was });
|
||||
const b = round.bonusRound;
|
||||
if (b) b.perf.steady = soulShare(R, c) >= SOUL_SHARE;
|
||||
}
|
||||
while (c.sNext < S.length && (c.souls[c.sNext] !== 0 || S[c.sNext][0] < you.x - 2)) {
|
||||
if (c.souls[c.sNext] === 0) c.souls[c.sNext] = 2;
|
||||
c.sNext++;
|
||||
}
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------- targets */
|
||||
|
||||
// How high a gargoyle is over the aisle: GARG_PERCH perched, falling as it drops, 0 standing.
|
||||
export function gargRise(g) {
|
||||
if (g.state === "drop") return GARG_PERCH * clamp(g.t / GARG_DROP_MS, 0, 1);
|
||||
return g.state === "stand" || g.state === "stun" || g.state === "broken" ? 0 : GARG_PERCH;
|
||||
}
|
||||
|
||||
// A bolt into something to shoot: a gargoyle falling or standing, a bell rope. True when one took it.
|
||||
function pewShot(round, s) {
|
||||
const R = round.spec.ride;
|
||||
const c = round.runner;
|
||||
if (!R || R.runner !== "pew" || !c || c.id !== "pew") return false;
|
||||
if (s.lane === undefined) s.lane = clamp(Math.round(c.lane), 0, LANES - 1);
|
||||
const x0 = s.q === undefined ? s.x - 3 : s.q;
|
||||
s.q = s.x;
|
||||
const lo = Math.min(x0, s.x) - 0.6;
|
||||
const hi = Math.max(x0, s.x) + 0.6;
|
||||
const over = (q) => q.lane === s.lane && q.end >= lo && q.x <= hi;
|
||||
const award = (n) => {
|
||||
round.score += n * c.mult;
|
||||
if (round.bonusRound) round.bonusRound.perf.acts++;
|
||||
};
|
||||
const gs = gargsOf(R);
|
||||
for (let i = 0; i < gs.length; i++) {
|
||||
const g = c.gargs[i];
|
||||
if ((g.state !== "drop" && g.state !== "stand") || !over(gs[i])) continue;
|
||||
const q = gs[i];
|
||||
if (--g.hp > 0) {
|
||||
round.events.push({ type: "pewGargChip", x: q.x, y: round.you.y, lane: q.lane, hp: g.hp });
|
||||
return true;
|
||||
}
|
||||
Object.assign(g, { state: "broken", t: 0 });
|
||||
award(GARG_POINTS);
|
||||
round.events.push({ type: "pewGargHit", x: q.x, y: round.you.y, lane: q.lane, points: GARG_POINTS * c.mult });
|
||||
return true;
|
||||
}
|
||||
const bs = bellsOf(R);
|
||||
for (let i = 0; i < bs.length; i++) {
|
||||
if (c.bells[i] || !over(bs[i])) continue;
|
||||
const q = bs[i];
|
||||
c.bells[i] = true;
|
||||
// Every gargoyle still to come (or standing), up to BELL_S seconds of ride beyond the rope, is stunned.
|
||||
let stunned = 0;
|
||||
gs.forEach((gq, j) => {
|
||||
const g = c.gargs[j];
|
||||
if (g.state !== "broken" && g.state !== "stun" && gq.end > round.you.x && gq.x <= q.x + c.v * BELL_S) {
|
||||
Object.assign(g, { state: "stun", t: 0 });
|
||||
stunned++;
|
||||
}
|
||||
});
|
||||
award(BELL_POINTS);
|
||||
if (round.bonusRound) round.bonusRound.perf.acts += stunned;
|
||||
round.events.push({ type: "pewBell", x: q.x, y: round.you.y, lane: q.lane, points: BELL_POINTS * c.mult, stunned });
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
export const PEW = freeze({
|
||||
id: "pew",
|
||||
monsters: MONSTERS,
|
||||
walkers: freeze([]),
|
||||
zombies: freeze([]),
|
||||
stackers: freeze([]),
|
||||
climbers: freeze([]),
|
||||
act: freeze({}),
|
||||
horde: freeze({}),
|
||||
ride: freeze([ride]),
|
||||
place: freeze([place]),
|
||||
target: pewShot,
|
||||
});
|
||||
@@ -0,0 +1,220 @@
|
||||
// Plan2Code Web Console - ghoul: Holy Roller's own sound effects and music track, merged into ghoul-sfx.js; defines only.
|
||||
//
|
||||
// Same shape and rules as ghoul-sfx-sled.js: `tones` (a `ghoul<Kind><Act>` sound for the runner's
|
||||
// moves and things, each under 1.2 s) and `music` (a track for the room, named in ROOM_MUSIC in ghoul.js).
|
||||
// The sounds and the track are first drafts in the house's tone layers; they are still to be
|
||||
// picked by ear. A name may be defined only once across tones.js and every game's file. No imports.
|
||||
|
||||
export const PEW_SFX = {
|
||||
tones: {
|
||||
// Lane change: a quick whoosh as the pew slides across.
|
||||
ghoulPewLane: {
|
||||
layers: [
|
||||
{ type: "noise", seconds: 0.16, attack: 0.04, gain: 0.4, filter: { type: "bandpass", from: 600, to: 2400, q: 1.4 } },
|
||||
{ type: "triangle", from: 180, to: 260, seconds: 0.12, attack: 0.01, gain: 0.18 },
|
||||
],
|
||||
},
|
||||
// A lane press at the edge: a tiny bump on the chapel wall.
|
||||
ghoulPewBump: {
|
||||
layers: [
|
||||
{ type: "sine", from: 120, to: 70, seconds: 0.1, attack: 0, gain: 0.6 },
|
||||
{ type: "noise", seconds: 0.05, attack: 0, gain: 0.25, filter: { type: "lowpass", from: 900, to: 400, q: 1 } },
|
||||
],
|
||||
},
|
||||
// Jump: wood creak and a lift.
|
||||
ghoulPewJump: {
|
||||
layers: [
|
||||
{ type: "noise", seconds: 0.18, attack: 0.05, gain: 0.3, filter: { type: "bandpass", from: 700, to: 1800, q: 4 } },
|
||||
{ type: "triangle", from: 240, to: 420, seconds: 0.2, attack: 0.02, gain: 0.3 },
|
||||
],
|
||||
},
|
||||
// Landing: a wooden thump.
|
||||
ghoulPewLand: {
|
||||
layers: [
|
||||
{ type: "sine", from: 130, to: 55, seconds: 0.14, attack: 0, gain: 0.8 },
|
||||
{ type: "noise", seconds: 0.06, attack: 0, gain: 0.4, filter: { type: "bandpass", from: 900, to: 500, q: 3 } },
|
||||
],
|
||||
},
|
||||
// Slide: a scrape of wood on stone.
|
||||
ghoulPewSlide: {
|
||||
layers: [
|
||||
{ type: "noise", seconds: 0.4, attack: 0.03, gain: 0.42, filter: { type: "bandpass", from: 2200, to: 900, q: 2 } },
|
||||
{ type: "sawtooth", from: 110, to: 80, seconds: 0.35, attack: 0.02, gain: 0.1, filter: { type: "lowpass", from: 700, to: 300, q: 1 } },
|
||||
],
|
||||
},
|
||||
// Down in the air, a fast fall: a falling whistle.
|
||||
ghoulPewDive: {
|
||||
layers: [
|
||||
{ type: "sine", from: 900, to: 260, seconds: 0.2, attack: 0.01, gain: 0.2 },
|
||||
{ type: "noise", seconds: 0.18, attack: 0.02, gain: 0.2, filter: { type: "highpass", from: 1200, to: 1200, q: 1 } },
|
||||
],
|
||||
},
|
||||
// A wax soul taken: a bright tick (the art raises its pitch with the combo).
|
||||
ghoulPewSoul: {
|
||||
layers: [
|
||||
{ type: "sine", from: 880, to: 880, seconds: 0.1, attack: 0.003, gain: 0.3 },
|
||||
{ type: "triangle", from: 1760, to: 1760, seconds: 0.08, attack: 0.003, gain: 0.12 },
|
||||
{ type: "noise", seconds: 0.02, attack: 0, gain: 0.1, filter: { type: "highpass", from: 5000, to: 5000, q: 1 } },
|
||||
],
|
||||
},
|
||||
// A halo caught: a rising shimmer.
|
||||
ghoulPewHalo: {
|
||||
layers: [
|
||||
{ type: "sine", from: 660, to: 1320, seconds: 0.5, attack: 0.01, gain: 0.28 },
|
||||
{ type: "sine", from: 990, to: 1980, seconds: 0.5, attack: 0.01, gain: 0.16, delay: 0.04 },
|
||||
{ type: "sine", from: 1320, to: 2640, seconds: 0.4, attack: 0.01, gain: 0.1, delay: 0.08 },
|
||||
],
|
||||
},
|
||||
// A hit: splintering wood and a sour organ chord.
|
||||
ghoulPewCrash: {
|
||||
layers: [
|
||||
{ type: "sine", from: 96, to: 34, seconds: 0.25, attack: 0, gain: 0.95 },
|
||||
{ type: "brown", seconds: 0.2, attack: 0, gain: 0.7, filter: { type: "lowpass", from: 300, to: 260, q: 1 } },
|
||||
{ type: "noise", seconds: 0.3, attack: 0.04, gain: 0.4, delay: 0.02, filter: { type: "bandpass", from: 1200, to: 3200, q: 2 } },
|
||||
{ type: "sawtooth", from: 196, to: 190, seconds: 0.5, attack: 0.02, gain: 0.2, delay: 0.05, filter: { type: "lowpass", from: 900, to: 500, q: 1 } },
|
||||
{ type: "sawtooth", from: 208, to: 200, seconds: 0.5, attack: 0.02, gain: 0.2, delay: 0.05, filter: { type: "lowpass", from: 900, to: 500, q: 1 } },
|
||||
{ type: "sawtooth", from: 233, to: 225, seconds: 0.5, attack: 0.02, gain: 0.2, delay: 0.05, filter: { type: "lowpass", from: 900, to: 500, q: 1 } },
|
||||
],
|
||||
},
|
||||
// Checkpoint: two chapel bell strokes.
|
||||
ghoulPewCheck: {
|
||||
layers: [
|
||||
{ type: "sine", from: 784, to: 776, seconds: 0.4, attack: 0.003, gain: 0.3 },
|
||||
{ type: "sine", from: 2093, to: 2070, seconds: 0.2, attack: 0.003, gain: 0.12 },
|
||||
{ type: "sine", from: 988, to: 980, seconds: 0.5, attack: 0.003, gain: 0.3, delay: 0.16 },
|
||||
{ type: "sine", from: 2637, to: 2610, seconds: 0.25, attack: 0.003, gain: 0.12, delay: 0.16 },
|
||||
],
|
||||
},
|
||||
// Finish: an organ fanfare, a major chord.
|
||||
ghoulPewFinish: {
|
||||
layers: [
|
||||
{ type: "square", seconds: 1, attack: 0.02, gain: 0.2, notes: [262, 330, 392, 523], filter: { type: "lowpass", from: 1600, to: 1600, q: 1 } },
|
||||
{ type: "triangle", seconds: 1, attack: 0.02, gain: 0.4, notes: [131, 165, 196, 262] },
|
||||
{ type: "sine", seconds: 1, attack: 0.02, gain: 0.2, notes: [523, 659, 784, 1047] },
|
||||
],
|
||||
},
|
||||
// The ride picks up speed: an organ swell, rising.
|
||||
ghoulPewSpeed: {
|
||||
layers: [
|
||||
{ type: "sawtooth", from: 147, to: 294, seconds: 0.7, attack: 0.3, gain: 0.2, filter: { type: "lowpass", from: 600, to: 1600, q: 1 } },
|
||||
{ type: "sawtooth", from: 220, to: 440, seconds: 0.7, attack: 0.3, gain: 0.14, filter: { type: "lowpass", from: 600, to: 1600, q: 1 } },
|
||||
{ type: "noise", seconds: 0.6, attack: 0.3, gain: 0.18, filter: { type: "bandpass", from: 500, to: 3000, q: 1.5 } },
|
||||
],
|
||||
},
|
||||
// Gargoyle: a stone gargoyle in the arches. It shudders (grinding stone) ...
|
||||
ghoulPewGargWarn: {
|
||||
layers: [
|
||||
{ type: "brown", seconds: 0.45, attack: 0.05, gain: 0.5, filter: { type: "bandpass", from: 300, to: 700, q: 3 } },
|
||||
{ type: "sawtooth", from: 92, to: 70, seconds: 0.45, attack: 0.05, gain: 0.3, vibrato: { rate: 18, depth: 0.12 }, filter: { type: "lowpass", from: 500, to: 300, q: 2 } },
|
||||
],
|
||||
},
|
||||
// ... drops into the lane (a heavy stone thud) ...
|
||||
ghoulPewGargDrop: {
|
||||
layers: [
|
||||
{ type: "sine", from: 74, to: 28, seconds: 0.3, attack: 0, gain: 1 },
|
||||
{ type: "brown", seconds: 0.25, attack: 0, gain: 0.8, filter: { type: "lowpass", from: 240, to: 200, q: 1 } },
|
||||
{ type: "noise", seconds: 0.1, attack: 0, gain: 0.35, delay: 0.02, filter: { type: "bandpass", from: 1400, to: 800, q: 2 } },
|
||||
],
|
||||
},
|
||||
// ... a first bolt chips it (a stone crack) ...
|
||||
ghoulPewGargChip: {
|
||||
layers: [
|
||||
{ type: "noise", seconds: 0.05, attack: 0, gain: 0.6, filter: { type: "bandpass", from: 2200, to: 1400, q: 3 } },
|
||||
{ type: "square", from: 520, to: 300, seconds: 0.04, attack: 0, gain: 0.2 },
|
||||
],
|
||||
},
|
||||
// ... and the second bolt breaks it: stone cracking apart.
|
||||
ghoulPewGargHit: {
|
||||
layers: [
|
||||
{ type: "noise", seconds: 0.05, attack: 0, gain: 0.8, filter: { type: "bandpass", from: 1800, to: 1000, q: 2 } },
|
||||
{ type: "square", from: 600, to: 200, seconds: 0.05, attack: 0, gain: 0.3 },
|
||||
{ type: "noise", seconds: 0.04, delay: 0.07, attack: 0, gain: 0.5, filter: { type: "bandpass", from: 2600, to: 1600, q: 3 } },
|
||||
{ type: "brown", seconds: 0.3, attack: 0.02, gain: 0.5, delay: 0.04, filter: { type: "lowpass", from: 500, to: 200, q: 1 } },
|
||||
],
|
||||
},
|
||||
// Bell rope: shoot it and the bell rings, a deep stroke, and the gargoyles ahead are stunned.
|
||||
ghoulPewBell: {
|
||||
layers: [
|
||||
{ type: "sine", from: 392, to: 386, seconds: 1.1, attack: 0.004, gain: 0.5 },
|
||||
{ type: "sine", from: 784, to: 772, seconds: 0.9, attack: 0.004, gain: 0.22 },
|
||||
{ type: "sine", from: 1180, to: 1160, seconds: 0.6, attack: 0.004, gain: 0.14 },
|
||||
{ type: "sine", from: 1990, to: 1960, seconds: 0.35, attack: 0.004, gain: 0.08 },
|
||||
{ type: "noise", seconds: 0.04, attack: 0, gain: 0.4, filter: { type: "bandpass", from: 3000, to: 2000, q: 3 } },
|
||||
],
|
||||
},
|
||||
},
|
||||
music: {
|
||||
// Holy Roller: the organist's chase. A driving D minor organ ride at 132 beats a minute (the pulse the
|
||||
// art throbs in the pillars and windows): four on the floor, a pedal bass in eighths, organ chords on the
|
||||
// off-beats, a reed line that climbs through the bars, and a bell stroke on the backbeat. Built to loop:
|
||||
// two four-bar phrases that answer each other, round and round.
|
||||
ghoulPewDirge: {
|
||||
bpm: 132,
|
||||
rush: 0,
|
||||
voices: {
|
||||
organ: { wave: "square", gain: 0.045, decay: 0.12, sustain: 0.6, vibrato: { rate: 5, depth: 0.01, delay: 0.2 } },
|
||||
reed: { wave: "sawtooth", gain: 0.04, decay: 0.12, sustain: 0.6, vibrato: { rate: 5.5, depth: 0.018, delay: 0.2 } },
|
||||
pedal: { wave: "triangle", gain: 0.42, decay: 0.2, sustain: 0.7 },
|
||||
kick: { kit: true, gain: 0.22, from: 0 },
|
||||
toll: { kit: true, gain: 0.12, from: 0.35 },
|
||||
},
|
||||
patterns: {
|
||||
A: {
|
||||
organ:
|
||||
". . D4^037 - . . D4^037 - . . D4^037 - . . D4^037 - | " +
|
||||
". . Bb3^047 - . . Bb3^047 - . . Bb3^047 - . . Bb3^047 - | " +
|
||||
". . G3^037 - . . G3^037 - . . G3^037 - . . G3^037 - | " +
|
||||
". . A3^047 - . . A3^047 - . . A3^047 - . . A3^047 -",
|
||||
reed:
|
||||
"D5 - F5 - A5 - F5 - D5 - F5 - A5 - F5 - | " +
|
||||
"D5 - F5 - Bb5 - F5 - D5 - F5 - Bb5 - F5 - | " +
|
||||
"D5 - G5 - Bb5 - G5 - D5 - G5 - Bb5 - G5 - | " +
|
||||
"E5 - A5 - C#6 - A5 - E5 - A5 - C#6 - A5 -",
|
||||
pedal:
|
||||
"D2 - D2 - D2 - D2 - D2 - D2 - D2 - D2 - | " +
|
||||
"Bb1 - Bb1 - Bb1 - Bb1 - Bb1 - Bb1 - Bb1 - Bb1 - | " +
|
||||
"G1 - G1 - G1 - G1 - G1 - G1 - G1 - G1 - | " +
|
||||
"A1 - A1 - A1 - A1 - A1 - A1 - A1 - A1 -",
|
||||
kick:
|
||||
"k . . . k . . . k . . . k . . . | " +
|
||||
"k . . . k . . . k . . . k . . . | " +
|
||||
"k . . . k . . . k . . . k . . . | " +
|
||||
"k . . . k . . . k . . . k . . .",
|
||||
toll:
|
||||
". . . . s . . . . . . . s . . . | " +
|
||||
". . . . s . . . . . . . s . . . | " +
|
||||
". . . . s . . . . . . . s . . . | " +
|
||||
". . . . s . . . . . . . s . s .",
|
||||
},
|
||||
B: {
|
||||
organ:
|
||||
". . F4^037 - . . F4^037 - . . F4^037 - . . F4^037 - | " +
|
||||
". . G3^037 - . . G3^037 - . . G3^037 - . . G3^037 - | " +
|
||||
". . Bb3^047 - . . Bb3^047 - . . Bb3^047 - . . Bb3^047 - | " +
|
||||
". . A3^047 - . . A3^047 - . . A3^047 - . . A3^047 -",
|
||||
reed:
|
||||
"A5 - F5 - A5 - D6 - A5 - F5 - A5 - D6 - | " +
|
||||
"G5 - D5 - G5 - Bb5 - G5 - D5 - G5 - Bb5 - | " +
|
||||
"F5 - D5 - F5 - Bb5 - F5 - D5 - F5 - Bb5 - | " +
|
||||
"E5 - A5 - C#6 - E6 - D6 - A5 - F5 - A4 -",
|
||||
pedal:
|
||||
"F1 - F1 - F1 - F1 - F1 - F1 - F1 - F1 - | " +
|
||||
"G1 - G1 - G1 - G1 - G1 - G1 - G1 - G1 - | " +
|
||||
"Bb1 - Bb1 - Bb1 - Bb1 - Bb1 - Bb1 - Bb1 - Bb1 - | " +
|
||||
"A1 - A1 - A1 - A1 - A1 - A1 - A1 - A1 -",
|
||||
kick:
|
||||
"k . . . k . . . k . . . k . . . | " +
|
||||
"k . . . k . . . k . . . k . . . | " +
|
||||
"k . . . k . . . k . . . k . . . | " +
|
||||
"k . . . k . . . k . . . k . k .",
|
||||
toll:
|
||||
". . . . s . . . . . . . s . . . | " +
|
||||
". . . . s . . . . . . . s . . . | " +
|
||||
". . . . s . . . . . . . s . . . | " +
|
||||
". . . . s . . . . . . . s . . .",
|
||||
},
|
||||
},
|
||||
order: ["A", "B", "A", "B", "A", "B"],
|
||||
},
|
||||
},
|
||||
};
|
||||
Reference in new issue
Block a user