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` #231

Parked opened this
Closed without merging

vesper/pixel-plays:vesper/188-add-carousel-the-playable-page-and-its-p → main 7 commits fork

  • Closed without merging. Nothing was applied to main.

Review

Sign in to review this change.
10 files changed +390 −3
README.md +3 −2

Diff not shown — a line 2,147 characters wide (limit 2,000). +3 −2

View file
forge.json +1 −1
@@ -2,6 +2,6 @@
22 "app": {
33 "run": "bun serve.mjs",
44 "health": "/",
5 "test": "bun test"
5 "test": "bun scripts/test.mjs"
66 }
77 }
index.html +1
@@ -121,6 +121,7 @@ footer a::after { content: none; }
121121 <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>
122122 <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>
123123 <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>
124125 </ul>
125126 <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>
126127 </main>
og/home.png
Binary file not shown.
rounds.mjs +5
@@ -344,6 +344,11 @@ export const ROUNDS = {
344344 const { index, offset } = g.read('Rope.nearestBeat(R.t)');
345345 if (g.read('R.phase') === 'pull' && Math.abs(offset) < .05 && g.read('R.lastBeat') !== index) g.press(' ', .04); else g.step(1);
346346 } },
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 } },
347352 'window-washer': { over: /play again/, outcome: /[1-9]\d* of 500/, beat: g => g.drag([60, 100], [300, 100], .6) },
348353 };
349354
scripts/test.mjs added +48
@@ -0,0 +1,48 @@
1 // The suite in parallel: playtest.test.mjs boots and plays every game for real and takes longer than
2 // everything else together, so its games are dealt into shards, each its own bun process, beside one
3 // process for every other test file, run two at a time. Exit code is nonzero if any process failed.
4 import { readdirSync } from 'node:fs';
5 const root = new URL('..', import.meta.url).pathname;
6 const SHARDS = 6;
7 const games = readdirSync(root, { withFileTypes: true })
8 .filter(d => d.isDirectory() && readdirSync(root + d.name).includes('index.html')).map(d => d.name).sort();
9
10 const walk = dir => readdirSync(dir, { withFileTypes: true }).flatMap(e =>
11 e.name === 'node_modules' || e.name.startsWith('.') ? [] :
12 e.isDirectory() ? walk(`${dir}${e.name}/`) : /\.test\.[mc]?[jt]s$/.test(e.name) ? [`${dir}${e.name}`.slice(root.length)] : []);
13 const others = walk(root).filter(f => f !== 'playtest.test.mjs');
14
15 const jobs = [
16 { name: 'rest', args: others },
17 { name: 'playtest roster', args: ['playtest.test.mjs', '-t', '^(every game has|the games folder)'] },
18 ];
19 for (let s = 0; s < SHARDS; s++) {
20 const ids = games.filter((_, i) => i % SHARDS === s);
21 jobs.push({ name: `playtest ${s + 1}/${SHARDS}`, args: ['playtest.test.mjs', '-t', `^(${ids.join('|')}): `] });
22 }
23
24 // the forge caps a test run at 2 cores, and one bun process alone spends about 1.6 (JIT and GC threads), so two
25 // processes at a time are each pinned to their own core with taskset, each job taken as one finishes
26 const WORKERS = 2;
27 function cores() {
28 try {
29 const out = Bun.spawnSync(['taskset', '-pc', String(process.pid)]).stdout.toString();
30 const list = out.split(':').pop().trim().split(',').flatMap(r => {
31 const [a, b = a] = r.trim().split('-').map(Number);
32 return Number.isInteger(a) && Number.isInteger(b) ? Array.from({ length: b - a + 1 }, (_, i) => a + i) : [];
33 });
34 return list.length >= WORKERS ? list : [];
35 } catch { return []; }
36 }
37 const pins = cores();
38 const results = [], queue = [...jobs];
39 async function worker(_, n) {
40 for (let job; (job = queue.shift());) {
41 const p = Bun.spawn([...(pins.length ? ['taskset', '-c', String(pins[n])] : []), 'bun', 'test', ...job.args], { cwd: root, stdout: 'pipe', stderr: 'pipe' });
42 const [out, err] = await Promise.all([new Response(p.stdout).text(), new Response(p.stderr).text()]);
43 results.push({ job, code: await p.exited, text: out + err });
44 }
45 }
46 await Promise.all(Array.from({ length: WORKERS }, (_, n) => worker(_, n)));
47 for (const { job, code, text } of results) console.log(`\n=== ${job.name}: ${code === 0 ? 'ok' : 'FAILED'}\n${text}`);
48 process.exit(results.some(r => r.code) ? 1 : 0);
serve.test.mjs +7
@@ -563,6 +563,13 @@ test('Bunting and its rules script are served without a track', async () => {
563563 expect((await fetch(base + '/bunting/line.js')).status).toBe(200);
564564 });
565565
566 test('Carousel and its rules script are served without a track', async () => {
567 const page = await fetch(base + '/carousel/');
568 expect(page.status).toBe(200);
569 expect(page.headers.get('content-type')).toBe('text/html; charset=utf-8');
570 expect((await fetch(base + '/carousel/ride.js')).status).toBe(200);
571 });
572
566573 test('Hedge Maze and its rules script are served without a track', async () => {
567574 const page = await fetch(base + '/hedge-maze/');
568575 expect(page.status).toBe(200);
shell.js +1
@@ -61,6 +61,7 @@ window.PixelPlays = (() => {
6161 { 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 },
6262 { id: 'bird-watch', title: 'Bird Watch', blurb: 'Remember where each bird perched', kind: 'Memory', input: 'Tap', accent: '#6b8f3a', music: false, forged: true },
6363 { 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 },
6465 ];
6566 const MUSIC_VOLUME = .4;
6667 const CREDITS = [

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs