wobblyhead hg > minor_monsters
comparison doc/architecture.md @ 6:910b26feca76
full game flow
| author | ark |
|---|---|
| date | 2026-10-19 01:05 +0200 |
| parents | 2d46729a022e |
| children | 2c4fed8baed9 |
comparison
equal
deleted
inserted
replaced
| 5:67bf3c505145 | 6:910b26feca76 |
|---|---|
| 59 - images are loaded with image elements, which works from disk | 59 - images are loaded with image elements, which works from disk |
| 60 - recorded sounds are embedded by the build as base64 data in a javascript | 60 - recorded sounds are embedded by the build as base64 data in a javascript |
| 61 file, so they can be decoded without fetch() | 61 file, so they can be decoded without fetch() |
| 62 | 62 |
| 63 | 63 |
| 64 screenshots | |
| 65 ----------- | |
| 66 | |
| 67 firefox's own --screenshot captures at the load event. the game loads its | |
| 68 images and draws its first frame after that, so the capture shows an empty | |
| 69 page. the ff_screenshot script (in $PATH, ~/bin/ff_screenshot) drives | |
| 70 headless firefox over marionette and waits before capturing: | |
| 71 | |
| 72 ff_screenshot -w 1024,768 -s 2 file://$PWD/game/index.html temp/splash.png | |
| 73 | |
| 74 -w sets the viewport, -s the wait after loading. the game state is not | |
| 75 reachable from outside, so other screens are reached by tapping: -J runs | |
| 76 javascript after the wait, and -S waits again before capturing. a pointer | |
| 77 event sent to the canvas counts as a tap at that position in css pixels. | |
| 78 this taps the play button on the splash screen at 1024 x 768: | |
| 79 | |
| 80 ff_screenshot -w 1024,768 -s 2 -S 3 -J 'document.getElementById("game") | |
| 81 .dispatchEvent(new PointerEvent("pointerdown", | |
| 82 {clientX: 512, clientY: 444, bubbles: true}))' \ | |
| 83 file://$PWD/game/index.html temp/play.png | |
| 84 | |
| 85 `ff_screenshot -h` lists the other options. | |
| 86 | |
| 87 | |
| 64 build | 88 build |
| 65 ----- | 89 ----- |
| 66 | 90 |
| 67 one command, `python3 tools/build.py`, runs all steps. each step skips its work | 91 one command, `python3 tools/build.py`, runs all steps. each step skips its work |
| 68 when its inputs have not changed. requires python 3.11 or later (for the | 92 when its inputs have not changed. requires python 3.11 or later (for the |
| 73 cut_sounds.py also needs ffmpeg with mp3 support, so the build itself does not | 97 cut_sounds.py also needs ffmpeg with mp3 support, so the build itself does not |
| 74 depend on it. see sound.md. | 98 depend on it. see sound.md. |
| 75 | 99 |
| 76 steps: | 100 steps: |
| 77 | 101 |
| 78 1. sprites: trim transparent edges, write to game/assets/ | 102 1. sprites: trim transparent edges, write to game/assets/. make the hp bar |
| 103 variants: the empty part, and the blue bars for slowed monsters (art.md) | |
| 79 2. tower levels: t0-t3 are level 1. split each t*p strip into four images, | 104 2. tower levels: t0-t3 are level 1. split each t*p strip into four images, |
| 80 levels 2-5. fill the inside of the outline with white (flood fill from | 105 levels 2-5. fill the inside of the outline with white (flood fill from |
| 81 outside, everything not reached is inside), trim, write as t0_2..t0_5 and | 106 outside, everything not reached is inside), trim, write as t0_2..t0_5 and |
| 82 so on. see art.md | 107 so on. see art.md |
| 83 3. maps: copy the map images, possibly converted to a smaller format | 108 3. maps: copy the map images, possibly converted to a smaller format |
| 148 the boss is a group in the last wave. | 173 the boss is a group in the last wave. |
| 149 | 174 |
| 150 debug switches, all off by default: | 175 debug switches, all off by default: |
| 151 | 176 |
| 152 - start coins override, unlimited coins | 177 - start coins override, unlimited coins |
| 153 - start at a given map and wave | 178 - start at a given map and wave. that map counts as the first map: the play |
| 154 - unlock all maps | 179 button starts it, and a lost map returns to it |
| 155 - no heart loss | 180 - no heart loss |
| 156 - show routes, placement grid, tower ranges, hit areas | 181 - show routes, placement grid, tower ranges, hit areas |
| 157 - higher game speeds | 182 - higher game speeds |
| 158 - on-screen frame time and entity counts | 183 - on-screen frame time and entity counts |
| 159 | 184 |
| 169 data/maps.js generated map data | 194 data/maps.js generated map data |
| 170 data/sounds.js generated sound data | 195 data/sounds.js generated sound data |
| 171 js/util.js vector maths, random numbers, easing | 196 js/util.js vector maths, random numbers, easing |
| 172 js/assets.js image loading, sprite table | 197 js/assets.js image loading, sprite table |
| 173 js/audio.js recorded sounds, placeholder beeps for the other events | 198 js/audio.js recorded sounds, placeholder beeps for the other events |
| 174 js/storage.js localStorage wrapper | |
| 175 js/map.js placement lookup, snapping, route sampling | 199 js/map.js placement lookup, snapping, route sampling |
| 176 js/monster.js movement along a route, hops, slow, hp | 200 js/monster.js movement along a route, hops, slow, hp |
| 177 js/tower.js targeting, attacks, upgrade, sell | 201 js/tower.js targeting, attacks, upgrade, sell |
| 178 js/projectile.js | 202 js/projectile.js |
| 179 js/wave.js wave timing, countdown, early start bonus | 203 js/wave.js wave timing, countdown, early start bonus |
| 223 - t0 checks once, at placement, which of its four sides face the path, and | 247 - t0 checks once, at placement, which of its four sides face the path, and |
| 224 only draws spikes on those | 248 only draws spikes on those |
| 225 | 249 |
| 226 persistence: | 250 persistence: |
| 227 | 251 |
| 228 - one localStorage entry holds unlocked maps and settings (sound on or off) | 252 - nothing is stored for now. maps are played in order and a lost map goes |
| 253 back to the first map, so there is no progress to keep. a reload starts at | |
| 254 the splash screen with a fresh game | |
| 255 - once the game has settings, such as sound on or off, js/storage.js wraps | |
| 256 localStorage, and one entry holds them | |
| 229 - all access is wrapped so the game still runs when storage is unavailable, | 257 - all access is wrapped so the game still runs when storage is unavailable, |
| 230 for example in private browsing; progress is then not saved | 258 for example in private browsing; progress is then not saved |
| 231 - the entry carries a version number for later format changes | 259 - the entry carries a version number for later format changes |
| 232 | 260 |
| 233 | 261 |
