wobblyhead hg > minor_monsters
comparison doc/architecture.md @ 4:2d46729a022e
sound processing and in-game sounds
| author | ark |
|---|---|
| date | 2026-10-18 20:58 +0200 |
| parents | 7af9dd4e2595 |
| children | 910b26feca76 |
comparison
equal
deleted
inserted
replaced
| 3:cc0c32e71090 | 4:2d46729a022e |
|---|---|
| 14 ---------------- | 14 ---------------- |
| 15 | 15 |
| 16 proposed: | 16 proposed: |
| 17 | 17 |
| 18 art/ drawings as supplied: scans, masks, sprites | 18 art/ drawings as supplied: scans, masks, sprites |
| 19 sound_sources/ voice recordings as supplied | |
| 20 sounds/ sounds cut from the recordings (tools/cut_sounds.py) | |
| 19 config/ hand-edited game settings (toml) | 21 config/ hand-edited game settings (toml) |
| 20 game.toml numbers from balance.md, waves, debug switches | 22 game.toml numbers from balance.md, waves, debug switches |
| 21 routes.toml manual corrections to the extracted routes | 23 routes.toml manual corrections to the extracted routes |
| 22 tools/ python build scripts | 24 tools/ python build scripts |
| 23 game/ the runnable game, opened as game/index.html | 25 game/ the runnable game, opened as game/index.html |
| 24 index.html | 26 index.html |
| 25 style.css | 27 style.css |
| 26 js/ game code, hand-written | 28 js/ game code, hand-written |
| 27 assets/ processed images (generated, committed) | 29 assets/ processed images (generated, committed) |
| 28 data/ maps.js, config.js (generated, committed) | 30 data/ maps.js, sounds.js, config.js (generated, committed) |
| 29 doc/ design and technical notes | 31 doc/ design and technical notes |
| 30 www/ copy of game/ prepared for publishing (ignored) | 32 www/ copy of game/ prepared for publishing (ignored) |
| 31 dist/ zip archives for distribution (ignored) | 33 dist/ zip archives for distribution (ignored) |
| 32 temp/ scratch files, build previews (ignored) | 34 temp/ scratch files, build previews (ignored) |
| 33 | 35 |
| 53 - scripts are loaded with plain script tags in a fixed order, and share one | 55 - scripts are loaded with plain script tags in a fixed order, and share one |
| 54 global namespace object | 56 global namespace object |
| 55 - data files are javascript files that assign to that object, not json files | 57 - data files are javascript files that assign to that object, not json files |
| 56 - the game never reads mask pixels; the build turns the masks into data | 58 - the game never reads mask pixels; the build turns the masks into data |
| 57 - images are loaded with image elements, which works from disk | 59 - images are loaded with image elements, which works from disk |
| 58 - recorded sounds will be embedded by the build as base64 data in a | 60 - recorded sounds are embedded by the build as base64 data in a javascript |
| 59 javascript file, so they can be decoded without fetch() | 61 file, so they can be decoded without fetch() |
| 60 | 62 |
| 61 | 63 |
| 62 build | 64 build |
| 63 ----- | 65 ----- |
| 64 | 66 |
| 65 one command, `python3 tools/build.py`, runs all steps. each step skips its work | 67 one command, `python3 tools/build.py`, runs all steps. each step skips its work |
| 66 when its inputs have not changed. requires python 3.11 or later (for the | 68 when its inputs have not changed. requires python 3.11 or later (for the |
| 67 built-in toml reader) and pillow. numpy is optional, if the pure python image | 69 built-in toml reader) and pillow. numpy is optional, if the pure python image |
| 68 steps turn out too slow. | 70 steps turn out too slow. |
| 71 | |
| 72 tools/cut_sheet.py and tools/cut_sounds.py are run by hand and write to art/. | |
| 73 cut_sounds.py also needs ffmpeg with mp3 support, so the build itself does not | |
| 74 depend on it. see sound.md. | |
| 69 | 75 |
| 70 steps: | 76 steps: |
| 71 | 77 |
| 72 1. sprites: trim transparent edges, write to game/assets/ | 78 1. sprites: trim transparent edges, write to game/assets/ |
| 73 2. tower levels: t0-t3 are level 1. split each t*p strip into four images, | 79 2. tower levels: t0-t3 are level 1. split each t*p strip into four images, |
| 80 thresholds (the mask edges are soft) | 86 thresholds (the mask edges are soft) |
| 81 - compute the distance from every free pixel to the nearest path pixel | 87 - compute the distance from every free pixel to the nearest path pixel |
| 82 - write a placement grid: cells where a tower footprint fits next to the | 88 - write a placement grid: cells where a tower footprint fits next to the |
| 83 path, within the limits in balance.md | 89 path, within the limits in balance.md |
| 84 - extract routes, see below | 90 - extract routes, see below |
| 85 5. config: read config/game.toml, check it, write game/data/config.js | 91 5. sounds: embed art/sounds/*.mp3 as base64 in game/data/sounds.js, |
| 86 6. checks: print a summary per map (routes with length and turning, monster | 92 grouped by event |
| 93 6. config: read config/game.toml, check it, write game/data/config.js | |
| 94 7. checks: print a summary per map (routes with length and turning, monster | |
| 87 counts, coins and hp per map against the target) and warn on problems | 95 counts, coins and hp per map against the target) and warn on problems |
| 88 7. previews: draw each map with its routes, entrances, exits and placement | 96 8. previews: draw each map with its routes, entrances, exits and placement |
| 89 grid into temp/preview/, for checking without starting the game | 97 grid into temp/preview/, for checking without starting the game |
| 90 | 98 |
| 91 a watch mode (`tools/build.py --watch`) reruns the build when a file in | 99 a watch mode (`tools/build.py --watch`) reruns the build when a file in |
| 92 config/ or art/ changes. tuning then means: edit the toml, save, reload the | 100 config/, art/ or art/sounds/ changes. tuning then means: edit the toml, save, reload the |
| 93 browser. | 101 browser. |
| 94 | 102 |
| 95 `tools/publish.py` copies game/ to www/ with debug switches off, and writes a | 103 `tools/publish.py` copies game/ to www/ with debug switches off, and writes a |
| 96 zip into dist/. | 104 zip into dist/. |
| 97 | 105 |
| 157 | 165 |
| 158 script files, in load order: | 166 script files, in load order: |
| 159 | 167 |
| 160 data/config.js generated settings | 168 data/config.js generated settings |
| 161 data/maps.js generated map data | 169 data/maps.js generated map data |
| 170 data/sounds.js generated sound data | |
| 162 js/util.js vector maths, random numbers, easing | 171 js/util.js vector maths, random numbers, easing |
| 163 js/assets.js image loading, sprite table | 172 js/assets.js image loading, sprite table |
| 164 js/audio.js placeholder beeps, later recorded sounds | 173 js/audio.js recorded sounds, placeholder beeps for the other events |
| 165 js/storage.js localStorage wrapper | 174 js/storage.js localStorage wrapper |
| 166 js/map.js placement lookup, snapping, route sampling | 175 js/map.js placement lookup, snapping, route sampling |
| 167 js/monster.js movement along a route, hops, slow, hp | 176 js/monster.js movement along a route, hops, slow, hp |
| 168 js/tower.js targeting, attacks, upgrade, sell | 177 js/tower.js targeting, attacks, upgrade, sell |
| 169 js/projectile.js | 178 js/projectile.js |
