# HG changeset patch # User ark # Date 1792279599 -7200 # Node ID 7af9dd4e25959ea3210b9f265ad741432f92738b initial art and design/planning docs diff -r 000000000000 -r 7af9dd4e2595 .hgignore --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/.hgignore Sun Oct 18 01:26:39 2026 +0200 @@ -0,0 +1,4 @@ +.DS_Store +temp/ +www/ +dist/ diff -r 000000000000 -r 7af9dd4e2595 art/b0.png Binary file art/b0.png has changed diff -r 000000000000 -r 7af9dd4e2595 art/b1.png Binary file art/b1.png has changed diff -r 000000000000 -r 7af9dd4e2595 art/b2.png Binary file art/b2.png has changed diff -r 000000000000 -r 7af9dd4e2595 art/b3.png Binary file art/b3.png has changed diff -r 000000000000 -r 7af9dd4e2595 art/c0.png Binary file art/c0.png has changed diff -r 000000000000 -r 7af9dd4e2595 art/c1.png Binary file art/c1.png has changed diff -r 000000000000 -r 7af9dd4e2595 art/c2.png Binary file art/c2.png has changed diff -r 000000000000 -r 7af9dd4e2595 art/c3.png Binary file art/c3.png has changed diff -r 000000000000 -r 7af9dd4e2595 art/hpb.png Binary file art/hpb.png has changed diff -r 000000000000 -r 7af9dd4e2595 art/hpm.png Binary file art/hpm.png has changed diff -r 000000000000 -r 7af9dd4e2595 art/m0.png Binary file art/m0.png has changed diff -r 000000000000 -r 7af9dd4e2595 art/m1.png Binary file art/m1.png has changed diff -r 000000000000 -r 7af9dd4e2595 art/m2.png Binary file art/m2.png has changed diff -r 000000000000 -r 7af9dd4e2595 art/m3.png Binary file art/m3.png has changed diff -r 000000000000 -r 7af9dd4e2595 art/m4.png Binary file art/m4.png has changed diff -r 000000000000 -r 7af9dd4e2595 art/map0.png Binary file art/map0.png has changed diff -r 000000000000 -r 7af9dd4e2595 art/map0mask.png Binary file art/map0mask.png has changed diff -r 000000000000 -r 7af9dd4e2595 art/map1.png Binary file art/map1.png has changed diff -r 000000000000 -r 7af9dd4e2595 art/map1mask.png Binary file art/map1mask.png has changed diff -r 000000000000 -r 7af9dd4e2595 art/map2.png Binary file art/map2.png has changed diff -r 000000000000 -r 7af9dd4e2595 art/map2mask.png Binary file art/map2mask.png has changed diff -r 000000000000 -r 7af9dd4e2595 art/map3.png Binary file art/map3.png has changed diff -r 000000000000 -r 7af9dd4e2595 art/map3mask.png Binary file art/map3mask.png has changed diff -r 000000000000 -r 7af9dd4e2595 art/p0.png Binary file art/p0.png has changed diff -r 000000000000 -r 7af9dd4e2595 art/p1.png Binary file art/p1.png has changed diff -r 000000000000 -r 7af9dd4e2595 art/p2.png Binary file art/p2.png has changed diff -r 000000000000 -r 7af9dd4e2595 art/p3.png Binary file art/p3.png has changed diff -r 000000000000 -r 7af9dd4e2595 art/source_sheet.jpg Binary file art/source_sheet.jpg has changed diff -r 000000000000 -r 7af9dd4e2595 art/t0.png Binary file art/t0.png has changed diff -r 000000000000 -r 7af9dd4e2595 art/t0p.png Binary file art/t0p.png has changed diff -r 000000000000 -r 7af9dd4e2595 art/t1.png Binary file art/t1.png has changed diff -r 000000000000 -r 7af9dd4e2595 art/t1p.png Binary file art/t1p.png has changed diff -r 000000000000 -r 7af9dd4e2595 art/t2.png Binary file art/t2.png has changed diff -r 000000000000 -r 7af9dd4e2595 art/t2p.png Binary file art/t2p.png has changed diff -r 000000000000 -r 7af9dd4e2595 art/t3.png Binary file art/t3.png has changed diff -r 000000000000 -r 7af9dd4e2595 art/t3p.png Binary file art/t3p.png has changed diff -r 000000000000 -r 7af9dd4e2595 doc/architecture.md --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/doc/architecture.md Sun Oct 18 01:26:39 2026 +0200 @@ -0,0 +1,231 @@ +architecture +------------ + +the game is a static html page with plain javascript, drawn on a 2d canvas. it +uses no javascript libraries and needs no build step to run. a python build +script prepares everything that can be calculated in advance: processed +images, map data, route data and the config. its output is committed, so the +game runs straight from the source tree. + +this is a plan; nothing is implemented yet. + + +directory layout +---------------- + +proposed: + + art/ drawings as supplied: scans, masks, sprites + config/ hand-edited game settings (toml) + game.toml numbers from balance.md, waves, debug switches + routes.toml manual corrections to the extracted routes + tools/ python build scripts + game/ the runnable game, opened as game/index.html + index.html + style.css + js/ game code, hand-written + assets/ processed images (generated, committed) + data/ maps.js, config.js (generated, committed) + doc/ design and technical notes + www/ copy of game/ prepared for publishing (ignored) + dist/ zip archives for distribution (ignored) + temp/ scratch files, build previews (ignored) + +generated files carry a header line saying so and naming the script that made +them. + + +running the game +---------------- + +- desktop: open game/index.html directly from disk, or serve the directory + with any static web server +- tablet: tablets cannot easily open local html files, so the game is served + over http, from a computer on the home network or from a web host. www/ is + the copy meant for that +- an optional later step makes it installable to the home screen (web app + manifest, offline cache). that requires https + +opening the page from disk (file://) limits what the browser allows. chrome +blocks javascript modules, fetch() and reading pixels back from a canvas +there. so: + +- scripts are loaded with plain script tags in a fixed order, and share one + global namespace object +- data files are javascript files that assign to that object, not json files +- the game never reads mask pixels; the build turns the masks into data +- images are loaded with image elements, which works from disk +- recorded sounds will be embedded by the build as base64 data in a + javascript file, so they can be decoded without fetch() + + +build +----- + +one command, `python3 tools/build.py`, runs all steps. each step skips its work +when its inputs have not changed. requires python 3.11 or later (for the +built-in toml reader) and pillow. numpy is optional, if the pure python image +steps turn out too slow. + +steps: + +1. sprites: trim transparent edges, write to game/assets/ +2. tower levels: t0-t3 are level 1. split each t*p strip into four images, + levels 2-5. fill the inside of the outline with white (flood fill from + outside, everything not reached is inside), trim, write as t0_2..t0_5 and + so on. see art.md +3. maps: copy the map images, possibly converted to a smaller format +4. masks: for each map + - classify pixels as path, entrance, exit or free, using colour + thresholds (the mask edges are soft) + - compute the distance from every free pixel to the nearest path pixel + - write a placement grid: cells where a tower footprint fits next to the + path, within the limits in balance.md + - extract routes, see below +5. config: read config/game.toml, check it, write game/data/config.js +6. checks: print a summary per map (routes with length and turning, monster + counts, coins and hp per map against the target) and warn on problems +7. previews: draw each map with its routes, entrances, exits and placement + grid into temp/preview/, for checking without starting the game + +a watch mode (`tools/build.py --watch`) reruns the build when a file in +config/ or art/ changes. tuning then means: edit the toml, save, reload the +browser. + +`tools/publish.py` copies game/ to www/ with debug switches off, and writes a +zip into dist/. + + +routes +------ + +a route is a list of points from an entrance to an exit. a map has one or +more routes. a monster picks a route at spawn (weights in balance.md) and +follows it to the end. this handles the branches on map1 and map2 without +junction logic at runtime. + +extraction in the build: + +1. thin the path pixels to a one-pixel centre line (skeleton) +2. turn the skeleton into a graph of junctions and segments, and drop short + dead ends left by uneven strokes +3. find the graph nodes nearest to each entrance and exit blob +4. list every path through the graph from an entrance to an exit that visits + no junction twice +5. smooth each route and reduce it to a few points per bend +6. record length and turning for each route + +map0 and map3 give one route each. map1 and map2 give several; map2 may give +more than wanted. config/routes.toml can drop routes, set fixed weights, or +replace a route with hand-placed points, for cases where the automatic result +is wrong. + + +config +------ + +config/game.toml holds every number in balance.md, the wave lists, and debug +switches. the build converts it into game/data/config.js. toml allows comments, +so each value can carry its source note (guess, decided). + +wave format (sketch): + + [[map.0.wave]] + groups = [ + { monster = "m0", count = 6, interval = 1.0 }, + { monster = "m1", count = 2, interval = 1.5, delay = 3.0 }, + ] + +a group starts after the previous one has finished spawning plus its delay. +the boss is a group in the last wave. + +debug switches, all off by default: + +- start coins override, unlimited coins +- start at a given map and wave +- unlock all maps +- no heart loss +- show routes, placement grid, tower ranges, hit areas +- higher game speeds +- on-screen frame time and entity counts + +there is no in-game config editor: values are changed in the toml file. + + +runtime +------- + +script files, in load order: + + data/config.js generated settings + data/maps.js generated map data + js/util.js vector maths, random numbers, easing + js/assets.js image loading, sprite table + js/audio.js placeholder beeps, later recorded sounds + js/storage.js localStorage wrapper + js/map.js placement lookup, snapping, route sampling + js/monster.js movement along a route, hops, slow, hp + js/tower.js targeting, attacks, upgrade, sell + js/projectile.js + js/wave.js wave timing, countdown, early start bonus + js/game.js game state, rules, win and loss + js/render.js drawing + js/ui.js top bar, shop, tower menu, screens + js/input.js pointer events + js/main.js start-up and main loop + +game loop: + +- the simulation advances in fixed steps of 1/60 s. drawing happens once per + browser frame and is independent of it +- game speed 2x runs two simulation steps per frame +- pause stops the simulation; drawing and input continue +- a frame that takes too long runs at most a few steps and drops the rest, so + the game slows down rather than freezing after the tab was in the background + +state: + +- game state is plain objects: monsters, towers, projectiles, coins in flight, + wave state, coins, hearts. rendering reads it and does not change it +- random numbers come from one seeded generator, so a run can be repeated with + the same seed when chasing a bug + +display: + +- the canvas fills the window. the map is scaled to fit and centred, with + borders where the shapes differ +- the canvas resolution follows the device pixel ratio, so drawings stay sharp + on high-resolution screens +- layout: top bar with coins, hearts, wave, countdown, pause and speed. the + tower shop sits on the right in landscape and at the bottom in portrait +- buttons are at least 48 css pixels for touch + +input: + +- pointer events cover mouse and touch alike +- nothing relies on hover; selection and confirmation are by tap +- the page blocks browser zoom and scroll gestures on the canvas + +placement: + +- the build's placement grid marks every cell where a tower may stand +- on a tap, the game searches outward from the tap for the nearest legal cell + that keeps the minimum distance to other towers, within the snap radius +- t0 checks once, at placement, which of its four sides face the path, and + only draws spikes on those + +persistence: + +- one localStorage entry holds unlocked maps and settings (sound on or off) +- all access is wrapped so the game still runs when storage is unavailable, + for example in private browsing; progress is then not saved +- the entry carries a version number for later format changes + + +not planned +----------- + +- in-browser editors or tuning panels +- automatic balance simulation: tower placement is up to the player, so a + simulation would need a placement strategy first. could be revisited once + the game is playable diff -r 000000000000 -r 7af9dd4e2595 doc/art.md --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/doc/art.md Sun Oct 18 01:26:39 2026 +0200 @@ -0,0 +1,127 @@ +art assets +---------- + +b0-b3: boss monsters for each map level +c0-c3: coin variants +hpb: hp bar for bosses +hpm: hp bar for monsters +m0-m4: monster progression +map0-map3: map level art. maps are to be scaled approx 400% +map*mask: map level definitions, blue: monster entrance, red: path, green: exit +p0-p3: projectiles for defense towers +t0-t3: defense towers +t*p: defense towers upgrade progression +source_sheet.jpg: the original drawing sheet with all sprites, maps, damage +values, monster and boss coins, and starting coins per map. map numbers on the +sheet start at 1 (M1-M4 are map0-map3) + +files in art/ stay as supplied. the build (see architecture.md) writes +processed copies to game/assets/. + + +state of the files +------------------ + +- t0-t3, m0-m4, b0-b3, p0-p3, c0-c3, hpb: cut out, transparent outside, white + inside. ready to use after trimming +- hpm: no transparency, the whole rectangle is opaque. usable as a bar +- towers have 5 levels. t0-t3 are level 1, already processed +- t*p: pencil outlines of tower levels 2-5 side by side. transparent outside + and inside. the build splits them and fills the inside white +- the strip drawings are close in design to level 1, and the scan scale may + differ. to check when processing that the sizes follow on from level 1 +- t3 level 5 is a different design from levels 1-4 (square with a barrel + instead of a triangle) +- maps: scans with paper edges. map and mask of the same number line up pixel + for pixel +- masks: soft (anti-aliased) edges, colours are pure red, blue and green + otherwise. map1 has branches, map2 has two entrances and loops + + +drawing direction +----------------- + +turning towers and projectiles are rotated to face their target. each sprite +records which way it points as drawn, so the game can correct for it. angles +as on screen: 0 is right, -90 is up. + +| sprite | points to | angle | +|---------------|-----------|-------| +| t0, all levels | does not turn | - | +| t1, all levels | right | 0 | +| t2, all levels | up | -90 | +| t3 levels 1-4 | up-right | -45 | +| t3 level 5 | up | -90 | +| p0 | up | -90 | +| p1 | any (square) | - | +| p2 | any (round) | - | +| p3 | up-right | -45 | + +the whole tower sprite turns, base included; the drawings do not separate a +base from a turret. rotation is around the centre of the trimmed image unless +the config sets another point. + +monsters and bosses face the viewer and are not rotated or mirrored. + + +hp bars +------- + +the bar is drawn cut to the share of hp left. the empty part is drawn as a +darkened copy of the bar (suggestion). hpm sits above every monster, hpb above +the boss. + + +art still needed +---------------- + +the game uses icons instead of text. until the drawings are supplied, the game +draws simple placeholder shapes and uses a system font for numbers. + +icons for the top bar and buttons: + +- heart +- coin counter (could reuse c0) +- wave counter +- pause and play +- game speed 1x and 2x +- start next wave early +- upgrade +- sell +- cancel or close +- sound on and off +- restart map +- back to map selection + +screens: + +- title, "minor monsters" +- map selection; small copies of the maps can serve as buttons +- locked map +- map won +- map lost + +numbers: + +- digits 0-9 for coins, hearts, wave, countdown and prices, in one consistent + size +- plus sign, for the early start bonus + +optional: + +- t0 spike burst, if p0 alone does not read well as an attack +- hit and death puffs +- a mark on slowed monsters +- a frame or background for the tower shop + +drawing tips for these: dark outline, white or coloured inside, on white +paper with space around each item, so the build can cut them out the same way +as the existing sprites. + + +possible addition +----------------- + +if decorated areas of a map, such as the lava pools on map3, should be off +limits for towers, a fourth mask colour (for example black) could mark them. +not decided. diff -r 000000000000 -r 7af9dd4e2595 doc/balance.md --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/doc/balance.md Sun Oct 18 01:26:39 2026 +0200 @@ -0,0 +1,267 @@ +balance +------- + +all game numbers in one place. the values used by the game are in the config +file (see architecture.md); this document explains them and records where each +one comes from. + +source markers: + +- notes: from the original design notes or the original drawing sheet, + decided +- decided: decided after the notes were written +- guess: a starting value for playtesting, expected to change +- derived: calculated from other values + +units: distances are in map pixels, that is pixels of the map image as +scanned. times are in seconds, speeds in map pixels per second. + + +scale +----- + +| item | value | source | +|------------------------------|-------|--------| +| map images | 1.0 | notes | +| towers, monsters, projectiles | 0.25 | notes ("maps scaled approx 400%") | +| coins | 0.4 | guess, 0.25 makes them about 10 pixels | +| hp bars | 0.25 | guess | + +measured from the masks (approximate, from red area divided by path width): + +| map | size | path width | path length, all branches | +|------|---------|------------|---------------------------| +| map0 | 705x697 | 56 | 1930 | +| map1 | 663x590 | 48 | 1350 | +| map2 | 618x537 | 42 | 2075 | +| map3 | 642x459 | 52 | 905 | + +a single route on map1 or map2 is shorter than the total. exact route lengths +come from the build (see architecture.md). + + +monsters +-------- + +| monster | hp | coins | speed | source | +|---------|----|-------|-------|--------| +| m0 | 5 | 1 | 35 | hp, coins: notes; speed: guess | +| m1 | 10 | 2 | 40 | as above | +| m2 | 15 | 3 | 45 | as above | +| m3 | 20 | 4 | 40 | as above | +| m4 | 30 | 6 | 35 | as above | +| b0 | 30 | 30 | 25 | as above | +| b1 | 50 | 50 | 25 | as above | +| b2 | 70 | 70 | 25 | as above | +| b3 | 100 | 100 | 25 | as above | + +regular monsters drop 0.2 coins per hp; bosses drop 1 coin per hp (derived). + +time to walk the whole path at 35-45 speed (derived): map0 about 50 s, map3 +about 23 s. + +animation (all guesses): + +- one hop takes 0.35 s +- hop height 5 +- squash on landing 6 % (wider and flatter), stretch in the air 4 % +- idle bob 2 % +- each monster starts at a random point in its hop cycle, so a group does not + hop in step + + +route preference +---------------- + +on maps with several routes, a monster picks one at spawn. faster monsters +prefer longer or straighter routes, slower ones prefer shortcuts (decided). + +proposed rule (guess): + +- for each route the build calculates its length and how much it turns (sum of + direction changes along the route) +- each route gets a value between 0 and 1: the average of its length relative + to the longest route and its straightness relative to the straightest route +- each monster gets a speed factor: its speed minus the reference speed, + divided by the reference speed, limited to -1..1 +- route weight = 1 + bias * speed factor * (2 * route value - 1), at least 0.1 +- a monster at the reference speed sees all routes as equally likely + +| parameter | value | source | +|-----------------|-------|--------| +| reference speed | 40 | guess | +| bias | 3 | guess | + +with the speeds above, m2 is the only regular monster faster than the +reference, and the effect on it is small. the speeds may need to spread out +more for the preference to be visible. + + +towers +------ + +towers have 5 levels (decided). the drawing sheet gives five damage values for +t0 and t1, and four for t2 and t3. level 5 of t2 and t3 continues the trend +(guess). + +| tower | damage by level | cost | range by level | attack every | projectile speed | source | +|-------|------------------|------|---------------------|--------------|------------------|--------| +| t0 | 5,10,15,20,25 | 5 | 45,48,51,54,57 | 1.5 s | none (melee) | damage, cost: notes; rest: guess | +| t1 | 3,7,13,17,23 | 10 | 100,104,108,112,116 | 0.7 s | 300 | as above | +| t2 | 1,3,5,7,9 | 20 | 90,94,98,102,106 | 1.2 s | 220 | damage 1-4, cost: notes; rest: guess | +| t3 | 1,5,7,10,13 | 25 | 220,230,240,250,260 | 1.3 s | 800 | damage 1-4: notes; cost: decided (was 40), may go lower; rest: guess | + +rules: + +- attack speed stays the same at every level (decided). t0 is slower than the + others (decided), t1 faster than t2, t2 faster than t3 (notes) +- range grows about 4 % per level (decided "slightly", amount guessed) +- t0 damages every monster in range at once, each attack +- t2 slow: hit monsters move at 0.60, 0.55, 0.50, 0.45, 0.40 of their speed + by level, for 2 s (guess). a new hit restarts the time. slows do not add up; + the strongest one applies +- p1, p2, p3 home in on their target. if the target dies first, the + projectile flies on to the last position and disappears (guess) +- towers aim at the monster furthest along its route (guess) + +costs (decided: level n costs base cost x n): + +| tower | level 1 (build) | level 2 | level 3 | level 4 | level 5 | total | +|-------|-----------------|---------|---------|---------|---------|-------| +| t0 | 5 | 10 | 15 | 20 | 25 | 75 | +| t1 | 10 | 20 | 30 | 40 | 50 | 150 | +| t2 | 20 | 40 | 60 | 80 | 100 | 300 | +| t3 | 25 | 50 | 75 | 100 | 125 | 375 | + +selling refunds half of the last purchase, rounded down (decided). this is +low for upgraded towers: a level 5 t1 cost 150 in total and sells for 25. + +| tower | level 1 | level 2 | level 3 | level 4 | level 5 | +|-------|---------|---------|---------|---------|---------| +| t0 | 2 | 5 | 7 | 10 | 12 | +| t1 | 5 | 10 | 15 | 20 | 25 | +| t2 | 10 | 20 | 30 | 40 | 50 | +| t3 | 12 | 25 | 37 | 50 | 62 | + +damage per second against a single target, at the guessed attack times +(derived): + +| tower | level 1 | level 2 | level 3 | level 4 | level 5 | +|-------|---------|---------|---------|---------|---------| +| t0 | 3.3 | 6.7 | 10.0 | 13.3 | 16.7 | +| t1 | 4.3 | 10.0 | 18.6 | 24.3 | 32.9 | +| t2 | 0.8 | 2.5 | 4.2 | 5.8 | 7.5 | +| t3 | 0.8 | 3.8 | 5.4 | 7.7 | 10.0 | + +t3 is meant to be weaker than the other towers; its range lets it reach more +targets (decided). to keep the gap moderate, its cost went from 40 to 25 and +its attack time from 2.0 s to 1.3 s, just slower than t2 as the notes require +(decided, amount guessed). at level 1 it deals about a fifth of t1's damage per +second at two and a half times the cost. its range covers more path, roughly +three times as much on a winding map (estimate). + + +placement +--------- + +| parameter | value | source | +|--------------------------------------------|-------|--------| +| tower footprint radius | 16 | guess | +| largest gap between footprint and path edge | 14 | guess | +| smallest distance between tower centres | 32 | derived (two footprints) | +| distance from the map edge | 16 | guess | +| snap radius, how far a tap may be from a legal position | 48 | guess | +| placement grid cell | 4 | guess | + +towers may not be placed on the entrance or exit areas. + + +economy +------- + +| map | starting coins | coins dropped in total | boss coins | regular monster coins | regular monster hp | +|------|----------------|------------------------|------------|-----------------------|--------------------| +| map0 | 10 | 100 | 30 | 70 | 350 | +| map1 | 20 | 200 | 50 | 150 | 750 | +| map2 | 40 | 400 | 70 | 330 | 1650 | +| map3 | 60 | 600 | 100 | 500 | 2500 | + +starting coins and the 10 x starting coins total are from the notes; the rest +is derived. early wave bonuses come on top of this total. + +the source sheet gives 50 starting coins for map3. the notes raise it to 60 to +make the step from map1 to map3 more even (10, 20, 40, 60 instead of 10, 20, +40, 50). likely to change after playtesting. + +share of the regular monster coins by monster level (guess). all monster +levels appear on all maps (decided): + +| map | m0 | m1 | m2 | m3 | m4 | +|------|------|------|------|------|------| +| map0 | 40 % | 25 % | 15 % | 10 % | 10 % | +| map1 | 30 % | 25 % | 20 % | 15 % | 10 % | +| map2 | 20 % | 20 % | 20 % | 20 % | 20 % | +| map3 | 15 % | 15 % | 20 % | 25 % | 25 % | + +resulting monster counts (derived, rounded): + +| map | m0 | m1 | m2 | m3 | m4 | monsters | coins | +|------|----|----|----|----|----|----------|-------| +| map0 | 28 | 9 | 4 | 2 | 1 | 44 | 72 | +| map1 | 45 | 19 | 10 | 6 | 2 | 82 | 149 | +| map2 | 66 | 33 | 22 | 16 | 11 | 148 | 328 | +| map3 | 75 | 38 | 33 | 31 | 21 | 198 | 500 | + +the build prints these totals from the actual wave lists and warns when a map +is more than 5 % off its coin total. + + +waves +----- + +| parameter | value | source | +|------------------------------------|---------------------|--------| +| waves per map | 6, 8, 10, 12 | guess | +| break before the first wave | 40 s | guess | +| break between waves | 25 s | guess ("longer", decided) | +| time between spawns within a group | 1.0 s, set per group | guess | +| early start bonus, coins per second left | 0.05, 0.1, 0.2, 0.3 by map | guess (starting coins / 200) | + +the bonus is rounded down. if every break is skipped at once, the bonus adds +about 6, 17, 45 and 82 coins per map (derived). + +suggested shape of a map's waves (guess): the coin value of wave n grows in +proportion to n, so the last wave is the largest. the boss comes at the end of +the last wave. later waves mix monster levels; early waves are mostly m0 and +m1. + + +hearts +------ + +| parameter | value | source | +|-------------------------|-------|--------| +| hearts per map | 10 | decided | +| heart cost of a monster | 1 | decided | +| heart cost of a boss | 5 | decided | + + +coins in flight +--------------- + +| parameter | value | source | +|----------------------------------|-------|--------| +| flight time to the counter | 0.7 s | guess | +| most coin sprites for one death | 8 | guess | + +coins are added to the counter at the moment the monster dies; the flying +coins only show it (guess). this keeps the counter correct for a player who +builds right after a kill. + + +controls +-------- + +| parameter | value | source | +|------------|--------|--------| +| game speeds | 1x, 2x | guess | diff -r 000000000000 -r 7af9dd4e2595 doc/game_design.md --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/doc/game_design.md Sun Oct 18 01:26:39 2026 +0200 @@ -0,0 +1,129 @@ +tower defense game design notes +------------------------------- + +numbers marked as guesses, and all speeds, ranges and timings, are collected in +balance.md. technical details are in architecture.md. + +- working title "minor monsters" +- runs as a plain html/javascript page, on desktop (mouse) and on tablets + (touch) +- the player only manages towers: build, upgrade, sell. everything else, such + as collecting coins, happens on its own +- no text in the game where an icon will do. icons, ui elements and any + remaining text are supplied as scribbles; see art.md for the list + +maps +---- + +- map levels 0-3: home, mine entrance, mine, lava depths + *mask images define play areas + monster enter from blue entrance, walk to green exit on red path + towers are placed along path +- maps are played in order. finishing a map unlocks the next one +- progress is stored in the browser (localStorage): unlocked maps and settings +- coins do not carry over between maps; each map starts with its own starting + coins +- map1 and map2 have branching paths, map2 has two entrances. a monster picks + its route when it spawns: + - faster monsters prefer longer or straighter routes + - slower monsters prefer shortcuts + - otherwise all routes are equally likely +- later maps have shorter paths and many more monsters + +towers +------ + +- towers: + - t0 is close range and projects spikes (p0) from all four sides + damage per tower level: 5,10,15,20 + cost 5 + melee tower: each attack damages every monster in range at once + slower attack than the other towers + spikes are only drawn on the sides that face the path + - t1 is the default generic towers, turns, shoots projectile p1 + damage: 3,7,13,17 + cost 10 + - t2 shoots projectile p2, turns, slows down monsters + slower than t1 + damage: 1,3,5,7 + cost 20 + - t3 is long range sniper tower, turns, shoots p3 + slower than t2 + damage 1,5,7,10 + cost 25 (first planned as 40, lowered for balance) +- art assets for tower levels still need to be processed, contain upgrades 1-4 + for each tower +- towers have 5 levels: t0-t3 are level 1 (the base), the four drawings in + each t*p strip are levels 2-5 + the original drawing sheet gives five damage values for t0 (5,10,15,20,25) + and t1 (3,7,13,17,23), and four for t2 and t3, as above. level 5 of t2 + and t3 is guessed in balance.md +- t3 is meant to be weaker than the other towers; its range lets it reach + more targets +- towers are placed next to the path, never on it. a tap or click snaps to the + nearest legal position, so the player does not have to hit an exact spot +- placing: pick a tower in the shop, tap the map. a preview with its range + appears at the snapped position; tapping the preview builds the tower, + tapping elsewhere moves the preview (suggestion) +- tapping a built tower shows its range and the upgrade and sell buttons +- tower upgrades cost tower base cost * tower level + the level is the new level: building is level 1 and costs the base cost, + the first upgrade (to level 2) costs twice the base cost +- upgrades mainly raise damage. range grows slightly, and so does the slowing + of t2. attack speed stays the same at all levels +- selling a tower refunds half the cost of its last purchase (the build, or + the last upgrade) + exception: a tower built and removed during the same pause, never used, + is refunded in full. the same applies to an upgrade bought and undone + during the same pause + +monsters +-------- + +- monsters m0-m4 are monster levels, drop 1/2/3/4/6 coins on death + hp 5/10/15/20/30 +- all monster levels appear on all maps, in different amounts and proportions. + low levels stay in the mix on later maps to balance the larger numbers +- monsters emulate animation with slight bobbing, squish/stretch on x and y by a + few percent; walking animation is by small hops; hops and animation may + overlap out of red path +- bosses are map-specific, b0 belongs to map0 etc; boss hp 30/50/70/100 coin + drop equal to hp +- hp bars are always shown above every monster. the boss uses its own bar, also + above the boss +- dropped coins fly to the coin counter on their own. each coin uses a random + one of c0-c3 + +economy and waves +----------------- + +- starting coins per map level: 10, 20, 40, 60 +- balance of monster speed vs tower fire frequency tbd +- several monster waves per map with breaks between them, total 10*map + starting coins, last wave includes boss +- the break between waves counts down, and the next wave starts on its own + when it runs out. a button starts the next wave early and pays a coin bonus + based on the seconds left. this is how most tower defense games handle it +- the breaks are longer than first planned, to give time to build + +hearts +------ + +- each map starts with a number of hearts +- a monster that reaches the exit costs one heart, a boss costs more +- at zero hearts the map is lost and can be restarted +- the map is won when the last wave, including the boss, is cleared + +controls +-------- + +- pause, with building, upgrading and selling allowed while paused +- game speed 1x and 2x (suggestion) +- input via pointer events, so mouse and touch work the same. no part of the + game depends on mouse hover + +sound +----- + +- placeholder beeps for now, generated in the browser +- voice recordings will replace them later; see sound.md diff -r 000000000000 -r 7af9dd4e2595 doc/roadmap.md --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/doc/roadmap.md Sun Oct 18 01:26:39 2026 +0200 @@ -0,0 +1,41 @@ +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 with the pause refund rule, t0 melee and spike sides, + t2 slow, boss with its bar +7. game flow + - title and map selection, unlocking, localStorage, restart +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. diff -r 000000000000 -r 7af9dd4e2595 doc/sound.md --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/doc/sound.md Sun Oct 18 01:26:39 2026 +0200 @@ -0,0 +1,49 @@ +sound +----- + +the first version uses placeholder beeps, generated in the browser (web audio +oscillator, a few notes each). voice recordings replace them later, one event +at a time. + + +events +------ + +| event | notes | +|----------------------|-------| +| t0 attack | | +| t1 shot | | +| t2 shot | | +| t3 shot | | +| monster hit | frequent; keep short or play only some of them | +| monster dies | | +| boss appears | | +| boss dies | | +| coins arrive | at most one per short interval | +| monster reaches exit | a heart is lost | +| wave starts | | +| early start bonus | | +| tower built | | +| tower upgraded | | +| tower sold | | +| placement refused | no legal spot within reach | +| button tap | | +| map won | | +| map lost | | + +several recordings per event are allowed; the game picks one at random. + + +recordings +---------- + +- recorded on any device, supplied in any common format +- the build trims silence, evens out volume, converts to one format that + desktop browsers and tablets (including safari) play, and embeds the result + as base64 in a javascript file. see architecture.md for why +- named after the event, with a number for variants + +browsers only play sound after the first user interaction. the first tap on +the title screen unlocks audio. + +sound can be switched off; the setting is stored with the other settings.