wobblyhead hg > minor_monsters
comparison doc/architecture.md @ 27:75deda08db90 0.9.1
game debug functions separated into own file; release build option, distribution script
| author | ark |
|---|---|
| date | 2026-10-20 17:19 +0200 |
| parents | 3f2811aebb3d |
| children | 85d23328a215 |
comparison
equal
deleted
inserted
replaced
| 26:28e1fc486be5 | 27:75deda08db90 |
|---|---|
| 29 doc/ design and technical notes | 29 doc/ design and technical notes |
| 30 www/ the built game, opened as www/index.html (generated, ignored) | 30 www/ the built game, opened as www/index.html (generated, ignored) |
| 31 index.html copied from game/, as are style.css and js/ | 31 index.html copied from game/, as are style.css and js/ |
| 32 assets/ processed images | 32 assets/ processed images |
| 33 data/ maps.js, sounds.js, config.js | 33 data/ maps.js, sounds.js, config.js |
| 34 dist/ zip archives for distribution (ignored) | 34 dist/ tarballs for distribution (ignored) |
| 35 temp/ scratch files, build previews (ignored) | 35 temp/ scratch files, build previews (ignored) |
| 36 | 36 |
| 37 generated files carry a header line saying so and naming the script that made | 37 generated files carry a header line saying so and naming the script that made |
| 38 them. | 38 them. |
| 39 | 39 |
| 42 ---------------- | 42 ---------------- |
| 43 | 43 |
| 44 - desktop: open www/index.html directly from disk, or serve the directory | 44 - desktop: open www/index.html directly from disk, or serve the directory |
| 45 with any static web server | 45 with any static web server |
| 46 - tablet: tablets cannot easily open local html files, so the game is served | 46 - tablet: tablets cannot easily open local html files, so the game is served |
| 47 over http, from a computer on the home network or from a web host. the zip | 47 over http, from a computer on the home network or from a web host. the |
| 48 in dist/ is meant for that | 48 tarball in dist/ is meant for that |
| 49 - an optional later step makes it installable to the home screen (web app | 49 - an optional later step makes it installable to the home screen (web app |
| 50 manifest, offline cache). that requires https | 50 manifest, offline cache). that requires https |
| 51 | 51 |
| 52 opening the page from disk (file://) limits what the browser allows. chrome | 52 opening the page from disk (file://) limits what the browser allows. chrome |
| 53 blocks javascript modules, fetch() and reading pixels back from a canvas | 53 blocks javascript modules, fetch() and reading pixels back from a canvas |
| 127 grid into temp/preview/, for checking without starting the game. towers.png | 127 grid into temp/preview/, for checking without starting the game. towers.png |
| 128 shows the tower levels, each turned by its drawing direction to face up, | 128 shows the tower levels, each turned by its drawing direction to face up, |
| 129 with its pivot and footprint | 129 with its pivot and footprint |
| 130 9. game files: copy the files in game/ to www/. a file is copied when its | 130 9. game files: copy the files in game/ to www/. a file is copied when its |
| 131 time or size differs from the copy. files no longer in game/ are removed | 131 time or size differs from the copy. files no longer in game/ are removed |
| 132 from www/, apart from www/assets/ and www/data/ | 132 from www/, apart from www/assets/ and www/data/. a release build writes |
| 133 www/js/debug.js empty | |
| 133 | 134 |
| 134 a watch mode (`tools/build.py --watch`) reruns the build when a file in | 135 a watch mode (`tools/build.py --watch`) reruns the build when a file in |
| 135 config/, art/, art/sounds/ or game/ changes. tuning then means: edit the toml, | 136 config/, art/, art/sounds/ or game/ changes. tuning then means: edit the toml, |
| 136 save, reload the browser. the same goes for changes to the game code: they | 137 save, reload the browser. the same goes for changes to the game code: they |
| 137 show in www/ only after the build has copied them. | 138 show in www/ only after the build has copied them. |
| 138 | 139 |
| 139 `tools/publish.py` writes a zip of www/ into dist/, with debug switches off. | 140 `tools/build.py --release` leaves the debug code out: it writes |
| 141 www/js/debug.js empty and leaves [debug] out of config.js. the game then | |
| 142 runs as with every debug switch off. | |
| 143 | |
| 144 `tools/make_dist.sh` runs a release build and packs www/ into | |
| 145 dist/minor_monsters_VERSION.tar.gz, which unpacks into a directory | |
| 146 minor_monsters. the version comes from `tools/get_version.sh -f`: the | |
| 147 latest tag, with a timestamp appended when the working directory is not | |
| 148 clean or not at the tagged revision. `--debug` builds with the debug code | |
| 149 in place of a release build. www/ keeps the build the script made, so a | |
| 150 plain build afterwards brings the debug code back. | |
| 140 | 151 |
| 141 | 152 |
| 142 balance tools | 153 balance tools |
| 143 ------------- | 154 ------------- |
| 144 | 155 |
| 174 node tools/simulate.js --maps 2 --players naive,naive_t0 --seeds 10 | 185 node tools/simulate.js --maps 2 --players naive,naive_t0 --seeds 10 |
| 175 | 186 |
| 176 it loads www/data/config.js, www/data/maps.js and the logic files util.js, | 187 it loads www/data/config.js, www/data/maps.js and the logic files util.js, |
| 177 assets.js, map.js, monster.js, tower.js, projectile.js, wave.js and | 188 assets.js, map.js, monster.js, tower.js, projectile.js, wave.js and |
| 178 game.js, as the browser would, with window set to the global object. | 189 game.js, as the browser would, with window set to the global object. |
| 179 render.js, ui.js, input.js and main.js are left out. MM.audio is the only | 190 render.js, ui.js, input.js, debug.js and main.js are left out, so the |
| 180 stub; assets.js loads unchanged, since sprite sizes come from the config | 191 debug switches have no effect. MM.audio is the only stub; assets.js loads |
| 181 and images are only loaded by main.js. the debug switches are forced off. | 192 unchanged, since sprite sizes come from the config and images are only |
| 193 loaded by main.js. | |
| 182 | 194 |
| 183 the game advances in steps of 1/60 s, as in the browser; game speed plays | 195 the game advances in steps of 1/60 s, as in the browser; game speed plays |
| 184 no part. each run has its own seed, passed to the game. the players build, | 196 no part. each run has its own seed, passed to the game. the players build, |
| 185 upgrade and start waves through the game's own functions (shop choice, | 197 upgrade and start waves through the game's own functions (shop choice, |
| 186 preview, build, tower selection, upgrade, early start), so placement rules | 198 preview, build, tower selection, upgrade, early start), so placement rules |
| 255 - start coins override, unlimited coins | 267 - start coins override, unlimited coins |
| 256 - start at a given map and wave. that map counts as the first map: the play | 268 - start at a given map and wave. that map counts as the first map: the play |
| 257 button starts it, and a lost map returns to it | 269 button starts it, and a lost map returns to it |
| 258 - no heart loss | 270 - no heart loss |
| 259 - show routes, placement grid, tower ranges, hit areas | 271 - show routes, placement grid, tower ranges, hit areas |
| 260 - higher game speeds | |
| 261 - on-screen frame time and entity counts | 272 - on-screen frame time and entity counts |
| 273 - a fixed random seed | |
| 274 | |
| 275 js/debug.js holds the code for all of them. it replaces functions of the | |
| 276 game and the top bar drawing, and render.js calls it to draw over the map | |
| 277 image and over the monsters. main.js takes the start map, wave and seed | |
| 278 from it. without it, as in a release build, nothing of this is left. | |
| 262 | 279 |
| 263 there is no in-game config editor: values are changed in the toml file. | 280 there is no in-game config editor: values are changed in the toml file. |
| 264 | 281 |
| 265 | 282 |
| 266 runtime | 283 runtime |
| 282 js/wave.js wave timing, countdown, early start bonus | 299 js/wave.js wave timing, countdown, early start bonus |
| 283 js/game.js game state, rules, win and loss | 300 js/game.js game state, rules, win and loss |
| 284 js/render.js drawing | 301 js/render.js drawing |
| 285 js/ui.js top bar, shop, tower menu, screens | 302 js/ui.js top bar, shop, tower menu, screens |
| 286 js/input.js pointer events | 303 js/input.js pointer events |
| 304 js/debug.js debug switches, empty in a release build | |
| 287 js/main.js start-up and main loop | 305 js/main.js start-up and main loop |
| 288 | 306 |
| 289 game loop: | 307 game loop: |
| 290 | 308 |
| 291 - the simulation advances in fixed steps of 1/60 s. drawing happens once per | 309 - the simulation advances in fixed steps of 1/60 s. drawing happens once per |
