Public: anyone can read this; the crew can change it.
Migrated from github.com/amirmushichge/pixel-plays
Add Carousel: the playable page and its place in the catalogue, on the rules in `carousel/ride.js` #236
vesper/pixel-plays:vesper/188-add-carousel-the-playable-page-and-its-p → main 11 commits fork
8 files
changed +341
−2
README.md +3 −2
Diff not shown — a line 2,147 characters wide (limit 2,000). +3 −2
View filecarousel/index.html added +324
| @@ -0,0 +1,324 @@ | ||
| 1 | ||
| 2 | <html lang="en"> | |
| 3 | <head> | |
| 4 | <meta charset="utf-8"> | |
| 5 | <meta name="viewport" content="width=device-width,initial-scale=1,viewport-fit=cover"> | |
| 6 | <title>Carousel</title> | |
| 7 | <!-- og:begin --> | |
| 8 | <meta name="description" content="Ride the horses and snatch the brass ring as you pass the dispenser"> | |
| 9 | <link rel="canonical" href="https://pixel-plays--forge-trevato-apps.open-platform.sh/carousel/"> | |
| 10 | <meta property="og:type" content="website"> | |
| 11 | <meta property="og:site_name" content="Pixel Plays"> | |
| 12 | <meta property="og:title" content="Carousel"> | |
| 13 | <meta property="og:description" content="Ride the horses and snatch the brass ring as you pass the dispenser"> | |
| 14 | <meta property="og:url" content="https://pixel-plays--forge-trevato-apps.open-platform.sh/carousel/"> | |
| 15 | <meta property="og:image" content="https://pixel-plays--forge-trevato-apps.open-platform.sh/og/carousel.png"> | |
| 16 | <meta property="og:image:type" content="image/png"> | |
| 17 | <meta property="og:image:width" content="1200"> | |
| 18 | <meta property="og:image:height" content="630"> | |
| 19 | <meta property="og:image:alt" content="Carousel: the opening scene of the game"> | |
| 20 | <meta name="twitter:card" content="summary_large_image"> | |
| 21 | <!-- og:end --> | |
| 22 | <style> | |
| 23 | :root { : #1c1b19; : #8b877f; : #fff; : #c4893a; } | |
| 24 | * { box-sizing: border-box; } | |
| 25 | html, body { -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; -webkit-tap-highlight-color: transparent; } | |
| 26 | html, body { height: 100%; margin: 0; background: var(); color: var(); } | |
| 27 | body { font: 13px/1.35 ui-monospace, "Cascadia Mono", Consolas, Menlo, monospace; overflow: hidden; } | |
| 28 | #stage { position: fixed; inset: 0; display: grid; place-items: center; } | |
| 29 | canvas { display: block; image-rendering: pixelated; touch-action: none; cursor: pointer; outline: none; } | |
| 30 | .hud { position: fixed; left: max(16px, env(safe-area-inset-left)); right: max(16px, env(safe-area-inset-right)); display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; pointer-events: none; } | |
| 31 | #scores { position: fixed; top: max(14px, env(safe-area-inset-top)); left: max(16px, env(safe-area-inset-left)); display: grid; gap: 2px; pointer-events: none; } | |
| 32 | #bottom { bottom: max(14px, env(safe-area-inset-bottom)); } | |
| 33 | .row { display: flex; align-items: center; gap: 8px; color: var(); } | |
| 34 | .row b { font-size: 16px; font-weight: 600; min-width: 1ch; font-variant-numeric: tabular-nums; } | |
| 35 | .row span { color: var(); } | |
| 36 | #status { color: var(); min-height: 1.35em; } | |
| 37 | .acts { display: flex; gap: 22px; align-items: center; } | |
| 38 | button { pointer-events: auto; font: inherit; color: var(); background: none; border: 0; padding: 10px; margin: -10px; cursor: pointer; } | |
| 39 | button.act { color: var(); font-weight: 600; } | |
| 40 | button:hover, button:focus-visible { color: var(); } | |
| 41 | button:focus-visible { outline: 2px solid var(); outline-offset: 2px; } | |
| 42 | noscript p { position: fixed; inset: 40% 16px auto; margin: 0; text-align: center; color: var(); } | |
| 43 | </style> | |
| 44 | </head> | |
| 45 | <body> | |
| 46 | <div id="stage"><canvas id="c" tabindex="0" aria-label="A fairground carousel turning with horses that rise and fall, a rider on one and a ring dispenser at the front with the next ring showing. Brass rings are hollow, iron rings are solid discs. A marked arc on the platform is the grab window, with its centre for the bonus. Tap anywhere or press Space to grab as the rider passes the dispenser, once a turn. Ten turns, and 14 points wins."></canvas></div> | |
| 47 | <noscript><p>Carousel needs JavaScript to play.</p></noscript> | |
| 48 | <div id="scores"> | |
| 49 | <div class="row"><b id="turns">10</b><span>turns left</span></div> | |
| 50 | <div class="row"><b id="rings">0</b><span>rings taken</span></div> | |
| 51 | <div class="row"><b id="score">0 of 14</b><span>score</span></div> | |
| 52 | </div> | |
| 53 | <div class="hud" id="bottom"> | |
| 54 | <div id="status" role="status" aria-live="polite"></div> | |
| 55 | <div class="acts"> | |
| 56 | <button id="grab" class="act" type="button">Grab (Space)</button> | |
| 57 | <button id="mute" type="button" aria-pressed="false">sound on</button> | |
| 58 | </div> | |
| 59 | </div> | |
| 60 | <script src="../shell.js"></script> | |
| 61 | <script> | |
| 62 | PixelPlays.mount({ | |
| 63 | id: 'carousel', | |
| 64 | rules: [ | |
| 65 | 'The carousel turns and speeds up; tap anywhere or press Space as you pass the dispenser.', | |
| 66 | 'Inside the marked arc you take the front ring; one try a turn.', | |
| 67 | 'Iron is 1 point, brass 3, brass dead centre 5.', | |
| 68 | 'Ten turns: 14 points wins.', | |
| 69 | ], | |
| 70 | }); | |
| 71 | </script> | |
| 72 | <script>window.PP_SCENE = { originY: 30, shadowX: .6, shadowY: -.1 };</script> | |
| 73 | <script src="../engine.js"></script> | |
| 74 | <script src="ride.js"></script> | |
| 75 | <script> | |
| 76 | 'use strict'; | |
| 77 | ||
| 78 | const Ride = window.Carousel; | |
| 79 | const DEG = Math.PI / 180; | |
| 80 | const RIM = 5, FLOOR = 7, CANOPY = 6.2, APEX = 7.8, HORSES = 8, DISP_R = 8.2, HAND = 3.4; | |
| 81 | const eng = (u, v, z) => [(u + v) / R2, (v - u) / R2, z]; | |
| 82 | const scr = (u, v, z = 0) => { const p = project(...eng(u, v, z)); return [p.sx, p.sy]; }; | |
| 83 | // a point at radius r on the carousel, a degrees round from the back (180 is the front, at the dispenser) | |
| 84 | const at = (a, r) => [r * Math.sin(a * DEG), -r * Math.cos(a * DEG)]; | |
| 85 | ||
| 86 | const BRASS = [226, 170, 60], IRON = [96, 98, 108], POLE = [214, 188, 120], CREAM = [240, 228, 200], RED = [196, 74, 70]; | |
| 87 | const SKIN = [226, 184, 150], PAVE = [200, 192, 172], PAVE_ALT = [190, 182, 164], PLANK = [172, 128, 88], PLANK_ALT = [156, 114, 78]; | |
| 88 | const BULB_ON = [255, 222, 110], BULB_OFF = [150, 130, 100], COATS = [[240, 238, 230], [140, 98, 66], [196, 90, 80], [150, 154, 162]]; | |
| 89 | const WINDOW_PIX = rgb(236, 196, 96), CENTRE_PIX = rgb(255, 250, 232); | |
| 90 | const INK_PIX = rgb(28, 27, 25), BRASS_PIX = rgb(226, 170, 60), BRASS_HI = rgb(255, 226, 140), IRON_PIX = rgb(96, 98, 108), IRON_HI = rgb(150, 152, 164); | |
| 91 | ||
| 92 | /* ---------- state ---------- */ | |
| 93 | const nodes = {}; | |
| 94 | for (const k of ['turns', 'rings', 'score', 'status']) nodes[k] = document.getElementById(k); | |
| 95 | const shown = {}; | |
| 96 | function setText(key, text) { | |
| 97 | if (shown[key] === text) return; | |
| 98 | shown[key] = text; | |
| 99 | nodes[key].textContent = text; | |
| 100 | } | |
| 101 | const fresh = () => Ride.start(Math.floor(Math.random() * 4294967296)); | |
| 102 | let P = fresh(); | |
| 103 | const G = { time: 0, noteUntil: 0, end: '' }; | |
| 104 | ||
| 105 | function renderHud() { | |
| 106 | setText('turns', String(Math.max(0, Ride.TURNS - P.turn))); | |
| 107 | setText('rings', String(P.rings.length)); | |
| 108 | setText('score', `${P.score} of ${Ride.WIN}`); | |
| 109 | } | |
| 110 | function note(text) { setText('status', text); G.noteUntil = G.time + 1.8; } | |
| 111 | ||
| 112 | /* ---------- baked scene ---------- */ | |
| 113 | const polar = (u, v) => ({ r: Math.hypot(u, v), a: (Math.atan2(u, -v) / DEG + 360) % 360 }); | |
| 114 | const inPlaza = (u, v, ix, iy) => Math.hypot(u, v - 1) < 15 + (hash(ix, iy) - .5) * 1.4; | |
| 115 | function groundColor(x, y, ix, iy) { | |
| 116 | const u = (x - y) / R2, v = (x + y) / R2; | |
| 117 | if (!inPlaza(u, v, ix, iy)) return 0; | |
| 118 | const t = .96 + (hash(ix, iy) - .5) * .06; | |
| 119 | const shade = c => rgb(c[0] * t, c[1] * t, c[2] * t); | |
| 120 | const { r, a } = polar(u, v); | |
| 121 | if (r < FLOOR) { | |
| 122 | // the grab window: the arc either side of the dispenser, brighter at the centre where brass earns the bonus | |
| 123 | const off = Math.abs(a - Ride.DISPENSER); | |
| 124 | if (r > FLOOR - 1.5 && off <= Ride.WINDOW) return off <= Ride.CENTRE ? CENTRE_PIX : (off > Ride.WINDOW - 1.6 ? INK_PIX : WINDOW_PIX); | |
| 125 | return shade(Math.floor(r * 2.2) % 2 ? PLANK : PLANK_ALT); | |
| 126 | } | |
| 127 | return shade((ix + iy) & 4 ? PAVE : PAVE_ALT); | |
| 128 | } | |
| 129 | function bakeCanopy() { | |
| 130 | const rim = k => { const [u, v] = at(k / 16 * 360, FLOOR - .4); return eng(u, v, CANOPY); }; | |
| 131 | for (let k = 0; k < 16; k++) dynamicAdd(rim(k), rim(k + 1), .16, .16, () => (k % 2 ? CREAM : RED)); | |
| 132 | for (let k = 0; k < 8; k++) dynamicAdd(eng(0, 0, APEX), rim(k * 2), .1, .1, () => (k % 2 ? CREAM : RED)); | |
| 133 | dynamicAdd(eng(0, 0, 0), eng(0, 0, APEX), .5, .4, () => POLE); | |
| 134 | dynamicAdd(eng(0, 0, 0), eng(0, 0, .5), 1, 1, () => IRON); | |
| 135 | flushShadows(); | |
| 136 | pendingShadows.length = 0; | |
| 137 | } | |
| 138 | function bake() { | |
| 139 | ground.fill(0); shadowMask.fill(0); staticShadow.fill(0); kinds.fill(0); | |
| 140 | tufts.length = 0; leaves.length = 0; | |
| 141 | zb.fill(-1e9); | |
| 142 | pix.fill(rgb(255, 255, 255)); | |
| 143 | for (let iy = 0; iy < H; iy++) for (let ix = 0; ix < W; ix++) { | |
| 144 | const g = unproject(ix + .5, iy + .5), i = iy * W + ix, c = groundColor(g.x, g.y, ix, iy); | |
| 145 | if (!c) continue; | |
| 146 | pix[i] = c; ground[i] = 1; | |
| 147 | zb[i] = (g.x + g.y) / R2 * COS; | |
| 148 | } | |
| 149 | groundZ.set(zb); | |
| 150 | bakeCanopy(); | |
| 151 | bakeOcclusion(); | |
| 152 | staticShadow.set(shadowMask); | |
| 153 | applyShadows(groundZ); | |
| 154 | bakedPix.set(pix); | |
| 155 | bakedZ.set(zb); | |
| 156 | } | |
| 157 | ||
| 158 | /* ---------- drawing ---------- */ | |
| 159 | // a brass ring is a hollow band, an iron ring a solid disc: the shape tells them apart as well as the colour | |
| 160 | function stampRing(cx, cy, kind, r) { | |
| 161 | cx = Math.round(cx); cy = Math.round(cy); | |
| 162 | for (let y = -r; y <= r; y++) for (let x = -r; x <= r; x++) { | |
| 163 | const d = Math.hypot(x, y), px = cx + x, py = cy + y; | |
| 164 | if (d > r + .4 || px < 0 || px >= W || py < 0 || py >= H) continue; | |
| 165 | const edge = d > r - .8; | |
| 166 | if (kind === 'brass') { | |
| 167 | if (d < r * .55) continue; | |
| 168 | pix[py * W + px] = edge || d < r * .55 + .9 ? INK_PIX : (x + y < 0 ? BRASS_HI : BRASS_PIX); | |
| 169 | } else { | |
| 170 | pix[py * W + px] = edge ? INK_PIX : (x + y < -r * .3 ? IRON_HI : IRON_PIX); | |
| 171 | } | |
| 172 | } | |
| 173 | } | |
| 174 | function drawHorse(k, a, z, coat) { | |
| 175 | const [u, v] = at(a, RIM), t = [Math.cos(a * DEG), Math.sin(a * DEG)]; | |
| 176 | const at3 = (s, h) => eng(u + t[0] * s, v + t[1] * s, z + h); | |
| 177 | dynamicAdd(eng(u, v, 0), eng(u, v, CANOPY), .07, .07, () => POLE); | |
| 178 | dynamicAdd(at3(-.7, 1.3), at3(.6, 1.3), .45, .4, () => coat); | |
| 179 | dynamicAdd(at3(.6, 1.45), at3(1.1, 2.05), .26, .2, () => coat); | |
| 180 | dynamicAdd(at3(-.7, 1.2), at3(-1, .5), .08, .08, () => IRON); | |
| 181 | for (const s of [-.55, .5]) dynamicAdd(at3(s, 1.1), at3(s, .35), .1, .08, () => coat); | |
| 182 | if (k !== 0) return; | |
| 183 | // the rider: a saddle-high body, a head, and an arm held out toward the dispenser | |
| 184 | const [ou, ov] = at(a, RIM + 1.4); | |
| 185 | dynamicAdd(at3(0, 1.7), at3(0, 2.4), .3, .26, () => RED); | |
| 186 | dynamicAdd(at3(0, 2.75), at3(0, 2.8), .27, .27, () => SKIN); | |
| 187 | dynamicAdd(eng(u, v, z + 2.3), eng(ou, ov, z + 2.5), .1, .1, () => SKIN); | |
| 188 | } | |
| 189 | function drawHorses() { | |
| 190 | const horses = []; | |
| 191 | for (let k = 0; k < HORSES; k++) { | |
| 192 | const a = P.angle + k * 360 / HORSES; | |
| 193 | horses.push([k, a, .15 + .45 * (1 + Math.sin(a * 3 * DEG + k)), COATS[k % COATS.length]]); | |
| 194 | } | |
| 195 | horses.sort((p, q) => at(p[1], 1)[1] - at(q[1], 1)[1]); | |
| 196 | for (const h of horses) drawHorse(...h); | |
| 197 | } | |
| 198 | // the fairground lights on the canopy rim: alternate bulbs blink twice a second; under reduced motion they all stay lit | |
| 199 | function drawBulbs() { | |
| 200 | const phase = STILL ? 0 : Math.floor(G.time * 2) % 2; | |
| 201 | for (let k = 0; k < 16; k++) { | |
| 202 | const [u, v] = at((k + .5) / 16 * 360, FLOOR - .1); | |
| 203 | sphere(...eng(u, v, CANOPY - .3), .2, (k + phase) % 2 === 0 ? BULB_ON : BULB_OFF, 'solid'); | |
| 204 | } | |
| 205 | } | |
| 206 | // the dispenser stands just right of the rider's path and reaches an arm in over the platform edge, so the arc stays in view | |
| 207 | const POST = [2.2, DISP_R - .4]; | |
| 208 | function drawDispenser() { | |
| 209 | const [tu, tv] = at(Ride.DISPENSER, FLOOR - .6); | |
| 210 | dynamicAdd(eng(...POST, 0), eng(...POST, 4.2), .2, .16, () => IRON); | |
| 211 | dynamicAdd(eng(...POST, 4.1), eng(tu, tv, HAND + .9), .1, .1, () => IRON); | |
| 212 | } | |
| 213 | function drawRings() { | |
| 214 | const [tu, tv] = at(Ride.DISPENSER, FLOOR - .6), [x, y] = scr(tu, tv, HAND + .9); | |
| 215 | if (P.queue.length) stampRing(x, y + 6, P.queue[0], 6); | |
| 216 | // the rings after it, waiting on the post | |
| 217 | const [px, py] = scr(...POST, 4.6); | |
| 218 | P.queue.slice(1, 4).forEach((kind, i) => stampRing(px + 8 + i * 8, py - 4, kind, 3)); | |
| 219 | // the rings taken so far, along the foot of the picture | |
| 220 | P.rings.forEach((kind, i) => stampRing(10 + i * 9, H - 10, kind, 3)); | |
| 221 | } | |
| 222 | function draw() { | |
| 223 | pix.set(bakedPix); | |
| 224 | zb.set(bakedZ); | |
| 225 | pendingShadows.length = 0; | |
| 226 | drawHorses(); | |
| 227 | drawDispenser(); | |
| 228 | flushShadows(); | |
| 229 | drawBulbs(); | |
| 230 | applyShadows(bakedZ); | |
| 231 | shadeEdges(); | |
| 232 | drawRings(); | |
| 233 | ctx.putImageData(image, 0, 0); | |
| 234 | } | |
| 235 | ||
| 236 | /* ---------- game ---------- */ | |
| 237 | const REFUSED = { spent: 'you have already reached this turn', over: 'the ride is over' }; | |
| 238 | function finish() { | |
| 239 | G.end = `${P.line} · tap or press a key to play again`; G.noteUntil = 0; | |
| 240 | setText('status', G.end); | |
| 241 | sound(P.status === 'won' ? 523 : 130, .5, P.status === 'won' ? 'sine' : 'sawtooth'); | |
| 242 | } | |
| 243 | function grab() { | |
| 244 | ensureAudio(); | |
| 245 | const r = Ride.grab(P); | |
| 246 | P = r.state; | |
| 247 | renderHud(); | |
| 248 | if (r.ok) { | |
| 249 | const ring = P.rings[P.rings.length - 1]; | |
| 250 | note(ring === 'brass' ? 'Brass ring!' : 'Iron ring'); | |
| 251 | sound(ring === 'brass' ? 784 : 330, .15, 'triangle'); | |
| 252 | } else if (r.why === 'miss') { note('Missed: too early or too late'); sound(110, .15, 'sawtooth'); } | |
| 253 | else { note(REFUSED[r.why] || 'cannot do that'); sound(110, .1, 'sawtooth'); } | |
| 254 | } | |
| 255 | function restart() { | |
| 256 | P = fresh(); G.end = ''; | |
| 257 | note('Grab as you pass the dispenser'); | |
| 258 | renderHud(); | |
| 259 | } | |
| 260 | const act = () => { if (P.status !== 'playing') restart(); else grab(); canvas.focus({ preventScroll: true }); }; | |
| 261 | function update(dt) { | |
| 262 | G.time += dt; | |
| 263 | if (P.status !== 'playing') return; | |
| 264 | const turn = P.turn; | |
| 265 | P = Ride.tick(P, dt); | |
| 266 | if (P.turn !== turn) { renderHud(); if (P.status === 'playing') sound(196, .05, 'square'); } | |
| 267 | if (P.status !== 'playing') { finish(); return; } | |
| 268 | if (G.time < G.noteUntil) return; | |
| 269 | setText('status', P.line); | |
| 270 | } | |
| 271 | ||
| 272 | /* ---------- input ---------- */ | |
| 273 | canvas.addEventListener('pointerdown', () => act()); | |
| 274 | document.addEventListener('pointerdown', e => { if (e.target !== canvas && !(e.target.closest && e.target.closest('button, dialog'))) act(); }); | |
| 275 | document.getElementById('grab').addEventListener('click', act); | |
| 276 | canvas.addEventListener('keydown', e => { | |
| 277 | if (e.key !== ' ' && e.key !== 'Enter') return; | |
| 278 | e.preventDefault(); | |
| 279 | if (!e.repeat) act(); | |
| 280 | }); | |
| 281 | ||
| 282 | /* ---------- sound ---------- */ | |
| 283 | let audio = null, muted = false; | |
| 284 | function ensureAudio() { | |
| 285 | if (audio) { if (audio.state === 'suspended') audio.resume(); return; } | |
| 286 | const AC = window.AudioContext || window.webkitAudioContext; | |
| 287 | if (AC) audio = new AC(); | |
| 288 | } | |
| 289 | function sound(freq, life, type, delay = 0) { | |
| 290 | if (!audio || muted) return; | |
| 291 | const now = audio.currentTime + delay, gain = audio.createGain(), osc = audio.createOscillator(); | |
| 292 | osc.type = type; | |
| 293 | osc.frequency.setValueAtTime(freq, now); | |
| 294 | gain.gain.setValueAtTime(.0001, now); | |
| 295 | gain.gain.exponentialRampToValueAtTime(.07, now + .01); | |
| 296 | gain.gain.exponentialRampToValueAtTime(.0005, now + life); | |
| 297 | osc.connect(gain).connect(audio.destination); | |
| 298 | osc.start(now); osc.stop(now + life + .02); | |
| 299 | } | |
| 300 | const muteButton = document.getElementById('mute'); | |
| 301 | muteButton.addEventListener('click', () => { | |
| 302 | muted = !muted; | |
| 303 | muteButton.textContent = muted ? 'sound off' : 'sound on'; | |
| 304 | muteButton.setAttribute('aria-pressed', String(muted)); | |
| 305 | }); | |
| 306 | ||
| 307 | /* ---------- fit and boot ---------- */ | |
| 308 | addEventListener('resize', fit); | |
| 309 | fit(); | |
| 310 | bake(); | |
| 311 | note('Grab as you pass the dispenser'); | |
| 312 | renderHud(); | |
| 313 | canvas.focus({ preventScroll: true }); | |
| 314 | let last = performance.now(); | |
| 315 | function frame(now) { | |
| 316 | update(Math.min(.04, (now - last) / 1000)); | |
| 317 | last = now; | |
| 318 | draw(); | |
| 319 | requestAnimationFrame(frame); | |
| 320 | } | |
| 321 | requestAnimationFrame(frame); | |
| 322 | </script> | |
| 323 | </body> | |
| 324 | </html> |
index.html +1
| @@ -121,6 +121,7 @@ footer a::after { content: none; } | ||
| 121 | 121 | <li data-kind="Puzzle" data-input="Keys" style="--accent:#3d6e4f"><a href="hedge-maze/">Hedge Maze</a><span>Find the way through the hedges to the fountain before the gardener rings the bell</span><span>Game forged by the crew</span><span class="tags">Puzzle · Keys</span></li> |
| 122 | 122 | <li data-kind="Memory" data-input="Tap" style="--accent:#6b8f3a"><a href="bird-watch/">Bird Watch</a><span>Remember where each bird perched</span><span>Game forged by the crew</span><span class="tags">Memory · Tap</span></li> |
| 123 | 123 | <li data-kind="Strategy" data-input="Tap" style="--accent:#3d7f6e"><a href="bunting/">Bunting</a><span>Hang the flags for the fete so no two neighbours match</span><span>Game forged by the crew</span><span class="tags">Strategy · Tap</span></li> |
| 124 | <li data-kind="Timing" data-input="Tap" style="--accent:#c4893a"><a href="carousel/">Carousel</a><span>Ride the horses and snatch the brass ring as you pass the dispenser</span><span>Game forged by the crew</span><span class="tags">Timing · Tap</span></li> | |
| 124 | 125 | </ul> |
| 125 | 126 | <footer>Concept by <a href="https://x.com/awwbhi2">abhi</a>. Game by <a href="https://x.com/AmirMushich">AmirMushich</a>. Visual reference for the style: shawn.'s <a href="https://x.com/zzzzshawn/status/2111546123546661289">Small plays</a>; no assets or subjects were copied.<br><a href="stats/">Most played</a></footer> |
| 126 | 127 | </main> |
og/carousel.png added
Binary file not shown.
og/home.png
Binary file not shown.
rounds.mjs +5
| @@ -344,6 +344,11 @@ export const ROUNDS = { | ||
| 344 | 344 | const { index, offset } = g.read('Rope.nearestBeat(R.t)'); |
| 345 | 345 | if (g.read('R.phase') === 'pull' && Math.abs(offset) < .05 && g.read('R.lastBeat') !== index) g.press(' ', .04); else g.step(1); |
| 346 | 346 | } }, |
| 347 | // grab as the rider reaches the dispenser: the frame the angle is as close to it as a frame gets, once a turn | |
| 348 | 'carousel': { over: /play again/, outcome: /Ride over: [1-9]\d* rings, \d+ points/, beat: g => { | |
| 349 | const [angle, speed, spent, status] = g.read('[P.angle, P.speed, P.spent, P.status]'); | |
| 350 | if (status === 'playing' && !spent && Math.abs(angle - 180) <= speed / 50) g.press(' ', .02); else g.step(1); | |
| 351 | } }, | |
| 347 | 352 | 'window-washer': { over: /play again/, outcome: /[1-9]\d* of 500/, beat: g => g.drag([60, 100], [300, 100], .6) }, |
| 348 | 353 | }; |
| 349 | 354 |
serve.test.mjs +7
| @@ -565,6 +565,13 @@ test('Bunting and its rules script are served without a track', async () => { | ||
| 565 | 565 | expect((await fetch(base + '/bunting/line.js')).status).toBe(200); |
| 566 | 566 | }); |
| 567 | 567 | |
| 568 | test('Carousel and its rules script are served without a track', async () => { | |
| 569 | const page = await fetch(base + '/carousel/'); | |
| 570 | expect(page.status).toBe(200); | |
| 571 | expect(page.headers.get('content-type')).toBe('text/html; charset=utf-8'); | |
| 572 | expect((await fetch(base + '/carousel/ride.js')).status).toBe(200); | |
| 573 | }); | |
| 574 | ||
| 568 | 575 | test('Hedge Maze and its rules script are served without a track', async () => { |
| 569 | 576 | const page = await fetch(base + '/hedge-maze/'); |
| 570 | 577 | expect(page.status).toBe(200); |
shell.js +1
| @@ -61,6 +61,7 @@ window.PixelPlays = (() => { | ||
| 61 | 61 | { id: 'hedge-maze', title: 'Hedge Maze', blurb: 'Find the way through the hedges to the fountain before the gardener rings the bell', kind: 'Puzzle', input: 'Keys', accent: '#3d6e4f', music: false, forged: true }, |
| 62 | 62 | { id: 'bird-watch', title: 'Bird Watch', blurb: 'Remember where each bird perched', kind: 'Memory', input: 'Tap', accent: '#6b8f3a', music: false, forged: true }, |
| 63 | 63 | { id: 'bunting', title: 'Bunting', blurb: 'Hang the flags for the fete so no two neighbours match', kind: 'Strategy', input: 'Tap', accent: '#3d7f6e', music: false, forged: true }, |
| 64 | { id: 'carousel', title: 'Carousel', blurb: 'Ride the horses and snatch the brass ring as you pass the dispenser', kind: 'Timing', input: 'Tap', accent: '#c4893a', music: false, forged: true }, | |
| 64 | 65 | ]; |
| 65 | 66 | const MUSIC_VOLUME = .4; |
| 66 | 67 | const CREDITS = [ |
new above
offline