Files
gijs_pong/.planning/STATE.md
Dabit 836cb01ec8 docs(02-01): complete paddle2 and AI opponent plan
- Create 02-01-SUMMARY.md with task commits, decisions, and dependency graph
- Update STATE.md: position at 02-02, add AI/difficulty decisions to context
- Update ROADMAP.md: Phase 2 in progress (1/2 plans)
- Mark REQUIREMENTS.md complete: CORE-08, AI-01, AI-02, AI-03, AI-04

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-10 21:08:12 +01:00

145 lines
5.9 KiB
Markdown

---
gsd_state_version: 1.0
milestone: v1.0
milestone_name: milestone
status: unknown
stopped_at: Completed 02-01-PLAN.md
last_updated: "2026-03-10T20:07:22.163Z"
progress:
total_phases: 5
completed_phases: 1
total_plans: 4
completed_plans: 3
---
# STATE: Super Pong Next Gen
**Project Reference**
- **Core Value:** Pong reimagined with juice and depth — spectacular visuals, rich mechanics, complete game experience
- **Current Focus:** Phase 1 — executing plans
- **Key Constraint:** Coarse granularity (5 phases max), HTML5 Canvas + vanilla JS, static deployment
---
## Current Position
| Attribute | Value |
|-----------|-------|
| **Phase** | 02-core-gameplay |
| **Plan** | Plan 1/2 — COMPLETE |
| **Status** | Phase 02 in progress — paddle2, AI module, predictive ray-cast, 3 difficulty levels done |
| **Progress** | 75% (3/4 plans complete; Phase 1 complete, Phase 2 plan 1 complete) |
```
[████████░░] 75% — Phase 2: 1/2 plans complete
```
---
## Performance Metrics
| Metric | Target | Status |
|--------|--------|--------|
| **Phase Coverage** | 100% (37/37 requirements mapped) | ✓ Complete |
| **Success Criteria** | 2-5 per phase | ✓ Complete |
| **Dependency Chain** | Linear (P1 → P2 → P3 → P4 → P5) | ✓ Validated |
| **01-01 Duration** | — | 1 min (2 tasks, 1 file) |
| **01-02 Duration** | — | 1 min (2 tasks, 1 file) |
---
| Phase 02-core-gameplay P01 | 2min | 2 tasks | 1 files |
## Accumulated Context
### Key Decisions Made
1. **Coarse Granularity Compression:** Research suggested 10 phases; compressed to 5 by merging:
- Game loop + input + physics = Phase 1
- Second paddle + AI = Phase 2
- Menus + audio + pause = Phase 3
- Visual effects + power-ups + arenas = Phase 4
- Performance + testing = Phase 5
2. **Phase 5 (Release) Has No Requirements:** All 37 v1 requirements covered by phases 1-4. Phase 5 is purely validation (cross-browser, performance, pitfall mitigation).
3. **Success Criteria Grounded in Research Pitfalls:** Each phase's criteria address critical pitfalls from research:
- Phase 1: DPI scaling, game loop timing
- Phase 2: Ball tunneling, input lag, AI balance
- Phase 3: Audio autoplay policy
- Phase 4: Power-up balance
- Phase 5: Performance, memory leaks, cross-browser
4. **deltaTime Cap at 50ms:** Game loop caps deltaTime to prevent physics explosion when tab loses focus and resumes — without this a single large delta would fling the ball off screen.
5. **Logical vs Bitmap Coordinate Separation:** canvas.width/height = logical * devicePixelRatio; ctx.scale(dpr, dpr) makes all game draw calls use logical pixels — correct HiDPI approach for sharp rendering on Retina displays.
6. **Module-Object Pattern Established:** GameLoop, Renderer, Input, Physics, GameState are plain JS objects with init() methods in a single script tag. No classes, no modules, no build step — runs directly from filesystem.
7. **e.code over e.key for Input:** Using e.code === 'KeyW' makes W/S detection layout-independent (works on AZERTY and other non-QWERTY keyboards).
8. **Zone angles [-60, -30, 5, 30, 60] degrees:** Center zone uses 5 deg not 0 to prevent infinite horizontal ball loops; top/bottom edges at 60 degrees for dramatic deflection.
9. **GameConfig centralizes tunable constants:** initialBallSpeed (220px/s), speedIncrement (18px/s), paddleSpeed (400px/s) — all adjustable without touching Physics logic.
10. **vx/vy recomputed from speed+angle each paddle hit:** Prevents compound rounding drift from repeated scaling; speed and direction always cleanly separated.
11. **AI uses predictive ray-cast with wall bounce simulation:** _predictBallY steps forward in time (up to 500 steps) simulating wall bounces — far more accurate than linear Y interpolation.
12. **AI difficulty presets as config objects:** { speed, reactionDelay, errorMargin } in GameConfig — all three dimensions of difficulty tunable without touching AI logic.
13. **AI waits when ball moves toward player (vx < 0):** Resets reaction timer and returns early — AI only acts when ball is heading toward its paddle, avoiding premature repositioning.
14. **Physics.onResize() calls init() for full reposition:** Ensures paddle2 (and paddle1) are properly repositioned on window resize rather than just updating width/height dimensions.
### Coverage Validation
**Total v1 Requirements:** 37
- CORE (8): All mapped to Phase 1-2
- AI (4): All mapped to Phase 2
- SCRN (4): All mapped to Phase 3
- VFX (5): All mapped to Phase 1 (DPI) and Phase 4 (particles/glow/trails/shake)
- PWR (7): All mapped to Phase 4
- ARENA (4): All mapped to Phase 4
- AUD (5): All mapped to Phase 3
**Unmapped Requirements:** 0 ✓
**Coverage:** 100% ✓
### Research Alignment
- Phase 1 addresses Research Pitfalls: #1 (Game Loop Timing), #2 (Canvas DPI Scaling)
- Phase 2 addresses Research Pitfalls: #3 (Ball Tunneling), #4 (Input Lag), #5 (AI Difficulty Balance)
- Phase 3 addresses Research Pitfall: #6 (WebAudio Autoplay Policy)
- Phase 4 addresses Research Pitfalls: #7 (Power-Up Balance)
- Phase 5 addresses Research Pitfall: #8 (Memory Leaks)
---
## Session Continuity
### What Just Happened
Phase 02 Plan 01 executed: paddle2 added to GameState (mirrors paddle1 structure), Input extended with ArrowUp/ArrowDown + named handler refs + cleanup(), AI module added with predictive ray-cast interception (wall-bounce simulation) and 3 difficulty presets (AI_EASY/MEDIUM/HARD). Physics._checkPaddle2Collision() added with 5-zone deflection sending ball LEFT. Physics.update() extended with paddle2 movement branch. Requirements CORE-08, AI-01, AI-02, AI-03, AI-04 satisfied.
### What Comes Next
1. Execute Phase 2 Plan 02 — mode selection UI, scoring system, win/game-over states, ball tunneling safeguards
2. Continue through phases 3-5 after Phase 2 complete
### Known Blockers
None.
### Decisions Pending
None.
### Last Session
Stopped at: Completed 02-01-PLAN.md
---
*State initialized: 2026-03-10*