wobblyhead hg > minor_monsters
diff doc/architecture.md @ 17:fe680946164b
reorganised repo
| author | ark |
|---|---|
| date | 2026-10-20 00:12 +0200 |
| parents | 7fda634d15ad |
| children | fa04481563b7 |
line wrap: on
line diff
--- a/doc/architecture.md Mon Oct 19 23:47:22 2026 +0200 +++ b/doc/architecture.md Tue Oct 20 00:12:36 2026 +0200 @@ -2,10 +2,11 @@ ------------ the game is a static html page with plain javascript, drawn on a 2d canvas. it -uses no javascript libraries and needs no build step to run. a python build -script prepares everything that can be calculated in advance: processed -images, map data, route data and the config. its output is committed, so the -game runs straight from the source tree. +uses no javascript libraries. a python build script prepares everything that +can be calculated in advance: processed images, map data, route data and the +config. it writes them to www/, together with a copy of the hand-written game +files from game/. www/ is the runnable game. it is not kept in the repository, +so the game has to be built before it can be run. this is a plan; nothing is implemented yet. @@ -22,14 +23,15 @@ game.toml numbers from balance.md, waves, debug switches routes.toml manual corrections to the extracted routes tools/ python build scripts - game/ the runnable game, opened as game/index.html + game/ hand-written game files index.html style.css - js/ game code, hand-written - assets/ processed images (generated, committed) - data/ maps.js, sounds.js, config.js (generated, committed) + js/ game code doc/ design and technical notes - www/ copy of game/ prepared for publishing (ignored) + www/ the built game, opened as www/index.html (generated, ignored) + index.html copied from game/, as are style.css and js/ + assets/ processed images + data/ maps.js, sounds.js, config.js dist/ zip archives for distribution (ignored) temp/ scratch files, build previews (ignored) @@ -40,11 +42,11 @@ running the game ---------------- -- desktop: open game/index.html directly from disk, or serve the directory +- desktop: open www/index.html directly from disk, or serve the directory with any static web server - tablet: tablets cannot easily open local html files, so the game is served - over http, from a computer on the home network or from a web host. www/ is - the copy meant for that + over http, from a computer on the home network or from a web host. the zip + in dist/ is meant for that - an optional later step makes it installable to the home screen (web app manifest, offline cache). that requires https @@ -69,7 +71,7 @@ page. the ff_screenshot script (in $PATH, ~/bin/ff_screenshot) drives headless firefox over marionette and waits before capturing: - ff_screenshot -w 1024,768 -s 2 file://$PWD/game/index.html temp/splash.png + ff_screenshot -w 1024,768 -s 2 file://$PWD/www/index.html temp/splash.png -w sets the viewport, -s the wait after loading. the game state is not reachable from outside, so other screens are reached by tapping: -J runs @@ -80,7 +82,7 @@ ff_screenshot -w 1024,768 -s 2 -S 3 -J 'document.getElementById("game") .dispatchEvent(new PointerEvent("pointerdown", {clientX: 497, clientY: 560, bubbles: true}))' \ - file://$PWD/game/index.html temp/play.png + file://$PWD/www/index.html temp/play.png `ff_screenshot -h` lists the other options. @@ -100,7 +102,7 @@ steps: -1. sprites: trim transparent edges, write to game/assets/. this covers the +1. sprites: trim transparent edges, write to www/assets/. this covers the icons, buttons and screens, and the digits from art/digits/ as digit_NAME_N. make the hp bar variants: the empty part, and the blue bars for slowed monsters (art.md) @@ -117,20 +119,23 @@ - write a placement grid: cells where a tower footprint fits next to the road, within the limits in balance.md. the red path in the mask is the centre line of the road; the road's half width is set per map -5. sounds: embed art/sounds/*.mp3 as base64 in game/data/sounds.js, +5. sounds: embed art/sounds/*.mp3 as base64 in www/data/sounds.js, grouped by event -6. config: read config/game.toml, check it, write game/data/config.js +6. config: read config/game.toml, check it, write www/data/config.js 7. checks: print a summary per map (routes with length and turning, monster counts, coins and hp per map against the target) and warn on problems 8. previews: draw each map with its routes, entrances, exits and placement grid into temp/preview/, for checking without starting the game +9. game files: copy the files in game/ to www/. a file is copied when its + time or size differs from the copy. files no longer in game/ are removed + from www/, apart from www/assets/ and www/data/ a watch mode (`tools/build.py --watch`) reruns the build when a file in -config/, art/ or art/sounds/ changes. tuning then means: edit the toml, save, reload the -browser. +config/, art/, art/sounds/ or game/ changes. tuning then means: edit the toml, +save, reload the browser. the same goes for changes to the game code: they +show in www/ only after the build has copied them. -`tools/publish.py` copies game/ to www/ with debug switches off, and writes a -zip into dist/. +`tools/publish.py` writes a zip of www/ into dist/, with debug switches off. routes @@ -169,7 +174,7 @@ ------ config/game.toml holds every number in balance.md, the wave lists, and debug -switches. the build converts it into game/data/config.js. toml allows comments, +switches. the build converts it into www/data/config.js. toml allows comments, so each value can carry its source note (guess, decided). wave format:
