mirror of
https://github.com/jparkerweb/plan2code.git
synced 2026-11-17 04:45:33 -08:00
Add Activities with Snake and Mini golf to play through a wait, paused whenever it is your turn
AI Assisted
This commit is contained in:
1 parent
720758a7ee
commit
dbd31611b7
17 files changed
+8920
-7
No files matched your search
@@ -0,0 +1,31 @@
|
||||
// Plan2Code Web Console - the list of activities: the games the Activities window can open.
|
||||
//
|
||||
// The source of truth for which games exist. The window (screens/activities.js)
|
||||
// knows only this list; each game is its own module under activities/, loaded
|
||||
// with import() the first time it is opened, and answers the same calls:
|
||||
// create({ canvas, tone, onScore }) returning start, pause, resume, key, tick
|
||||
// and resize, plus score and state (scripts/test-web-console-activities.mjs
|
||||
// checks every listed game against it). create() is also handed best(), the
|
||||
// saved best, and memo, a number kept between sessions; a game may ignore
|
||||
// both. Three parts are optional: pointer(type,
|
||||
// x, y) for a game played by mouse, release(name) for a game that acts on a
|
||||
// key held down (handed the same names as key() when the key is let go), and
|
||||
// lowerIsBetter on the module's export for a game whose best is its lowest
|
||||
// round. Adding a game is one file and
|
||||
// one line here. No DOM access and no imports: the page and `node --test` both
|
||||
// import this file.
|
||||
|
||||
const entry = (id, title) => Object.freeze({ id, title, module: `/activities/${id}.js` });
|
||||
|
||||
export const ACTIVITIES = Object.freeze([entry("snake", "Snake"), entry("golf", "Mini golf")]);
|
||||
|
||||
// The looks.json key that holds a game's best score: activityBestSnake for
|
||||
// snake. Built the way soundKey() builds the per-sound switches, so every key
|
||||
// stays flat (cleanLooks() drops nested objects).
|
||||
export const bestKey = (id) => "activityBest" + id[0].toUpperCase() + id.slice(1);
|
||||
|
||||
// The looks.json key that holds a game's memo: one whole number the game may
|
||||
// keep between sessions (Snake keeps its tally of surprises found as bits).
|
||||
// Handed to create() as memo { get, set }; a game that has no use for it
|
||||
// leaves it at 0.
|
||||
export const memoKey = (id) => "activityMemo" + id[0].toUpperCase() + id.slice(1);
|
||||
Reference in new issue
Block a user