From f57c1f16f8dcbd06b97708b91b40b928f6987832 Mon Sep 17 00:00:00 2001 From: w1n5t0n Date: Wed, 10 Jun 2026 15:23:22 +0200 Subject: [PATCH] feat: top-down 'Dogpit' arena mode (dota-like view) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Second game mode selectable at dog select (host-authoritative online): - js/sim_arena.js: top-down sim, same export surface as sim.js — x/y plane plus a z hop axis (Space / comma); KOs by knocking dogs into abyss pits - js/mapgen_arena.js: mirrored symmetric arenas — walls, pits, center clearing, guaranteed spawn-to-center corridors, crystals/spikes/launch pads, mirrored saw pairs; fallback pit pair since pits are the only KO mechanic - specials re-imagined per dog: zoom dash, ram + hop-slam, zip-leash slingshot, blink, hover (floats over pits/saws/spikes) - render: arena tiles with wall shadows + void pits, top-down dog drawing with z-lift over a ground shadow; new fall event/sfx - B.HOP input bit so 'up' can mean north in top-down (Space also jumps in side view); mode toggle UI + mode carried in start/rematch net messages Tested: arena mapgen determinism/symmetry/connectivity + chaotic matches + pit/hop scenarios headless; local chaos + full P2P arena match (host mode flip syncs to client) in two headless browsers with zero page errors. --- MAP.md | 10 +- README.md | 33 ++- index.html | 11 +- js/audio.js | 3 +- js/characters.js | 2 +- js/consts.js | 10 +- js/input.js | 4 +- js/main.js | 69 ++++-- js/mapgen_arena.js | 156 ++++++++++++ js/render.js | 241 +++++++++++++++++- js/sim.js | 4 +- js/sim_arena.js | 601 +++++++++++++++++++++++++++++++++++++++++++++ style.css | 9 + test/smoke.mjs | 124 ++++++++++ 14 files changed, 1226 insertions(+), 51 deletions(-) create mode 100644 js/mapgen_arena.js create mode 100644 js/sim_arena.js diff --git a/MAP.md b/MAP.md index a88b89c..ba18c17 100644 --- a/MAP.md +++ b/MAP.md @@ -6,15 +6,17 @@ Vanilla-JS canvas game, no build step. ES modules under `js/`, served statically - `style.css` — overlay/menu styling; canvas letterboxed to 16:9 via CSS. - `js/consts.js` — grid (TILE=12, 80×45 → 960×540), tile enum `T`, input bitmask `B`, item ids, physics constants, snapshot rate. - `js/rng.js` — seeded mulberry32 (`makeRng`); `randomSeed()` is UI-side only. -- `js/mapgen.js` — `generateMap(seed)`: ground heightmap, pits, towers, islands, one-way platforms, crystals (hp 3), pads, spikes, rail saws, spawns; `PALETTES`; `sawPos()` polyline eval (ping-pong or loop). +- `js/mapgen.js` — side-view `generateMap(seed)`: ground heightmap, pits, towers, islands, one-way platforms, crystals (hp 3), pads, spikes, rail saws, spawns; `PALETTES`; `sawPos()` polyline eval (ping-pong or loop). +- `js/mapgen_arena.js` — top-down `generateArena(seed)`: mirrored (left↔right) walls/pits, corner spawns, guaranteed corridors spawn→center, fallback pit pair (pits are the only KO mechanic), mirrored saw pairs. - `js/physics.js` — center-based AABB vs tile grid: `moveEntity` (per-axis, one-way platform aware), `raycast`, `boxFree`, `standingOnPlat`. - `js/characters.js` — `CHARS` data (stats + visual params) and `updateCharacter()`: per-dog special movement (air dash / charge+pound / grapple constraint / blink / jetpack). -- `js/sim.js` — **authoritative, DOM-free sim**: `createGame`, `step(game, inputs)` (60 Hz), combat (`hurt`: damage% → knockback), mining/items/hazards/KO/respawn/match-end, `snapshot`/`applySnapshot` for netplay. +- `js/sim.js` — **authoritative, DOM-free side-view sim**: `createGame`, `step(game, inputs)` (60 Hz), combat (`hurt`: damage% → knockback), mining/items/hazards/KO/respawn/match-end, `snapshot`/`applySnapshot` for netplay. Sets `game.kind='side'`. +- `js/sim_arena.js` — top-down "Dogpit" sim, **same export surface as sim.js** (main.js swaps modules per match). x/y plane + z hop axis; KOs via pit falls; specials re-imagined per dog (dash cooldown, ram/slam, zip-leash, blink, hover). Sets `game.kind='arena'`. - `js/input.js` — keyboard → bitmasks; slot 0 = WASD+FGH, slot 1 = arrows+KL;. - `js/net.js` — PeerJS wrapper: `hostRoom`/`joinRoom`; room key = host peer id suffix; signaling via PeerJS cloud, game traffic pure P2P. Runs a 2s heartbeat + 8s watchdog (WebRTC close events are unreliable); broker `network` errors are ignored once the data channel is up. -- `js/render.js` — canvas: cached seeded background, tiles, procedural dog drawing, particles/ghosts driven by sim events (`fxEvents`), HUD, banners. +- `js/render.js` — canvas: cached seeded background, tiles, procedural dog drawing, particles/ghosts driven by sim events (`fxEvents`), HUD, banners. Branches on `game.kind`: side view (`drawTiles`/`drawDog`) vs top-down (`drawTilesArena`/`drawDogTop`, z-height lifts the dog off its shadow). - `js/audio.js` — WebAudio-synthesized sfx; `playEvents` maps sim events → sounds. -- `js/main.js` — app state machine: screens, char select, three match drivers (local / host / client) sharing one rAF fixed-timestep loop. +- `js/main.js` — app state machine: screens, char select (incl. mode toggle: `gameMode` 'side'|'arena', host-authoritative over the wire via `mode`/`start`/`rematch` messages), three match drivers (local / host / client) sharing one rAF fixed-timestep loop; `matchSim` points at the active sim module. - `test/smoke.mjs` — `npm test`: headless mapgen determinism + chaotic full matches + targeted mining/stocks scenarios. ## Conventions & gotchas diff --git a/README.md b/README.md index 8c67052..8fadbde 100644 --- a/README.md +++ b/README.md @@ -4,6 +4,12 @@ wildly different movement physics brawl across procedurally generated arenas full of traps and mineable powerups. Last dog standing wins. +Two arena styles, picked at dog select: + +- **⛰ Parkour** (side view) — gravity, wall-jumps, one-way platforms, blast-zone KOs. +- **🐾 Dogpit** (top-down) — 8-way movement on a dota-style mirrored arena; + hop (third axis) over saws, spikes and abyss pits; KO by knocking dogs into the void. + No build step, no game server, no asset files — everything (art, sound, maps) is generated procedurally in the browser. @@ -18,12 +24,13 @@ Any static file server works (ES modules just need http://, not file://). ## Play -| | Move | Bite | Special | Item | -|---|---|---|---|---| -| **P1** | WASD | F | G | H | -| **P2** | arrows | K | L | ; | +| | Move | Bite | Special | Item | Hop (top-down) | +|---|---|---|---|---|---| +| **P1** | WASD | F | G | H | Space | +| **P2** | arrows | K | L | ; | , | -- **↑/W** jumps, **↓** drops through one-way platforms +- Side view: **↑/W** jumps (Space works too for P1), **↓** drops through one-way platforms +- Top-down: **Space/,** hops over pits, saw blades, spikes and bites - **Bite** is also your mining pick — crack open crystals for powerups - Damage % makes knockback grow (Smash-style); die by being launched past the arena edges or into the abyss. 3 stocks each. @@ -39,13 +46,15 @@ inputs and renders snapshots.) ## The dogs -| Dog | Breed | Movement identity | -|---|---|---| -| **Bolt** | Greyhound | Fastest runner, wall-slide/wall-jump, 8-way air dash | -| **Brick** | Bulldog | Massive knockback resistance, charging ram, ground-pound shockwave | -| **Lasso** | Lurcher | Leash grapple — anchor, reel, pendulum-swing, jump-release launch | -| **Wisp** | Saluki | Low gravity, double jump, blink-teleports through walls | -| **Stubbs** | Corgi | Jetpack (fuel refills on ground), butt-bounce off hard landings | +| Dog | Breed | Parkour (side) | Dogpit (top-down) | +|---|---|---|---| +| **Bolt** | Greyhound | Wall-slide/wall-jump, 8-way air dash | 8-way zoom dash on cooldown | +| **Brick** | Bulldog | Charging ram, ground-pound shockwave | Same ram; slam down from a hop | +| **Lasso** | Lurcher | Pendulum leash-swing, jump-release launch | Zip-leash: latch a wall, reel in, slingshot out | +| **Wisp** | Saluki | Low gravity, double jump, blink through walls | Blink through walls and over pits | +| **Stubbs** | Corgi | Jetpack, butt-bounce off hard landings | Hover — floats over pits, saws and spikes | + +All dogs keep their weight class: Brick barely launches, Wisp flies across the map. ## Arenas diff --git a/index.html b/index.html index a7291f1..d14ff3f 100644 --- a/index.html +++ b/index.html @@ -28,9 +28,9 @@
-
P1 WASD move · F bite · G special · H item
-
P2 arrows move · K bite · L special · ; item
-
↓ drops through platforms · bite crystals to mine powerups · last dog standing wins
+
P1 WASD move · F bite · G special · H item · Space hop
+
P2 arrows move · K bite · L special · ; item · , hop
+
bite crystals to mine powerups · last dog standing wins · two arena styles at dog select
@@ -55,6 +55,11 @@