comparison doc/architecture.md @ 8:2c4fed8baed9

art update, persistent sound setting, tower selling as double action
author ark
date 2026-10-19 13:37 +0200
parents 910b26feca76
children 53f015966118
comparison
equal deleted inserted replaced
7:4fd2da999ba4 8:2c4fed8baed9
91 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
92 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
93 built-in toml reader) and pillow. numpy is optional, if the pure python image 93 built-in toml reader) and pillow. numpy is optional, if the pure python image
94 steps turn out too slow. 94 steps turn out too slow.
95 95
96 tools/cut_sheet.py and tools/cut_sounds.py are run by hand and write to art/. 96 tools/cut_sheet.py, tools/cut_digits.py and tools/cut_sounds.py are run by
97 hand and write to art/.
97 cut_sounds.py also needs ffmpeg with mp3 support, so the build itself does not 98 cut_sounds.py also needs ffmpeg with mp3 support, so the build itself does not
98 depend on it. see sound.md. 99 depend on it. see sound.md.
99 100
100 steps: 101 steps:
101 102
102 1. sprites: trim transparent edges, write to game/assets/. make the hp bar 103 1. sprites: trim transparent edges, write to game/assets/. this covers the
103 variants: the empty part, and the blue bars for slowed monsters (art.md) 104 icons, buttons and screens, and the digits from art/digits/ as
105 digit_NAME_N. make the hp bar variants: the empty part, and the blue bars
106 for slowed monsters (art.md)
104 2. tower levels: t0-t3 are level 1. split each t*p strip into four images, 107 2. tower levels: t0-t3 are level 1. split each t*p strip into four images,
105 levels 2-5. fill the inside of the outline with white (flood fill from 108 levels 2-5. fill the inside of the outline with white (flood fill from
106 outside, everything not reached is inside), trim, write as t0_2..t0_5 and 109 outside, everything not reached is inside), trim, write as t0_2..t0_5 and
107 so on. see art.md 110 so on. see art.md
108 3. maps: copy the map images, possibly converted to a smaller format 111 3. maps: copy the map images, possibly converted to a smaller format
192 195
193 data/config.js generated settings 196 data/config.js generated settings
194 data/maps.js generated map data 197 data/maps.js generated map data
195 data/sounds.js generated sound data 198 data/sounds.js generated sound data
196 js/util.js vector maths, random numbers, easing 199 js/util.js vector maths, random numbers, easing
200 js/storage.js settings kept in the browser
197 js/assets.js image loading, sprite table 201 js/assets.js image loading, sprite table
198 js/audio.js recorded sounds, placeholder beeps for the other events 202 js/audio.js recorded sounds, placeholder beeps for the other events
199 js/map.js placement lookup, snapping, route sampling 203 js/map.js placement lookup, snapping, route sampling
200 js/monster.js movement along a route, hops, slow, hp 204 js/monster.js movement along a route, hops, slow, hp
201 js/tower.js targeting, attacks, upgrade, sell 205 js/tower.js targeting, attacks, upgrade, sell
227 231
228 - the canvas fills the window. the map is scaled to fit and centred, with 232 - the canvas fills the window. the map is scaled to fit and centred, with
229 borders where the shapes differ 233 borders where the shapes differ
230 - the canvas resolution follows the device pixel ratio, so drawings stay sharp 234 - the canvas resolution follows the device pixel ratio, so drawings stay sharp
231 on high-resolution screens 235 on high-resolution screens
232 - layout: top bar with coins, hearts, wave, countdown, pause and speed. the 236 - layout: top bar with coins, hearts, wave, countdown, sound, speed and
237 pause. the
233 tower shop sits on the right in landscape and at the bottom in portrait 238 tower shop sits on the right in landscape and at the bottom in portrait
234 - buttons are at least 48 css pixels for touch 239 - buttons are at least 48 css pixels for touch
235 240
236 input: 241 input:
237 242
238 - pointer events cover mouse and touch alike 243 - pointer events cover mouse and touch alike
239 - nothing relies on hover; selection and confirmation are by tap 244 - nothing relies on hover; selection and confirmation are by tap. with a
245 mouse, hover enlarges the screen buttons and shows the pointer cursor over
246 any button
240 - the page blocks browser zoom and scroll gestures on the canvas 247 - the page blocks browser zoom and scroll gestures on the canvas
241 248
242 placement: 249 placement:
243 250
244 - the build's placement grid marks every cell where a tower may stand 251 - the build's placement grid marks every cell where a tower may stand
250 persistence: 257 persistence:
251 258
252 - nothing is stored for now. maps are played in order and a lost map goes 259 - 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 260 back to the first map, so there is no progress to keep. a reload starts at
254 the splash screen with a fresh game 261 the splash screen with a fresh game
255 - once the game has settings, such as sound on or off, js/storage.js wraps 262 - settings, so far only sound on or off, are stored by js/storage.js. it
256 localStorage, and one entry holds them 263 wraps localStorage, and one entry holds them
257 - all access is wrapped so the game still runs when storage is unavailable, 264 - all access is wrapped so the game still runs when storage is unavailable,
258 for example in private browsing; progress is then not saved 265 for example in private browsing; settings are then not kept
259 - the entry carries a version number for later format changes 266 - the entry carries a version number for later format changes
260 267
261 268
262 not planned 269 not planned
263 ----------- 270 -----------