(Underdepths) Pass 2
This commit is contained in:
37 files changed
+5590
No files matched your search
@@ -0,0 +1,21 @@
|
||||
Phase 1 is complete. ✅ `python3 tests/smoke.py --phase 1` → **7 passed, 0 failed** (exit 0).
|
||||
|
||||
## Summary
|
||||
|
||||
Created all Phase 1 files plus the `__init__.py` package markers:
|
||||
|
||||
| File | What it does |
|
||||
|------|-------------|
|
||||
| `data/constants.py` | All tuning constants: map size, tile ids, `LEVEL_XP`/`LEVEL_HP_GAIN`/`LEVEL_POWER_GAIN`, `PLAYER_BASE`, `COLORS`, room bounds, BSP split range (5–8), and the per-floor `SPAWN_TABLE` (floor 9 → 0 enemies / 2 potions) |
|
||||
| `entities/entity.py` | `@dataclass(slots=True) Rect` (read-only `.center`, `.intersects()` on interiors) and base `Entity` |
|
||||
| `entities/player.py` | `Player` + `make_player(x,y)` with `total_power`/`total_armor` (reads item `.stats`), `gain_xp` (threshold via `LEVEL_XP[level]`), `level_up` (stat grants + full heal), `equip` (returns previous to inventory), `heal` |
|
||||
| `entities/enemy.py` | `Enemy` + `make_enemy(kind,x,y)`; reads `data.enemies.ENEMIES` if present else an inline fallback roster matching plan.md for all 8 kinds (incl. `ranged_power` for archer, `can_split` for slime) |
|
||||
| `engine/map_gen.py` | `GameMap` dataclass, `generate_floor(...)`, `is_walkable(...)`. Recursive BSP (alternating/aspect axis, 5–8 splits) carving margin-shrunk rooms inside disjoint leaves → guaranteed no overlaps; sibling rooms joined by L-corridors → full flood-fill connectivity; stairs in the farthest room from spawn; floor 9 = single 20×15 boss arena, no stairs. Spawns items/enemies only if `data.items`/`data.enemies` exist (skipped cleanly in phase 1) |
|
||||
| `main.py` | Real pygame loop: forces dummy SDL drivers, 1280×800 window, generates floor 0, renders colored rects per tile + stairs + player, arrows/hjkl/yubn movement with walkability check, Esc to quit, 60 FPS cap; runs cleanly headless |
|
||||
|
||||
Key design guarantees that satisfy the gate:
|
||||
- **No room overlaps** — rooms are carved strictly inside disjoint BSP leaves with a clamped margin, so interiors can never overlap (touching boundaries return `False` from the strict-inequality `intersects`).
|
||||
- **Full connectivity** — recursive sibling-room corridor joining means every room center is reachable from `rooms[0].center` by a floor-only flood fill.
|
||||
- **Correct indexing** — `tiles[y][x]`, 1-tile wall border, `MAP_W=80`×`MAP_H=50`.
|
||||
|
||||
`.build_state` advanced to `1`.
|
||||
Reference in new issue
Block a user