mirror of
https://github.com/jparkerweb/plan2code.git
synced 2026-11-16 20:45:33 -08:00
Add Flock Dash, the thirteenth Activities game, with sounds and music
AI Assisted
This commit is contained in:
1 parent
e924cf5cde
commit
6376a68f85
20 files changed
+4218
-31
No files matched your search
@@ -44,6 +44,7 @@ export const ACTIVITIES = Object.freeze([
|
||||
entry("hop", "Crossing Rush", "Hop through traffic and rivers. Race your rivals to the top."),
|
||||
entry("bounce", "Bounce Road", "Ten wild stages of toy-car mayhem. Jump, stomp and outrun the Monster truck."),
|
||||
entry("ghoul", "Ghoul Rush", "Run and gun through a pitch-dark haunted house. Keep moving.", { music: 65, module: "/activities/ghoul-rush/ghoul.js" }),
|
||||
entry("flock", "Flock Dash", "Lead your flock through the sunset sky. Dodge everything, keep the line.", { music: 70 }),
|
||||
]);
|
||||
|
||||
const cap = (word) => word[0].toUpperCase() + word.slice(1);
|
||||
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -0,0 +1,765 @@
|
||||
// Plan2Code Web Console - Flock Dash's drawing: the sunset sky, the hazards and the portal, the strays and the flock, Planny as the lead bird with a star for an eye, the pills and the banners, from a view flock.js refills.
|
||||
//
|
||||
// Drawing only: no rules and no state of its own. flock.js hands drawScene()
|
||||
// one view object of the moment (the round, the board's geometry, the colors
|
||||
// readColors() took from the page), so the rules never touch a canvas and this
|
||||
// file never decides anything. Everything is drawn in field units under one
|
||||
// scale. Anything that moves on its own (wings, a stray's bob) follows the
|
||||
// view's clock, never Math.random(), so a paused game's frame stays still.
|
||||
//
|
||||
// The sky (one palette per stage), the hazards and the birds keep their own fixed
|
||||
// colors, the same in light and dark. The pills are opaque dark with text that reads on them at 4.5:1
|
||||
// (pills.js). The strip the pills sit on and Planny (in your highlight) follow
|
||||
// the page.
|
||||
|
||||
import { drawPill, LIVES, livesText } from "./pills.js";
|
||||
|
||||
const FALLBACK_COLORS = Object.freeze({ board: "#ffffff", line: "#e4ddd1", you: "#206cc3", ink: "#1d1a17" });
|
||||
|
||||
// The page's tokens, read again at each round and each resize, so the board
|
||||
// follows a theme or highlight change made while the game sat paused. A stub
|
||||
// canvas in Node has no computed style, so every color falls back.
|
||||
export function readColors(canvas) {
|
||||
let style = null;
|
||||
try {
|
||||
style = typeof getComputedStyle === "function" ? getComputedStyle(canvas) : null;
|
||||
} catch {}
|
||||
const pick = (name, fallback) => (style && style.getPropertyValue(name).trim()) || fallback;
|
||||
return {
|
||||
board: pick("--panel", FALLBACK_COLORS.board),
|
||||
line: pick("--rule", FALLBACK_COLORS.line),
|
||||
you: pick("--accent", FALLBACK_COLORS.you),
|
||||
ink: pick("--ink", FALLBACK_COLORS.ink),
|
||||
};
|
||||
}
|
||||
|
||||
export const GOLD = "#f5b301";
|
||||
export const STAGE_COLOR = "#ff9a4d";
|
||||
export const DANGER = "#ff5a5a";
|
||||
export const FLOCK_COLOR = "#2b2140";
|
||||
export const STRAY_COLOR = "#fff3dc";
|
||||
export const HAZARD_COLORS = Object.freeze({ balloon: "#e8413c", gust: "#d9f2ff", stream: "#7fe3f0", cluster: "#b44fd6", storm: "#3a3550", kite: "#2fbf71" });
|
||||
export const POWER_COLORS = Object.freeze({ tailwind: "#5fd7a8", shield: "#4fc3f7", magnet: "#c58bff" });
|
||||
export const SUCCESS = "#5fd77a";
|
||||
const STRAY_RIM = "#2b2140";
|
||||
|
||||
// One palette per stage, golden afternoon deepening through sunset to violet
|
||||
// dusk: the sky's three colors, the clouds' tint, the sun's color and how far
|
||||
// down the field it sits (past 1 it has set), and the pale rim followers need
|
||||
// once the sky is as dark as they are. The first stars come out at stage 8.
|
||||
export const SKIES = Object.freeze({
|
||||
1: Object.freeze({ top: "#5b8fc7", mid: "#e9a95c", horizon: "#ffcb6b", cloud: "#fff4dc", sun: "#fff3b0", sunY: 0.55, rim: null, stars: 0 }),
|
||||
2: Object.freeze({ top: "#4f76b8", mid: "#ea9a58", horizon: "#ffc062", cloud: "#ffe9cc", sun: "#ffeaa0", sunY: 0.62, rim: null, stars: 0 }),
|
||||
3: Object.freeze({ top: "#4a5fa6", mid: "#e8834f", horizon: "#ffb05a", cloud: "#ffdcc0", sun: "#ffe08a", sunY: 0.68, rim: null, stars: 0 }),
|
||||
4: Object.freeze({ top: "#4a4d96", mid: "#e26c5a", horizon: "#ff9a52", cloud: "#ffcdb8", sun: "#ffd070", sunY: 0.74, rim: null, stars: 0 }),
|
||||
5: Object.freeze({ top: "#453f88", mid: "#cf5a72", horizon: "#f98a55", cloud: "#f4b8b8", sun: "#ffb860", sunY: 0.8, rim: null, stars: 0 }),
|
||||
6: Object.freeze({ top: "#3d3378", mid: "#b44d86", horizon: "#ef7a5c", cloud: "#dfa0c0", sun: "#ff9f58", sunY: 0.86, rim: "#ffd9a8", stars: 0 }),
|
||||
7: Object.freeze({ top: "#2f2866", mid: "#8a4392", horizon: "#d9656c", cloud: "#b784c4", sun: "#ff8a5c", sunY: 0.93, rim: "#ffd9a8", stars: 0 }),
|
||||
8: Object.freeze({ top: "#1c1a4a", mid: "#4f2f80", horizon: "#a8487c", cloud: "#7c63a8", sun: "#ff7a6a", sunY: 1.02, rim: "#ffd9a8", stars: 26 }),
|
||||
});
|
||||
const skyFor = (stage) => SKIES[stage] || SKIES[1];
|
||||
const SUN_X = 0.72;
|
||||
const SUN_R = 6.5;
|
||||
const RIM = 0.32;
|
||||
// The two cloud layers: how fast each scrolls against the sky, how many clouds,
|
||||
// their size and strength, and the band of height they keep to.
|
||||
const CLOUD_LAYERS = Object.freeze([
|
||||
Object.freeze({ rate: 0.3, count: 5, size: 0.8, alpha: 0.35, top: 0.04, band: 0.4 }),
|
||||
Object.freeze({ rate: 0.6, count: 4, size: 1.3, alpha: 0.5, top: 0.22, band: 0.55 }),
|
||||
]);
|
||||
// Past each edge a cloud wraps out of sight: half this is more than the widest reaches.
|
||||
const CLOUD_RUN = 40;
|
||||
const BLINK_MS = 110;
|
||||
const LEADER_TILT = 0.5;
|
||||
const LEADER_W = 5;
|
||||
const LEADER_H = 4;
|
||||
const LEADER_INK = "#1d1a17";
|
||||
const BALLOON_CREAM = "#fff3dc";
|
||||
const BASKET = "#7a4d2b";
|
||||
const PARTY = Object.freeze([HAZARD_COLORS.cluster, "#ff5fa2", "#38b6ff", "#ffd23f", "#2fbf71"]);
|
||||
const GLOW_STEPS = 3;
|
||||
const GLOW = 2.2;
|
||||
const GLOW_FINAL = 4;
|
||||
const RING_RX = 3.4;
|
||||
const RING_RX_FINAL = 2.6;
|
||||
const V_FADE_MS = 400;
|
||||
const JAG_STEPS = 7;
|
||||
const BOB = 0.6;
|
||||
const BOB_RATE = 0.003;
|
||||
const FLAP_RATE = 0.014;
|
||||
const TAU = Math.PI * 2;
|
||||
const STREAK_GAP = 11;
|
||||
const STREAK_LEN = 5;
|
||||
const LOOSE_ALPHA_MIN = 0.25;
|
||||
const BANNER_SHADE = "rgba(0, 0, 0, 0.3)";
|
||||
const END_SHADE = "rgba(0, 0, 0, 0.55)";
|
||||
const END_H = 18;
|
||||
const CRATE_BOX = 2.6;
|
||||
const CRATE_GLOW = 3.4;
|
||||
const WIND_STREAKS = 5;
|
||||
const WIND_RUN = 18;
|
||||
const WIND_LEN = 4;
|
||||
const WIND_RATE = 40;
|
||||
|
||||
const pillWidth = (h, text) => h * 0.7 + text.length * h * 0.42;
|
||||
|
||||
function pill(ctx, x, y, h, text, color, fill = 1) {
|
||||
ctx.font = `800 ${h * 0.62}px system-ui, -apple-system, "Segoe UI", sans-serif`;
|
||||
drawPill(ctx, x, y, pillWidth(h, text), h, text, color, fill, y + h * 0.54);
|
||||
}
|
||||
|
||||
const HUD_SHRINK = 0.92;
|
||||
const HUD_SHRINK_MIN = 0.6;
|
||||
|
||||
function layPills(h, W, lives, hud, stripH) {
|
||||
const gap = h * 0.3;
|
||||
const edge = h * 0.4;
|
||||
const y0 = h * 0.35;
|
||||
const out = [];
|
||||
let x = edge;
|
||||
let y = y0;
|
||||
const put = (text, color, fill = 1) => {
|
||||
const w = pillWidth(h, text);
|
||||
if (x > edge && x + w > W - edge) {
|
||||
x = edge;
|
||||
y += h + gap;
|
||||
}
|
||||
out.push({ x, y, w, text, color, fill });
|
||||
x += w + gap;
|
||||
};
|
||||
put(hud.stage, STAGE_COLOR);
|
||||
put(livesText(lives), LIVES);
|
||||
put(`Score ${hud.score}`, GOLD);
|
||||
put(`Flock ${hud.flock} / ${hud.min}`, hud.flock >= hud.min ? SUCCESS : STRAY_COLOR);
|
||||
if (hud.combo > 1) put(`x${hud.combo}`, GOLD);
|
||||
for (const p of hud.powers || []) put(p.text, p.color, p.fill);
|
||||
const drop = Math.max(0, (stripH - (y + h) - y0) / 2);
|
||||
for (const p of out) {
|
||||
p.y += drop;
|
||||
p.h = h;
|
||||
}
|
||||
return { out, over: stripH ? y + h > stripH : false };
|
||||
}
|
||||
|
||||
// Where the pills go, `h` units tall in a strip `stripH` tall on a board `W`
|
||||
// wide: the stage, lives, the score and the flock against the portal's minimum
|
||||
// (in the success color once met) from the left, then the combo
|
||||
// while it is above 1 and the power-ups running. A row that
|
||||
// would leave the strip shrinks every pill a step at a time until it fits; only
|
||||
// past HUD_SHRINK_MIN does a row spill below the strip, over the field, where
|
||||
// drawScene paints the pills last.
|
||||
export function hudLayout(h, W, lives, hud, stripH = 0) {
|
||||
let k = 1;
|
||||
let laid = layPills(h, W, lives, hud, stripH);
|
||||
while (laid.over && k > HUD_SHRINK_MIN) {
|
||||
k = Math.max(HUD_SHRINK_MIN, k * HUD_SHRINK);
|
||||
laid = layPills(h * k, W, lives, hud, stripH);
|
||||
}
|
||||
return laid.out;
|
||||
}
|
||||
|
||||
function drawHud(ctx, v) {
|
||||
const { g, colors } = v;
|
||||
ctx.fillStyle = colors.board;
|
||||
ctx.fillRect(0, 0, g.W, g.HUD_H);
|
||||
ctx.fillStyle = colors.line;
|
||||
ctx.fillRect(0, g.HUD_H - 0.25, g.W, 0.25);
|
||||
}
|
||||
|
||||
function drawPills(ctx, v) {
|
||||
const { g } = v;
|
||||
if (v.state !== "running" && v.state !== "paused") return;
|
||||
for (const p of hudLayout(v.pillH, g.W, v.round.infinite ? Infinity : v.round.lives, v.hud, g.HUD_H)) pill(ctx, p.x, p.y, p.h, p.text, p.color, p.fill);
|
||||
}
|
||||
|
||||
// A number from 0 to 1 for a seed and an index, so the clouds and stars of a
|
||||
// round always sit in the same places.
|
||||
function scatter(seed, k) {
|
||||
let t = Math.imul((seed >>> 0) ^ Math.imul(k + 1, 0x9e3779b1), 0x5bd1e995);
|
||||
t ^= t >>> 15;
|
||||
t = Math.imul(t, t | 61);
|
||||
t ^= t >>> 13;
|
||||
return (t >>> 0) / 4294967296;
|
||||
}
|
||||
|
||||
function disc(ctx, x, y, r, color) {
|
||||
ctx.fillStyle = color;
|
||||
ctx.beginPath();
|
||||
ctx.arc(x, y, r, 0, TAU);
|
||||
ctx.fill();
|
||||
}
|
||||
|
||||
function drawStars(ctx, v, sky) {
|
||||
const { g, round } = v;
|
||||
ctx.fillStyle = "#ffffff";
|
||||
for (let k = 0; k < sky.stars; k++) {
|
||||
ctx.globalAlpha = 0.45 + 0.45 * Math.abs(Math.sin(v.clock * 0.0012 + k));
|
||||
ctx.fillRect(scatter(round.seed, 1000 + k) * g.FIELD_W, scatter(round.seed, 2000 + k) * g.FIELD_H * 0.6, 0.3, 0.3);
|
||||
}
|
||||
ctx.globalAlpha = 1;
|
||||
}
|
||||
|
||||
function drawSun(ctx, g, sky) {
|
||||
const x = g.FIELD_W * SUN_X;
|
||||
const y = g.FIELD_H * sky.sunY;
|
||||
ctx.globalAlpha = 0.16;
|
||||
disc(ctx, x, y, SUN_R * 1.9, sky.sun);
|
||||
ctx.globalAlpha = 0.28;
|
||||
disc(ctx, x, y, SUN_R * 1.4, sky.sun);
|
||||
ctx.globalAlpha = 1;
|
||||
disc(ctx, x, y, SUN_R, sky.sun);
|
||||
}
|
||||
|
||||
// Two layers of clouds drifting behind everything, slower than the sky, wrapping
|
||||
// around from their places in the round's seed.
|
||||
function drawClouds(ctx, v, sky) {
|
||||
const { g, round } = v;
|
||||
const run = g.FIELD_W + CLOUD_RUN;
|
||||
ctx.fillStyle = sky.cloud;
|
||||
CLOUD_LAYERS.forEach((layer, l) => {
|
||||
ctx.globalAlpha = layer.alpha;
|
||||
for (let k = 0; k < layer.count; k++) {
|
||||
const key = (l + 1) * 100 + k * 3;
|
||||
const home = scatter(round.seed, key) * run - round.scroll * layer.rate;
|
||||
const x = ((home % run) + run) % run - CLOUD_RUN / 2;
|
||||
const y = (layer.top + scatter(round.seed, key + 1) * layer.band) * g.FIELD_H;
|
||||
const w = (6 + scatter(round.seed, key + 2) * 8) * layer.size;
|
||||
ctx.beginPath();
|
||||
ctx.ellipse(x, y, w, w * 0.28, 0, 0, TAU);
|
||||
ctx.ellipse(x - w * 0.35, y - w * 0.14, w * 0.42, w * 0.26, 0, 0, TAU);
|
||||
ctx.ellipse(x + w * 0.25, y - w * 0.2, w * 0.5, w * 0.32, 0, 0, TAU);
|
||||
ctx.fill();
|
||||
}
|
||||
});
|
||||
ctx.globalAlpha = 1;
|
||||
}
|
||||
|
||||
function drawSky(ctx, v) {
|
||||
const { g, round } = v;
|
||||
const palette = skyFor(round.stage);
|
||||
const sky = typeof ctx.createLinearGradient === "function" ? ctx.createLinearGradient(0, 0, 0, g.FIELD_H) : null;
|
||||
if (sky) {
|
||||
sky.addColorStop(0, palette.top);
|
||||
sky.addColorStop(0.58, palette.mid);
|
||||
sky.addColorStop(1, palette.horizon);
|
||||
}
|
||||
ctx.fillStyle = sky || palette.mid;
|
||||
ctx.fillRect(0, 0, g.FIELD_W, g.FIELD_H);
|
||||
drawStars(ctx, v, palette);
|
||||
drawSun(ctx, g, palette);
|
||||
drawClouds(ctx, v, palette);
|
||||
}
|
||||
|
||||
// How a wing sits at this moment of its beat, from -1 (down) to 1 (up).
|
||||
const flapAt = (clock, phase) => Math.sin(clock * FLAP_RATE + phase);
|
||||
|
||||
function birdBody(ctx, x, y, r) {
|
||||
ctx.moveTo(x + r, y);
|
||||
ctx.ellipse(x, y, r, r * 0.5, 0, 0, TAU);
|
||||
ctx.moveTo(x + r * 0.85, y - r * 0.2);
|
||||
ctx.lineTo(x + r * 1.5, y);
|
||||
ctx.lineTo(x + r * 0.85, y + r * 0.2);
|
||||
ctx.closePath();
|
||||
}
|
||||
|
||||
// A wing from the shoulder at x, its tip `lift` above the body and swept back.
|
||||
function birdWing(ctx, x, y, r, lift) {
|
||||
ctx.moveTo(x + r * 0.4, y);
|
||||
ctx.quadraticCurveTo(x, y - lift * 0.7, x - r * 0.75, y - lift);
|
||||
ctx.quadraticCurveTo(x - r * 0.3, y - lift * 0.25, x - r * 0.45, y);
|
||||
ctx.closePath();
|
||||
}
|
||||
|
||||
// A small bird flying right, `r` units long: a body and two wings on their beat,
|
||||
// each filled on its own, with a rim under them when the sky needs one.
|
||||
function drawBird(ctx, x, y, r, color, beat, rim) {
|
||||
const near = r * 1.5 * beat;
|
||||
const far = r * 1.05 * beat;
|
||||
const back = x - r * 0.4;
|
||||
if (rim) {
|
||||
ctx.strokeStyle = rim;
|
||||
ctx.lineWidth = RIM;
|
||||
ctx.beginPath();
|
||||
birdBody(ctx, x, y, r);
|
||||
birdWing(ctx, x, y, r, near);
|
||||
birdWing(ctx, back, y, r, far);
|
||||
ctx.stroke();
|
||||
}
|
||||
ctx.fillStyle = color;
|
||||
ctx.beginPath();
|
||||
birdBody(ctx, x, y, r);
|
||||
ctx.fill();
|
||||
ctx.beginPath();
|
||||
birdWing(ctx, back, y, r, far);
|
||||
ctx.fill();
|
||||
ctx.beginPath();
|
||||
birdWing(ctx, x, y, r, near);
|
||||
ctx.fill();
|
||||
}
|
||||
|
||||
function drawStar(ctx, x, y, r, color) {
|
||||
ctx.fillStyle = color;
|
||||
ctx.strokeStyle = LEADER_INK;
|
||||
ctx.lineWidth = 0.14;
|
||||
ctx.beginPath();
|
||||
for (let k = 0; k < 10; k++) {
|
||||
const a = -Math.PI / 2 + (k * Math.PI) / 5;
|
||||
const d = k % 2 ? r * 0.42 : r;
|
||||
if (k) ctx.lineTo(x + Math.cos(a) * d, y + Math.sin(a) * d);
|
||||
else ctx.moveTo(x + Math.cos(a) * d, y + Math.sin(a) * d);
|
||||
}
|
||||
ctx.closePath();
|
||||
ctx.stroke();
|
||||
ctx.fill();
|
||||
}
|
||||
|
||||
function roundedBox(ctx, x, y, w, h, r) {
|
||||
ctx.beginPath();
|
||||
ctx.moveTo(x + r, y);
|
||||
ctx.lineTo(x + w - r, y);
|
||||
ctx.quadraticCurveTo(x + w, y, x + w, y + r);
|
||||
ctx.lineTo(x + w, y + h - r);
|
||||
ctx.quadraticCurveTo(x + w, y + h, x + w - r, y + h);
|
||||
ctx.lineTo(x + r, y + h);
|
||||
ctx.quadraticCurveTo(x, y + h, x, y + h - r);
|
||||
ctx.lineTo(x, y + r);
|
||||
ctx.quadraticCurveTo(x, y, x + r, y);
|
||||
ctx.closePath();
|
||||
}
|
||||
|
||||
// Planny leads, in bird form: his box in your highlight, the star for an eye, two
|
||||
// wings on the beat and his feet tucked up, tilted with his climb. He blinks
|
||||
// while nothing can hit him.
|
||||
function drawLeader(ctx, v) {
|
||||
const { leader } = v.round;
|
||||
const you = v.colors.you;
|
||||
const beat = flapAt(v.clock, 0);
|
||||
if (leader.grace > 0 && Math.floor(v.clock / BLINK_MS) % 2) ctx.globalAlpha = 0.35;
|
||||
ctx.save();
|
||||
ctx.translate(leader.sx, leader.y);
|
||||
ctx.rotate(Math.max(-1, Math.min(1, leader.vy / v.g.CLIMB)) * LEADER_TILT);
|
||||
const wing = (x, lift) => {
|
||||
ctx.beginPath();
|
||||
birdWing(ctx, x, 0, 2.2, lift);
|
||||
ctx.fillStyle = you;
|
||||
ctx.fill();
|
||||
ctx.strokeStyle = LEADER_INK;
|
||||
ctx.lineWidth = 0.22;
|
||||
ctx.stroke();
|
||||
};
|
||||
wing(-1.2, 2.7 * beat);
|
||||
ctx.strokeStyle = LEADER_INK;
|
||||
ctx.lineWidth = 0.32;
|
||||
ctx.beginPath();
|
||||
ctx.moveTo(-0.9, LEADER_H / 2);
|
||||
ctx.lineTo(-1.9, LEADER_H / 2 + 0.55);
|
||||
ctx.moveTo(0.5, LEADER_H / 2);
|
||||
ctx.lineTo(-0.5, LEADER_H / 2 + 0.55);
|
||||
ctx.stroke();
|
||||
ctx.fillStyle = GOLD;
|
||||
ctx.beginPath();
|
||||
ctx.moveTo(LEADER_W / 2 - 0.1, -0.6);
|
||||
ctx.lineTo(LEADER_W / 2 + 1.1, 0.1);
|
||||
ctx.lineTo(LEADER_W / 2 - 0.1, 0.8);
|
||||
ctx.closePath();
|
||||
ctx.fill();
|
||||
roundedBox(ctx, -LEADER_W / 2, -LEADER_H / 2, LEADER_W, LEADER_H, 1.1);
|
||||
ctx.fillStyle = you;
|
||||
ctx.fill();
|
||||
ctx.strokeStyle = LEADER_INK;
|
||||
ctx.lineWidth = 0.25;
|
||||
ctx.stroke();
|
||||
drawStar(ctx, 0.75, -0.45, 1.1, GOLD);
|
||||
wing(-0.5, 3.1 * beat);
|
||||
ctx.restore();
|
||||
ctx.globalAlpha = 1;
|
||||
}
|
||||
|
||||
// A hot-air balloon: the striped envelope (its hit circle), ropes and a basket.
|
||||
function drawHotAir(ctx, x, y, r) {
|
||||
disc(ctx, x, y, r, HAZARD_COLORS.balloon);
|
||||
ctx.fillStyle = BALLOON_CREAM;
|
||||
ctx.beginPath();
|
||||
ctx.ellipse(x, y, r * 0.62, r * 0.98, 0, 0, TAU);
|
||||
ctx.fill();
|
||||
ctx.fillStyle = HAZARD_COLORS.balloon;
|
||||
ctx.beginPath();
|
||||
ctx.ellipse(x, y, r * 0.26, r * 0.98, 0, 0, TAU);
|
||||
ctx.fill();
|
||||
ctx.strokeStyle = BASKET;
|
||||
ctx.lineWidth = 0.18;
|
||||
ctx.beginPath();
|
||||
ctx.moveTo(x - r * 0.5, y + r * 0.85);
|
||||
ctx.lineTo(x - 0.6, y + r + 0.9);
|
||||
ctx.moveTo(x + r * 0.5, y + r * 0.85);
|
||||
ctx.lineTo(x + 0.6, y + r + 0.9);
|
||||
ctx.stroke();
|
||||
ctx.fillStyle = BASKET;
|
||||
ctx.fillRect(x - 0.7, y + r + 0.9, 1.4, 1);
|
||||
}
|
||||
|
||||
// A bunch of party balloons, their strings meeting at a knot under them.
|
||||
function drawBunch(ctx, x, y, h) {
|
||||
const knotY = y + h.h / 2 + 1;
|
||||
ctx.strokeStyle = STRAY_RIM;
|
||||
ctx.lineWidth = 0.14;
|
||||
ctx.beginPath();
|
||||
for (const p of h.parts) {
|
||||
ctx.moveTo(x + p.dx, y + p.dy + p.r);
|
||||
ctx.lineTo(x, knotY);
|
||||
}
|
||||
ctx.stroke();
|
||||
h.parts.forEach((p, i) => {
|
||||
disc(ctx, x + p.dx, y + p.dy, p.r, PARTY[i % PARTY.length]);
|
||||
ctx.globalAlpha = 0.45;
|
||||
disc(ctx, x + p.dx - p.r * 0.35, y + p.dy - p.r * 0.35, p.r * 0.25, "#ffffff");
|
||||
ctx.globalAlpha = 1;
|
||||
});
|
||||
}
|
||||
|
||||
function drawBand(ctx, x, y, w, h, color, alpha) {
|
||||
ctx.globalAlpha = alpha;
|
||||
ctx.fillStyle = color;
|
||||
ctx.fillRect(x, y - h / 2, w, h);
|
||||
ctx.globalAlpha = 1;
|
||||
}
|
||||
|
||||
// A gust's warning: arrows at its height along the right edge, pulsing.
|
||||
function drawGustWarning(ctx, v, h) {
|
||||
const { g } = v;
|
||||
ctx.globalAlpha = 0.55 + 0.45 * Math.sin(v.clock * 0.014);
|
||||
ctx.strokeStyle = HAZARD_COLORS.gust;
|
||||
ctx.lineWidth = 0.5;
|
||||
for (let k = 0; k < 3; k++) {
|
||||
const x = g.FIELD_W - 2 - k * 2.4;
|
||||
ctx.beginPath();
|
||||
ctx.moveTo(x, h.y - h.h / 2);
|
||||
ctx.lineTo(x - 1.6, h.y);
|
||||
ctx.lineTo(x, h.y + h.h / 2);
|
||||
ctx.stroke();
|
||||
}
|
||||
ctx.globalAlpha = 1;
|
||||
}
|
||||
|
||||
// A live gust: a white band, streaked along its way.
|
||||
function drawGust(ctx, v, h, sx) {
|
||||
drawBand(ctx, sx, h.y, h.w, h.h, HAZARD_COLORS.gust, 0.28);
|
||||
ctx.globalAlpha = 0.75;
|
||||
ctx.strokeStyle = "#ffffff";
|
||||
ctx.lineWidth = 0.28;
|
||||
for (let k = 0; k < 7; k++) {
|
||||
const at = (k * 5.3 + v.clock * 0.03) % h.w;
|
||||
const y = h.y + ((k % 3) - 1) * (h.h / 3.2);
|
||||
ctx.beginPath();
|
||||
ctx.moveTo(sx + h.w - at, y);
|
||||
ctx.lineTo(sx + h.w - at + 4, y);
|
||||
ctx.stroke();
|
||||
}
|
||||
ctx.globalAlpha = 1;
|
||||
}
|
||||
|
||||
// Streaks flowing toward the player at twice the stage's speed.
|
||||
function drawStream(ctx, v, h, sx) {
|
||||
drawBand(ctx, sx, h.y, h.w, h.h, HAZARD_COLORS.stream, 0.22);
|
||||
ctx.strokeStyle = HAZARD_COLORS.stream;
|
||||
ctx.lineWidth = 0.25;
|
||||
for (const y of [h.y - h.h / 2, h.y + h.h / 2]) {
|
||||
ctx.beginPath();
|
||||
ctx.moveTo(sx, y);
|
||||
ctx.lineTo(sx + h.w, y);
|
||||
ctx.stroke();
|
||||
}
|
||||
const flow = (v.clock / 1000) * v.round.speed * 2;
|
||||
for (let row = 0; row < 3; row++) {
|
||||
const y = h.y + (row - 1) * (h.h / 3);
|
||||
for (let at = (row * 7 - flow) % STREAK_GAP; at < h.w; at += STREAK_GAP) {
|
||||
if (at < 0) continue;
|
||||
ctx.beginPath();
|
||||
ctx.moveTo(sx + at, y);
|
||||
ctx.lineTo(sx + Math.min(h.w, at + STREAK_LEN), y);
|
||||
ctx.stroke();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// A kite on its string, the line that snaps a bird: a diamond with its spars and
|
||||
// a tail of bows that swings with the kite, hanging away from its string.
|
||||
function drawKite(ctx, v, h, sx, tipX) {
|
||||
const { g } = v;
|
||||
const R = g.KITE_R;
|
||||
ctx.strokeStyle = STRAY_RIM;
|
||||
ctx.lineWidth = 0.3;
|
||||
ctx.beginPath();
|
||||
ctx.moveTo(sx, h.top ? 0 : g.FIELD_H);
|
||||
ctx.lineTo(tipX, h.y);
|
||||
ctx.stroke();
|
||||
ctx.fillStyle = HAZARD_COLORS.kite;
|
||||
ctx.beginPath();
|
||||
ctx.moveTo(tipX, h.y - R);
|
||||
ctx.lineTo(tipX + R, h.y);
|
||||
ctx.lineTo(tipX, h.y + R);
|
||||
ctx.lineTo(tipX - R, h.y);
|
||||
ctx.closePath();
|
||||
ctx.fill();
|
||||
ctx.strokeStyle = BALLOON_CREAM;
|
||||
ctx.lineWidth = 0.18;
|
||||
ctx.beginPath();
|
||||
ctx.moveTo(tipX, h.y - R);
|
||||
ctx.lineTo(tipX, h.y + R);
|
||||
ctx.moveTo(tipX - R, h.y);
|
||||
ctx.lineTo(tipX + R, h.y);
|
||||
ctx.stroke();
|
||||
const swing = Math.sin(v.clock * 0.004 + h.phase) * 0.7;
|
||||
const away = h.top ? 1 : -1;
|
||||
ctx.fillStyle = "#ffd23f";
|
||||
for (let k = 1; k <= 3; k++) {
|
||||
const x = tipX + swing * k * 0.6 - k * 0.5;
|
||||
const y = h.y + away * (R + k * 1.1);
|
||||
ctx.beginPath();
|
||||
ctx.moveTo(x - 0.5, y - 0.3);
|
||||
ctx.lineTo(x + 0.5, y + 0.3);
|
||||
ctx.lineTo(x + 0.5, y - 0.3);
|
||||
ctx.lineTo(x - 0.5, y + 0.3);
|
||||
ctx.closePath();
|
||||
ctx.fill();
|
||||
}
|
||||
}
|
||||
|
||||
// A dark cloud; while it beats, a warning column that pulses, then the strike
|
||||
// down it as a jagged bolt inside the column it can hit.
|
||||
function drawStorm(ctx, v, h, sx) {
|
||||
const { g, round } = v;
|
||||
disc(ctx, sx - h.w * 0.25, h.y, h.h * 0.8, HAZARD_COLORS.storm);
|
||||
disc(ctx, sx + h.w * 0.25, h.y, h.h * 0.8, HAZARD_COLORS.storm);
|
||||
disc(ctx, sx, h.y - h.h * 0.2, h.h, HAZARD_COLORS.storm);
|
||||
ctx.globalAlpha = 0.5;
|
||||
ctx.fillStyle = "#5a5474";
|
||||
ctx.beginPath();
|
||||
ctx.ellipse(sx, h.y - h.h * 0.45, h.w * 0.32, h.h * 0.4, 0, 0, TAU);
|
||||
ctx.fill();
|
||||
ctx.globalAlpha = 1;
|
||||
if (h.phase === "idle") return;
|
||||
const [lo, hi] = h.top ? [h.y, h.y + g.STORM_REACH] : [h.y - g.STORM_REACH, h.y];
|
||||
const mid = h.col - round.scroll;
|
||||
const col = mid - g.STORM_COL / 2;
|
||||
if (h.phase === "warn") {
|
||||
drawBand(ctx, col, (lo + hi) / 2, g.STORM_COL, hi - lo, DANGER, 0.2 + 0.2 * Math.abs(Math.sin(v.clock * 0.02)));
|
||||
return;
|
||||
}
|
||||
drawBand(ctx, col, (lo + hi) / 2, g.STORM_COL, hi - lo, "#fff7b0", 0.5);
|
||||
ctx.strokeStyle = "#ffffff";
|
||||
ctx.lineWidth = 0.55;
|
||||
ctx.beginPath();
|
||||
for (let k = 0; k <= JAG_STEPS; k++) {
|
||||
const t = k / JAG_STEPS;
|
||||
const x = mid + (k === 0 ? 0 : (scatter(round.seed, Math.floor(h.beat) + k) - 0.5) * g.STORM_COL * 0.9);
|
||||
const y = h.top ? lo + (hi - lo) * t : hi - (hi - lo) * t;
|
||||
if (k) ctx.lineTo(x, y);
|
||||
else ctx.moveTo(x, y);
|
||||
}
|
||||
ctx.stroke();
|
||||
}
|
||||
|
||||
function drawHazards(ctx, v) {
|
||||
const { g, round } = v;
|
||||
for (const h of round.hazards) {
|
||||
const sx = h.x - round.scroll;
|
||||
if (h.kind === "gust") {
|
||||
if (h.warnAt === undefined) continue;
|
||||
if (h.live) drawGust(ctx, v, h, sx);
|
||||
else drawGustWarning(ctx, v, h);
|
||||
continue;
|
||||
}
|
||||
if (sx - h.w > g.FIELD_W || sx + h.w < 0) continue;
|
||||
if (h.kind === "balloon") drawHotAir(ctx, sx, h.y, h.r);
|
||||
else if (h.kind === "cluster") drawBunch(ctx, sx, h.y, h);
|
||||
else if (h.kind === "kite") drawKite(ctx, v, h, sx, h.tipX - round.scroll);
|
||||
else if (h.kind === "stream") drawStream(ctx, v, h, sx);
|
||||
else if (h.kind === "storm") drawStorm(ctx, v, h, sx);
|
||||
}
|
||||
}
|
||||
|
||||
// The jet stream's glowing swirl ring, seen a little from the side. The last one
|
||||
// has the smaller ring and the larger glow.
|
||||
function drawPortal(ctx, v) {
|
||||
const { portal, scroll, stage } = v.round;
|
||||
const final = stage === v.g.MAX_STAGE;
|
||||
const glow = final ? GLOW_FINAL : GLOW;
|
||||
const rx = final ? RING_RX_FINAL : RING_RX;
|
||||
const ry = portal.h / 2;
|
||||
const sx = portal.x - scroll;
|
||||
if (sx < -rx - glow * GLOW_STEPS || sx > v.g.FIELD_W + rx + glow * GLOW_STEPS) return;
|
||||
ctx.strokeStyle = GOLD;
|
||||
ctx.globalAlpha = 0.14;
|
||||
for (let k = GLOW_STEPS; k >= 1; k--) {
|
||||
ctx.lineWidth = 0.8 + k * glow;
|
||||
ctx.beginPath();
|
||||
ctx.ellipse(sx, portal.y, rx, ry, 0, 0, TAU);
|
||||
ctx.stroke();
|
||||
}
|
||||
ctx.globalAlpha = 1;
|
||||
ctx.lineWidth = 0.8;
|
||||
ctx.beginPath();
|
||||
ctx.ellipse(sx, portal.y, rx, ry, 0, 0, TAU);
|
||||
ctx.stroke();
|
||||
ctx.strokeStyle = "#fff7d6";
|
||||
ctx.lineWidth = 0.35;
|
||||
for (let k = 0; k < 4; k++) {
|
||||
const from = v.clock * 0.005 + (k * TAU) / 4;
|
||||
ctx.beginPath();
|
||||
ctx.ellipse(sx, portal.y, rx * 0.68, ry * 0.92, 0, from, from + 1.1);
|
||||
ctx.stroke();
|
||||
}
|
||||
}
|
||||
|
||||
// While the V forms: a faint gold line along each arm as the flock glides in.
|
||||
function drawV(ctx, v) {
|
||||
const { portal, flock, leader, scroll } = v.round;
|
||||
if (!portal.v || !flock.length) return;
|
||||
const ends = [flock[flock.length - 1], flock[Math.max(0, flock.length - 2)]];
|
||||
if (typeof ends[0].x !== "number" || typeof ends[1].x !== "number") return;
|
||||
ctx.globalAlpha = 0.5 * Math.max(0, Math.min(1, Math.min(portal.v.t, v.g.V_MS - portal.v.t) / V_FADE_MS));
|
||||
ctx.strokeStyle = GOLD;
|
||||
ctx.lineWidth = 0.4;
|
||||
ctx.beginPath();
|
||||
ctx.moveTo(ends[0].x - scroll, ends[0].y);
|
||||
ctx.lineTo(leader.sx, leader.y);
|
||||
ctx.lineTo(ends[1].x - scroll, ends[1].y);
|
||||
ctx.stroke();
|
||||
ctx.globalAlpha = 1;
|
||||
}
|
||||
|
||||
// Loose birds fade through their last second, but stay faintly in sight as they
|
||||
// fly off.
|
||||
function drawScattered(ctx, v) {
|
||||
const { round } = v;
|
||||
for (const b of round.scattered) {
|
||||
ctx.globalAlpha = Math.max(LOOSE_ALPHA_MIN, Math.min(1, (b.until - round.now) / 1000));
|
||||
drawBird(ctx, b.x - round.scroll, b.y, 1.3, STRAY_COLOR, flapAt(v.clock, b.id * 1.7), STRAY_RIM);
|
||||
}
|
||||
ctx.globalAlpha = 1;
|
||||
}
|
||||
|
||||
// A crate: a small box in its power's color with a soft glow.
|
||||
function drawCrates(ctx, v) {
|
||||
const { g, round } = v;
|
||||
for (const c of round.crates) {
|
||||
const sx = c.x - round.scroll;
|
||||
if (sx < -CRATE_GLOW || sx > g.FIELD_W + CRATE_GLOW) continue;
|
||||
const color = POWER_COLORS[c.kind];
|
||||
ctx.globalAlpha = 0.3;
|
||||
disc(ctx, sx, c.y, CRATE_GLOW, color);
|
||||
ctx.globalAlpha = 1;
|
||||
ctx.fillStyle = color;
|
||||
ctx.fillRect(sx - CRATE_BOX / 2, c.y - CRATE_BOX / 2, CRATE_BOX, CRATE_BOX);
|
||||
ctx.strokeStyle = FLOCK_COLOR;
|
||||
ctx.lineWidth = 0.25;
|
||||
ctx.strokeRect(sx - CRATE_BOX / 2, c.y - CRATE_BOX / 2, CRATE_BOX, CRATE_BOX);
|
||||
}
|
||||
}
|
||||
|
||||
// How far the magnet reaches, as a faint ring around the leader.
|
||||
function drawMagnetRing(ctx, v) {
|
||||
const { g, round } = v;
|
||||
if (round.active.magnet <= 0 || !round.leader.alive) return;
|
||||
ctx.globalAlpha = 0.35;
|
||||
ctx.strokeStyle = POWER_COLORS.magnet;
|
||||
ctx.lineWidth = 0.3;
|
||||
ctx.beginPath();
|
||||
ctx.arc(round.leader.sx, round.leader.y, g.MAGNET_REACH, 0, TAU);
|
||||
ctx.stroke();
|
||||
ctx.globalAlpha = 1;
|
||||
}
|
||||
|
||||
// Speed streaks rushing away behind the last bird of the line.
|
||||
function drawTailwind(ctx, v) {
|
||||
const { round } = v;
|
||||
if (round.active.tailwind <= 0 || !round.leader.alive) return;
|
||||
const last = round.flock[round.flock.length - 1];
|
||||
const tail = last && typeof last.x === "number" ? last : { x: round.leader.x, y: round.leader.y };
|
||||
const x = tail.x - round.scroll - 2;
|
||||
ctx.globalAlpha = 0.6;
|
||||
ctx.strokeStyle = POWER_COLORS.tailwind;
|
||||
ctx.lineWidth = 0.3;
|
||||
for (let k = 0; k < WIND_STREAKS; k++) {
|
||||
const back = (k * 5 + (v.clock / 1000) * WIND_RATE) % WIND_RUN;
|
||||
const y = tail.y + (k - (WIND_STREAKS - 1) / 2) * 1.4;
|
||||
ctx.beginPath();
|
||||
ctx.moveTo(x - back, y);
|
||||
ctx.lineTo(x - back - WIND_LEN, y);
|
||||
ctx.stroke();
|
||||
}
|
||||
ctx.globalAlpha = 1;
|
||||
}
|
||||
|
||||
function label(ctx, text, x, y, size, color, maxWidth) {
|
||||
ctx.font = `800 ${size}px system-ui, -apple-system, "Segoe UI", sans-serif`;
|
||||
ctx.textAlign = "center";
|
||||
ctx.textBaseline = "middle";
|
||||
ctx.fillStyle = color;
|
||||
ctx.fillText(text, x, y, maxWidth);
|
||||
}
|
||||
|
||||
// A strip across the field, its place chosen away from the leader, fading out
|
||||
// at the end of its time and to see-through while anything is under it.
|
||||
function drawBanner(ctx, v, b) {
|
||||
const { g, round } = v;
|
||||
const p = 1 - Math.max(0, b.until - round.now) / b.ms;
|
||||
ctx.globalAlpha = (p > 0.82 ? Math.max(0, (1 - p) / 0.18) : 1) * b.see;
|
||||
ctx.fillStyle = BANNER_SHADE;
|
||||
ctx.fillRect(0, b.row - g.BANNER_HALF, g.FIELD_W, g.BANNER_HALF * 2);
|
||||
label(ctx, b.text, g.FIELD_W / 2, b.row - 1, 4.2, b.color, g.FIELD_W - 4);
|
||||
if (b.sub) label(ctx, b.sub, g.FIELD_W / 2, b.row + 3.2, 2.2, "#ffffff", g.FIELD_W - 4);
|
||||
ctx.globalAlpha = 1;
|
||||
}
|
||||
|
||||
// The end of a run, along the bottom of the field (the window's own message sits
|
||||
// in the middle): how it went, the score, the best, and the nudge to go again.
|
||||
function drawEnd(ctx, v, end) {
|
||||
const { g } = v;
|
||||
const top = g.FIELD_H - END_H;
|
||||
const mid = g.FIELD_W / 2;
|
||||
ctx.fillStyle = END_SHADE;
|
||||
ctx.fillRect(0, top, g.FIELD_W, END_H);
|
||||
const title = end.won ? (end.flawless ? `You made it! Flawless +${end.flawless}` : "You made it!") : "Out of lives";
|
||||
label(ctx, title, mid, top + 2.8, 2.8, end.won ? GOLD : "#ffffff", g.FIELD_W - 4);
|
||||
label(ctx, String(end.score), mid, top + 7.8, 6, GOLD, g.FIELD_W - 4);
|
||||
label(ctx, end.fresh ? `A new best! ${end.best}` : `Best ${end.best}`, mid, top + 12.2, 2.2, "#ffffff", g.FIELD_W - 4);
|
||||
label(ctx, end.teaser, mid, top + 15.6, 2.2, "#ffffff", g.FIELD_W - 4);
|
||||
}
|
||||
|
||||
export function drawScene(ctx, v) {
|
||||
const { g, round } = v;
|
||||
ctx.save();
|
||||
ctx.scale(v.u, v.u);
|
||||
ctx.fillStyle = v.colors.board;
|
||||
ctx.fillRect(0, 0, g.W, g.H);
|
||||
drawHud(ctx, v);
|
||||
ctx.translate(g.PAD, g.HUD_H);
|
||||
ctx.save();
|
||||
ctx.beginPath();
|
||||
ctx.rect(0, 0, g.FIELD_W, g.FIELD_H);
|
||||
if (typeof ctx.clip === "function") ctx.clip();
|
||||
drawSky(ctx, v);
|
||||
drawHazards(ctx, v);
|
||||
drawPortal(ctx, v);
|
||||
drawCrates(ctx, v);
|
||||
drawMagnetRing(ctx, v);
|
||||
drawTailwind(ctx, v);
|
||||
drawV(ctx, v);
|
||||
for (const s of round.strays) {
|
||||
drawBird(ctx, s.x - round.scroll, s.y + Math.sin(v.clock * BOB_RATE + s.bob) * BOB, 1.3, STRAY_COLOR, flapAt(v.clock, s.bob), STRAY_RIM);
|
||||
}
|
||||
const { rim } = skyFor(round.stage);
|
||||
for (const b of round.flock) {
|
||||
if (typeof b.x === "number") drawBird(ctx, b.x - round.scroll, b.y, 1.4, FLOCK_COLOR, flapAt(v.clock, b.id * 1.7), rim);
|
||||
}
|
||||
drawScattered(ctx, v);
|
||||
if (round.leader.alive || v.state === "over") drawLeader(ctx, v);
|
||||
if (v.end) drawEnd(ctx, v, v.end);
|
||||
else if (round.banner && round.banner.row !== null) drawBanner(ctx, v, round.banner);
|
||||
ctx.restore();
|
||||
ctx.translate(-g.PAD, -g.HUD_H);
|
||||
drawPills(ctx, v);
|
||||
ctx.restore();
|
||||
}
|
||||
@@ -0,0 +1,147 @@
|
||||
// Plan2Code Web Console - flock: its own sound effects, merged into tones.js beside the shared kit; defines only.
|
||||
//
|
||||
// `tones` are one-shot sounds played with tone(name, level, pitch); `hums` are
|
||||
// held sounds kept going with hum(id, name, level, pitch). Both take the shapes
|
||||
// tones.js documents, as plain objects (tones.js freezes them). A name may be
|
||||
// defined only once across tones.js and every game's file. No imports.
|
||||
|
||||
export default {
|
||||
// The music: recorded songs, each a name to an mp3 the server serves (listed in
|
||||
// SERVABLE), played by music.js one after another in the order flock.js deals them.
|
||||
songs: {
|
||||
flockSong1: "activities/flock-dash/1.mp3",
|
||||
flockSong2: "activities/flock-dash/2.mp3",
|
||||
flockSong3: "activities/flock-dash/3.mp3",
|
||||
flockSong4: "activities/flock-dash/4.mp3",
|
||||
flockSong5: "activities/flock-dash/5.mp3",
|
||||
},
|
||||
tones: {
|
||||
// A stray picked up: a short, bright bird chirp (the game raises its pitch
|
||||
// with the combo, so it stays soft and under a tenth of a second).
|
||||
flockChirp: {
|
||||
layers: [
|
||||
{ type: "triangle", from: 1800, to: 2600, seconds: 0.07, gain: 0.25 },
|
||||
{ type: "sine", from: 2400, to: 3200, seconds: 0.05, gain: 0.12 },
|
||||
],
|
||||
},
|
||||
// A scattered bird picked back up: a softer, lower two-note chirp.
|
||||
flockRejoin: {
|
||||
layers: [{ type: "triangle", notes: [1047, 1319], seconds: 0.1, gain: 0.22 }],
|
||||
},
|
||||
// The line snapping: a plucked tone falling away, and a flutter of bandpassed noise.
|
||||
flockSnap: {
|
||||
layers: [
|
||||
{ type: "triangle", from: 660, to: 220, seconds: 0.25, gain: 0.45, filter: { type: "lowpass", from: 2400, to: 500 } },
|
||||
{ type: "noise", seconds: 0.03, gain: 0.3, filter: { type: "bandpass", from: 2500, to: 1800, q: 3 } },
|
||||
{ type: "noise", seconds: 0.03, delay: 0.05, gain: 0.25, filter: { type: "bandpass", from: 2500, to: 1800, q: 3 } },
|
||||
{ type: "noise", seconds: 0.03, delay: 0.1, gain: 0.2, filter: { type: "bandpass", from: 2500, to: 1800, q: 3 } },
|
||||
],
|
||||
},
|
||||
// The leader hit: a thump and a squawk.
|
||||
flockHit: {
|
||||
layers: [
|
||||
{ type: "sine", from: 150, to: 50, seconds: 0.15, gain: 0.8 },
|
||||
{ type: "square", from: 500, to: 220, seconds: 0.15, gain: 0.3, filter: { type: "lowpass", from: 2000, to: 800 } },
|
||||
],
|
||||
},
|
||||
// A shield soaking a hit: a bright metallic ping over a soft whoosh.
|
||||
flockShield: {
|
||||
layers: [
|
||||
{ type: "sine", from: 2400, to: 2400, seconds: 0.35, gain: 0.3 },
|
||||
{ type: "triangle", from: 3136, to: 3136, seconds: 0.25, delay: 0.02, gain: 0.15 },
|
||||
{ type: "pink", seconds: 0.3, attack: 0.1, gain: 0.2, filter: { type: "bandpass", from: 700, to: 2600, q: 1.4 } },
|
||||
],
|
||||
},
|
||||
// A crate opened: a sparkling rise.
|
||||
flockPower: {
|
||||
layers: [
|
||||
{ type: "triangle", notes: [1047, 1319, 1568, 2093, 2637], seconds: 0.4, gain: 0.4 },
|
||||
{ type: "sine", from: 2000, to: 4000, seconds: 0.4, gain: 0.15 },
|
||||
],
|
||||
},
|
||||
// The gust warning: a rising whoosh of pink noise.
|
||||
flockGust: {
|
||||
layers: [{ type: "pink", seconds: 0.6, attack: 0.3, gain: 0.5, filter: { type: "bandpass", from: 200, to: 1400, q: 1.2 } }],
|
||||
},
|
||||
// The storm warning: a low crackle of noise.
|
||||
flockThunder: {
|
||||
layers: [
|
||||
{ type: "brown", seconds: 0.5, gain: 0.6, filter: { type: "lowpass", from: 260, to: 140 } },
|
||||
{ type: "noise", seconds: 0.04, delay: 0.1, gain: 0.3, filter: { type: "bandpass", from: 1200, to: 900, q: 2 } },
|
||||
{ type: "noise", seconds: 0.04, delay: 0.22, gain: 0.25, filter: { type: "bandpass", from: 1200, to: 900, q: 2 } },
|
||||
{ type: "noise", seconds: 0.04, delay: 0.32, gain: 0.3, filter: { type: "bandpass", from: 1200, to: 900, q: 2 } },
|
||||
],
|
||||
},
|
||||
// Lightning striking: a sharp white crack with a low boom under it.
|
||||
flockStrike: {
|
||||
layers: [
|
||||
{ type: "noise", seconds: 0.12, gain: 0.6, filter: { type: "highpass", from: 4000, to: 1500 } },
|
||||
{ type: "sine", from: 90, to: 35, seconds: 0.5, gain: 0.8 },
|
||||
{ type: "brown", seconds: 0.4, gain: 0.4, filter: { type: "lowpass", from: 300, to: 80 } },
|
||||
],
|
||||
},
|
||||
// A portal passed: a whooshing shimmer.
|
||||
flockPortal: {
|
||||
layers: [
|
||||
{ type: "sine", from: 500, to: 1500, seconds: 0.7, attack: 0.2, gain: 0.3, vibrato: { rate: 14, depth: 0.04 } },
|
||||
{ type: "pink", seconds: 0.7, attack: 0.2, gain: 0.3, filter: { type: "bandpass", from: 400, to: 3000, q: 2 } },
|
||||
],
|
||||
},
|
||||
// The V formed: a rising arpeggio of triangle notes.
|
||||
flockV: {
|
||||
layers: [{ type: "triangle", notes: [523, 659, 784, 1047], seconds: 0.4, gain: 0.5 }],
|
||||
},
|
||||
// A flawless stage: a bright little fanfare.
|
||||
flockFlawless: {
|
||||
layers: [
|
||||
{ type: "triangle", notes: [784, 784, 988, 1319], seconds: 0.44, gain: 0.5 },
|
||||
{ type: "square", notes: [392, 392, 494, 659], seconds: 0.44, gain: 0.25, filter: { type: "lowpass", from: 2400, to: 2400 } },
|
||||
],
|
||||
},
|
||||
// A new stage: a clean four-note climb.
|
||||
flockStage: {
|
||||
layers: [
|
||||
{ type: "triangle", notes: [523, 659, 784, 1047], seconds: 0.3, gain: 0.45 },
|
||||
{ type: "square", notes: [262, 330, 392, 523], seconds: 0.3, gain: 0.15, filter: { type: "lowpass", from: 1600, to: 1600 } },
|
||||
],
|
||||
},
|
||||
// A new best: a short sparkling run.
|
||||
flockBest: {
|
||||
layers: [
|
||||
{ type: "triangle", notes: [1568, 2093, 2637, 3136, 2637, 3136], seconds: 0.3, gain: 0.4 },
|
||||
{ type: "noise", seconds: 0.2, gain: 0.1, filter: { type: "highpass", from: 6000, to: 8000 } },
|
||||
],
|
||||
},
|
||||
// Game over: a falling run.
|
||||
flockOver: {
|
||||
layers: [
|
||||
{ type: "triangle", notes: [523, 466, 392, 330, 262], seconds: 0.6, gain: 0.5 },
|
||||
{ type: "sawtooth", notes: [262, 233, 196, 165], seconds: 0.6, gain: 0.2, filter: { type: "lowpass", from: 900, to: 500 } },
|
||||
],
|
||||
},
|
||||
// The run won: a longer, happy fanfare.
|
||||
flockWin: {
|
||||
layers: [
|
||||
{ type: "triangle", notes: [523, 659, 784, 659, 784, 1047], seconds: 0.9, gain: 0.5 },
|
||||
{ type: "square", notes: [262, 330, 392, 330, 392, 523], seconds: 0.9, gain: 0.25, filter: { type: "lowpass", from: 2400, to: 2400 } },
|
||||
],
|
||||
},
|
||||
},
|
||||
hums: {
|
||||
// The wind past the flock: soft filtered pink noise; pitch follows flight speed.
|
||||
// Kept under the music, so it stays quiet.
|
||||
flockWind: {
|
||||
noise: { color: "pink", gain: 1 },
|
||||
filter: { type: "bandpass", freq: 500, q: 0.8, follow: 1 },
|
||||
pulse: { rate: 0.3, depth: 0.3 },
|
||||
peak: 0.015,
|
||||
},
|
||||
// Riding a slipstream: a faster, brighter rush with a light pulse.
|
||||
flockStream: {
|
||||
noise: { color: "pink", gain: 1 },
|
||||
filter: { type: "bandpass", freq: 1400, q: 1.2, follow: 1 },
|
||||
pulse: { rate: 6, depth: 0.4 },
|
||||
peak: 0.02,
|
||||
},
|
||||
},
|
||||
};
|
||||
File diff suppressed because it is too large.
Load diff
@@ -2650,13 +2650,13 @@
|
||||
<p class="help-lead">
|
||||
The <strong>die</strong> in the top bar opens
|
||||
<strong>Activities</strong>: small games to play while you wait, say
|
||||
through a long build. Twelve games ship: <strong>Snake</strong>,
|
||||
through a long build. Thirteen games ship: <strong>Snake</strong>,
|
||||
<strong>Mini golf</strong>, <strong>Light Trails</strong>,
|
||||
<strong>Bug Hunt</strong>, <strong>Sunset Drive</strong>,
|
||||
<strong>Stack Deploy</strong>, <strong>Bumper Ring</strong>,
|
||||
<strong>Rapids Run</strong>, <strong>Hot Potato</strong>,
|
||||
<strong>Crossing Rush</strong>, <strong>Bounce Road</strong> and
|
||||
<strong>Ghoul Rush</strong>. The window opens on a card for each game, with its best score; click one
|
||||
<strong>Crossing Rush</strong>, <strong>Bounce Road</strong>,
|
||||
<strong>Ghoul Rush</strong> and <strong>Flock Dash</strong>. The window opens on a card for each game, with its best score; click one
|
||||
(or walk them with the arrows and press <kbd>Space</kbd>) to play it,
|
||||
and <strong>All games</strong> takes you back. One game plays at a
|
||||
time: a round left for the cards waits, paused, on its card, and
|
||||
@@ -2959,6 +2959,18 @@
|
||||
lost; and 2000 for the Gourd and 2500 for Rattlebones, times the
|
||||
lap, with a life back.
|
||||
</li>
|
||||
<li>
|
||||
<strong>Flock Dash</strong>: lead Planny's flock through a sunset
|
||||
sky. Strays drift in from the right; fly into one and it joins the
|
||||
flock, following the exact path you flew. Balloons, gusts,
|
||||
slipstreams, storm clouds and kites are in the way: a hit on the
|
||||
leader costs one of three lives, and a hit on the line snaps it
|
||||
there, scattering the birds behind (pick them back up within 3
|
||||
seconds or they are gone). Eight stages, each ending at a jet
|
||||
stream portal that forms a V for a bonus when enough birds reach
|
||||
it; the final portal moves. Tailwind, shield and magnet crates help,
|
||||
and quick pickups build a combo of up to x5.
|
||||
</li>
|
||||
</ul>
|
||||
<h4>It never hides your turn</h4>
|
||||
<ul>
|
||||
@@ -3052,6 +3064,11 @@
|
||||
<kbd>Space</kbd> to fire (in bursts: the blaster slows as it heats
|
||||
and cools once you let go).
|
||||
</li>
|
||||
<li>
|
||||
Flock Dash: up and down (or <kbd>W</kbd> and <kbd>S</kbd>) climb and
|
||||
dive, left and right (or <kbd>A</kbd> and <kbd>D</kbd>) ease forward
|
||||
and back.
|
||||
</li>
|
||||
<li><kbd>Space</kbd> starts a round, and plays again after a pause.</li>
|
||||
<li><kbd>P</kbd> pauses and plays.</li>
|
||||
<li><kbd>R</kbd> starts the round over, from the countdown.</li>
|
||||
@@ -3076,7 +3093,7 @@
|
||||
<p>
|
||||
The window's title shows the best for the game on screen, and the
|
||||
line under the board shows it beside your score, and each card shows
|
||||
its game's. For Snake, Light Trails, Bug Hunt, Sunset Drive, Stack Deploy, Bumper Ring, Rapids Run, Hot Potato, Crossing Rush, Bounce Road and Ghoul Rush the best is
|
||||
its game's. For Snake, Light Trails, Bug Hunt, Sunset Drive, Stack Deploy, Bumper Ring, Rapids Run, Hot Potato, Crossing Rush, Bounce Road, Ghoul Rush and Flock Dash the best is
|
||||
your highest score; for Mini golf it is your lowest full round of eighteen holes,
|
||||
kept for each course on its own, and a round left halfway never counts. <strong>Reset best
|
||||
scores</strong>, at the bottom of the window, clears them all after a
|
||||
@@ -3091,7 +3108,7 @@
|
||||
its own <strong>Music</strong> slider under the board for how loud it plays.
|
||||
</p>
|
||||
<p>
|
||||
Best scores, Snake's surprises found, Light Trails' furthest arena, Bug Hunt's finds, Sunset Drive's roads found, Stack Deploy's highest floor, Bumper Ring's furthest arena, Rapids Run's furthest dam, Hot Potato's furthest venue, Crossing Rush's furthest zone, Bounce Road's furthest stage, Ghoul Rush's furthest room, each game's music volume, your last pick and that switch are saved privately on
|
||||
Best scores, Snake's surprises found, Light Trails' furthest arena, Bug Hunt's finds, Sunset Drive's roads found, Stack Deploy's highest floor, Bumper Ring's furthest arena, Rapids Run's furthest dam, Hot Potato's furthest venue, Crossing Rush's furthest zone, Bounce Road's furthest stage, Ghoul Rush's furthest room, Flock Dash's furthest stage, each game's music volume, your last pick and that switch are saved privately on
|
||||
this machine, with your other preferences, and never sent anywhere.
|
||||
</p>
|
||||
</section>
|
||||
|
||||
@@ -907,6 +907,22 @@ const COVERS = Object.freeze({
|
||||
["rect", { x: 59, y: 49.4, width: 6, height: 6, rx: 1.5, fill: "none", "stroke-width": 0.8, class: "cv-ink3-line" }],
|
||||
["path", { d: "M62.0 50.0 L62.6 51.5 L64.2 51.6 L63.0 52.6 L63.4 54.2 L62.0 53.3 L60.6 54.2 L61.0 52.6 L59.8 51.6 L61.4 51.5 Z", class: "cv-accent" }],
|
||||
],
|
||||
flock: [
|
||||
...[0, 1, 2, 3, 4, 5].map((k) => ["rect", { y: k * 10, width: 120, height: 10, fill: ["#4b2a7a", "#6a3b8f", "#944a9c", "#c75b93", "#ec6f7a", "#f5965c"][k] }]),
|
||||
["circle", { cx: 90, cy: 58, r: 8, fill: "#fff3b0" }],
|
||||
["rect", { y: 60, width: 120, height: 12, fill: "#f7c35e" }],
|
||||
...[[8, 22], [18, 28], [28, 24], [38, 30], [48, 34]].map(([x, y]) => ["path", { d: "M-5 0 Q-2.5 -4 0 -0.5 Q2.5 -4 5 0 Q2.5 -1.5 0 1.5 Q-2.5 -1.5 -5 0 Z", transform: `translate(${x} ${y})`, fill: "#2b2140" }]),
|
||||
["path", { d: "M96 6 Q106 6 106 18 Q106 30 98 36 H94 Q86 30 86 18 Q86 6 96 6 Z", fill: "#e2553f", stroke: "#2b2140", "stroke-width": 1 }],
|
||||
["rect", { x: 91, y: 9, width: 3, height: 23, fill: "#f4f1ea" }],
|
||||
["rect", { x: 98, y: 9, width: 3, height: 23, fill: "#f4f1ea" }],
|
||||
["path", { d: "M94 36 L93 39 M98 36 L99 39", stroke: "#2b2140", "stroke-width": 0.8 }],
|
||||
["rect", { x: 92.5, y: 39, width: 7, height: 4.5, rx: 1, fill: "#8a5a30" }],
|
||||
["rect", { transform: "translate(36 6)", x: 20, y: 28, width: 28, height: 22, rx: 9, class: "cv-accent" }],
|
||||
["path", { transform: "translate(36 6)", d: "M47 34 L53 37 L47 40 Z", fill: "#ff8a1f" }],
|
||||
["path", { transform: "translate(36 6)", d: "M24 40 Q32 47 42 40 Q36 46 24 44 Z", fill: "#000000", "fill-opacity": 0.22 }],
|
||||
["path", { transform: "translate(36 6)", d: "M34 31.4 L34.9 33.8 L37.4 33.9 L35.4 35.5 L36.1 37.9 L34 36.5 L31.9 37.9 L32.6 35.5 L30.6 33.9 L33.1 33.8 Z", fill: "#f5b301" }],
|
||||
["path", { transform: "translate(36 6)", d: "M28 50 V53 H31 M37 50 V53 H40", fill: "none", "stroke-width": 1.6, "stroke-linecap": "round", "stroke-linejoin": "round", class: "cv-accent-line" }],
|
||||
],
|
||||
fuse: [
|
||||
["rect", { width: 120, height: 72, fill: "#dcc9a6" }],
|
||||
...[0, 1, 2, 3, 4, 5].flatMap((r) => [0, 1, 2, 3, 4, 5, 6, 7].filter((c) => (c + r) % 2).map((c) => ["rect", { x: c * 16, y: r * 12, width: 16, height: 12, fill: "#d1bc95" }])),
|
||||
|
||||
@@ -13,6 +13,7 @@ import fuseSfx from "./activities/fuse-sfx.js";
|
||||
import hopSfx from "./activities/hop-sfx.js";
|
||||
import bounceSfx from "./activities/bounce-sfx.js";
|
||||
import ghoulSfx from "./activities/ghoul-rush/sfx/ghoul-sfx.js";
|
||||
import flockSfx from "./activities/flock-sfx.js";
|
||||
|
||||
/* ------------------------------------------------------------- tones
|
||||
|
||||
@@ -376,7 +377,7 @@ const HUMS = hums({
|
||||
|
||||
// Every game's own extras, merged after the shared kit; a name may be
|
||||
// defined only once across them all (the activities suite checks).
|
||||
const GAME_SFX = Object.freeze([snakeSfx, golfSfx, trailsSfx, bugsSfx, driveSfx, stackSfx, bumperSfx, rapidsSfx, fuseSfx, hopSfx, bounceSfx, ghoulSfx]);
|
||||
const GAME_SFX = Object.freeze([snakeSfx, golfSfx, trailsSfx, bugsSfx, driveSfx, stackSfx, bumperSfx, rapidsSfx, fuseSfx, hopSfx, bounceSfx, ghoulSfx, flockSfx]);
|
||||
|
||||
// A game file holds plain objects; they are frozen here, all the way down.
|
||||
const deepFreeze = (o) => {
|
||||
|
||||
Reference in new issue
Block a user