view doc/roadmap.md @ 6:910b26feca76

full game flow
author ark
date 2026-10-19 01:05 +0200
parents 2d46729a022e
children 2c4fed8baed9
line wrap: on
line source

roadmap
-------

steps in order. each ends with something that runs and can be looked at.

1. build basics
    - directory layout, config/game.toml with the values from balance.md
    - build script: sprites, tower level split and fill, map copies,
      config.js
    - check: the processed tower levels look right
2. maps and routes
    - mask classification, placement grid, route extraction, routes.toml
      corrections
    - previews in temp/preview/
    - check: routes on all four maps follow the paths, placement grid looks
      sensible
3. map and walking monsters
    - index.html, main loop, scaling to the window, map drawing
    - monsters walk their routes with hop animation and route preference
    - check: hop and squash feel; speeds against path lengths
4. waves and hearts
    - wave timing, countdown, early start and bonus, hearts, win and loss
5. towers
    - shop, placement with snapping and preview, targeting, projectiles,
      damage, hp bars, coin drops and flying coins
    - first playable version of map0
6. tower details
    - upgrades, selling the whole tower with the pause refund rule, t0 melee
      and spike sides, t2 slow with the blue hp bar, boss with its bar
7. game flow
    - splash screen with title, byline and play button over the paused first
      map; the play button starts the sound
    - map won with next, game won after the last map with restart to the
      splash screen, map lost back to the first map
    - no map selection, unlocking or localStorage
8. tuning on all maps
    - wave lists for maps 1-3, playtesting, balance changes in config only
9. supplied art and sound
    - icons, screens and digits as the drawings arrive (art.md)
    - voice recordings as they arrive (sound.md)
10. publishing
    - publish script, www/, dist/ zip, hosting for tablet play

debug switches (architecture.md) are added as each step needs them, starting
with step 3.


prototype notes
---------------

decisions taken while building steps 1-7 that the other documents do not
cover. values marked proto in config/game.toml refer to this list.

build:

- runs on python 3.11 or later with pillow; numpy is not used. a full build
  takes about 5 s, most of it in the mask step
- a step is skipped when its outputs are newer than its inputs and the build
  scripts. the mask step also reruns when the placement settings in
  game.toml change; it keeps its result in temp/build/maps.json for the
  checks and previews
- map images are written as jpeg, quality 88. the maps have no transparency
- tower strips are split at columns without ink. ink is anything darker
  than luminance 225. outline gaps of up to about 4 pixels are closed before
  the fill. the white paper edge outside the outline fades to transparent
- tools/cut_sheet.py cuts the sprites out of source_sheet_2.jpg into art/. it
  is run by hand, not by the build. one hand-set box per drawing; in each box
  the largest connected outline is the drawing and other ink is dropped.
  outline ink is darker than luminance 150. sprites stay at the sheet's
  scale, which is the scale the first cutouts had, so [scale] is unchanged.
  coins and maps are not on the inked sheet and stay as they were
- the empty part of the hp bars is a darkened copy made by the build
  (hpm_empty, hpb_empty). the blue bars for slowed monsters have the hue of
  every pixel set to 220 degrees, which leaves the black outline as it is
  (hpm_slow, hpb_slow, each with its _empty copy)
- sprite sizes go into config.js, so the game knows them before the images
  load
- mask pixels count when at least half opaque, and take the class of their
  strongest colour. entrance or exit areas under 50 pixels are ignored
- the placement test draws discs around the path edge instead of keeping a
  distance for every pixel. the result is the same. edge_distance applies to
  the tower centre
- the centre line runs through the entrance and exit areas, so routes start
  and end inside them. dead ends shorter than 0.8 path widths are dropped.
  junctions closer together than 0.75 path widths count as one
- map2 has three loops (the round one at the top left, two squares at the
  bottom). each leaves the path at a junction and comes back to the same
  junction, so the rule "no junction twice" would never walk them. a route
  may walk such a loop once. of its two directions, the one that turns less
  is kept. map2 gives 8 routes, all kept; map1 gives 3
- route smoothing: moving average over 17 points, applied twice, then
  simplified to 0.8 pixel tolerance
- straightness for the route value is the least turning of the map's routes
  divided by the route's turning. turning is the total, not per length
- routes.toml names routes by their number in the build output. the numbers
  change when a mask changes
- measured path widths are lower than in balance.md (map1 38, map2 38, map3
  46) because the centre line length includes the entrance and exit areas.
  map0's route is 2020 long
- the coin check compares all coins dropped, boss included, with 10 x
  starting coins
- the build prints the early start bonus for skipping every break, including
  the one before the first wave: 8, 21, 53, 94. balance.md gives 6, 17, 45,
  82, which leaves that break out. the game pays the bonus before the first
  wave too. to decide

config:

- per map: [map.N] holds starting_coins, early_bonus, wave_count and
  monster_share, followed by the [[map.N.wave]] lists
- added: hit_radius in [animation] (0.4 of the monster sprite's smaller
  side), min_weight in [route_preference] (the "at least 0.1" of the rule),
  [art.angle] and [art.pivot]. t1 turns around the middle of its box, not
  the middle of the image; the pivots for levels 1-5 are the centre of the
  box measured on the cutouts. temp/preview/towers.png marks them
- draft waves: monster counts per level from the coin shares. each level is
  spread over the waves by the coin budget still open, with wave n worth n
  shares. higher levels start later: m1 after 15 % of the waves, m2 35 %, m3
  50 %, m4 65 %. groups hold at most 5 monsters and alternate between
  levels. spawn interval 1.0 s on maps 0 and 1, 0.8 s on map2, 0.7 s on
  map3. 2 s between groups, 4 s before the boss. totals: 102, 199, 398, 600
  coins

game:

- scripts share the namespace object MM. storage.js is not written until
  there are settings to store (architecture.md, persistence)
- the simulation runs on wall clock time: at 60 frames per second, 2x gives
  two steps per frame. at most 4 steps per frame and speed step; a longer
  frame drops the rest
- game flow: the first map is debug.start_map, and only the first map
  starts at debug.start_wave; the next maps start at wave 1.
  debug.start_coins applies to every map. the splash screen pauses the
  first map without counting the pause for the sell refund, and only its
  play button responds. the next map starts with its break running, as
  does the first map after a lost map. the screens use placeholders: a
  pale veil with the title and byline in the system font, a play
  triangle, one star for a won map and three for the game, a broken heart
  for a lost map, an arrow for next and a circular arrow for restart
- a break starts when all monsters of the wave are gone, killed or escaped,
  not when the last one has spawned. during a break the wave counter shows
  the next wave
- monsters move at constant speed; the hop is drawn only. a hop spends 80 %
  of its time in the air and 20 % landing. the idle bob is a slow breathing
  (1.3 s) on top of the hops, as monsters never stand still
- route choice weighs all routes of the map. on map2 this also picks the
  entrance
- "furthest along" means the least distance left to the exit. a monster is in
  range when its centre is. projectiles hit on reaching the target's hit
  radius. a new tower attacks at once
- turning towers face their target at once and keep the last direction when
  idle
- t0's attack stretches each spike from under the tower until its tip
  reaches the range, and back, over 0.3 s
- t0 spike sides: each side covers a quarter of the directions around the
  tower. the route centre lines are sampled every 4 pixels; a side gets a
  spike when it holds at least 20 % of the samples within t0's level 5
  range. with no sample in that range, only the side towards the nearest
  one gets a spike. the preview shows the same sides. on map0 about half the
  placement cells give one side, most of the rest two, a few three
- t2 slow: each running slow keeps its own time, and the strongest one
  applies. a slowed monster also hops slower, by the same factor
- tower menu: tapping a built tower shows an upgrade and a sell button above
  it, or below it when there is no room above, kept inside the map. the
  upgrade button shows the cost of the next level and is dimmed when it
  cannot be afforded; at level 5 it is left out. the sell button shows the
  refund. selling clears the selection; upgrading keeps it
- the pause refund counts pauses: each purchase records the pause it was
  made in. a purchase made during the current pause is refunded in full
- placement: a tap within the footprint radius or 28 css pixels of the
  preview builds. the shop choice is cleared after building, and a second tap
  on the chosen shop button cancels it. a tap on a built tower selects it and
  shows its range. a refused tap shows a red cross for 0.5 s. shop buttons
  the player cannot afford are dimmed and do nothing
- flying coins: one sprite per coin, at most 8, started 0.05 s apart, flying
  in game time on an arc. they are dropped when the map ends
- placeholder icons: c0 for coins, m0 for waves, a drawn heart, one triangle
  per game speed step (digits for debug speeds), a skip icon with countdown
  and bonus for the early start. the top bar needs about 500 css pixels of
  width; narrower screens are not handled
- debug switches: all from architecture.md. start_coins -1 means the map's own value, seed 0 a new seed per
  run
- sound: the play button on the splash screen starts the sound; taps
  before it leave sound off. later pointer and touch events resume audio
  if the browser has suspended it. sound is switched off only in the
  config. beeps
  use a square wave. variants are picked with Math.random, not the seeded
  generator, so sound does not change a repeated run. a sound that cannot be
  played at once (audio still locked) is dropped, not queued
- towers at scale 0.25 are small: t1 level 1 is about 43 x 30 map pixels.
  worth a look with the hop and squash check of step 3