Skip to content

Commit 9452273

Browse files
author
DavidQ
committed
Combine the 2D engine capability foundation into one low-PR pass
BUILD_PR_LEVEL_02_2D_CAPABILITY_COMBINED_FOUNDATION
1 parent 2a2ca43 commit 9452273

11 files changed

Lines changed: 365 additions & 60 deletions

docs/architecture/engine-bootstrap.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,3 +62,18 @@ This slice creates the foundation needed for every future subsystem without drag
6262
3. world/entity boundary
6363
4. renderer command boundary
6464
5. collision boundary
65+
66+
## 2D Capability Foundation (Combined)
67+
68+
Public engine homes used by the combined 2D baseline:
69+
- scene boot: `src/engine/scene/index.js`
70+
- render loop: `src/engine/core/Engine.js` with renderer + scene tick wiring
71+
- camera: `src/engine/camera/index.js`
72+
- tilemap integration: `src/engine/tilemap/index.js`
73+
- collision patterns: `src/engine/collision/index.js` and `src/engine/systems/CollisionResolutionSystem.js`
74+
- gameplay hooks: `src/engine/game/index.js` (`GameModeState`, gameplay hook helpers)
75+
76+
Combined service grouping used in this baseline:
77+
- scene boot + render loop + gameplay hooks
78+
- camera + tilemap integration
79+
- collision patterns + gameplay hooks

docs/dev/CODEX_COMMANDS.md

Lines changed: 30 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -2,56 +2,44 @@ MODEL: GPT-5.4
22
REASONING: high
33

44
COMMAND:
5-
Create `BUILD_PR_LEVEL_02_ENGINE_CORE_BASELINE_AND_BOUNDARY_PASS` as the first combined Section-2 PR.
5+
Create `BUILD_PR_LEVEL_02_2D_CAPABILITY_COMBINED_FOUNDATION` as one combined 2D capability PR.
66

77
Goal:
8-
Reduce PR count by grouping the engine-core baseline work into one coherent normalization pass.
8+
Finish the 2D Engine Capability cluster in the fewest practical PRs.
99

10-
Required work:
11-
1. Establish and normalize the engine-core boundaries/public homes for:
12-
- core bootstrapping
13-
- scene
14-
- rendering
15-
- input
16-
- physics
17-
- audio
18-
- systems
19-
20-
2. Treat these as one combined service cluster where practical:
21-
- timing/frame services
22-
- event routing
23-
- camera integration
24-
25-
3. Define/document only the necessary engine-level contracts and public boundaries needed to support the baseline pass.
10+
Target items to close in this PR if truthfully possible:
11+
- 2D scene boot
12+
- 2D render loop
13+
- 2D camera
14+
- 2D tilemap integration
15+
- 2D collision patterns
16+
- 2D gameplay hooks
2617

27-
4. Close as many section-2 items as truthfully possible in this one PR:
28-
- core bootstrapping normalized
29-
- scene management normalized
30-
- rendering layer normalized
31-
- input layer normalized
32-
- physics layer normalized
33-
- audio layer normalized
34-
- systems layer normalized
35-
- engine-level contracts documented
36-
- engine public boundaries clarified
37-
- timing/frame services stabilized
38-
- event routing stabilized
39-
- camera integration stabilized
40-
41-
5. If some items cannot truthfully be completed here:
42-
- leave only the true residue open
18+
Required work:
19+
1. Treat these as one coherent 2D engine slice, not six isolated tasks.
20+
2. Bundle the work logically:
21+
- scene boot + render loop + gameplay hooks
22+
- camera + tilemap integration
23+
- collision patterns + gameplay hooks
24+
3. Reuse existing validated repo patterns where possible.
25+
4. Keep the implementation engine-facing and reusable.
26+
5. Avoid game-specific hacks unless they are already the accepted engine pattern.
27+
6. Close as many of the six items as truthfully possible in this one PR.
28+
7. If anything remains open:
29+
- keep the residue very small
4330
- report exact blockers
44-
- keep the residue small enough for one follow-up PR if possible
31+
- leave it suitable for one residue-only PR
4532

46-
6. Update roadmap status markers only.
47-
- do NOT rewrite roadmap text
33+
Roadmap:
34+
- update status markers only
35+
- do NOT rewrite roadmap text
4836

49-
7. Final packaging step is REQUIRED:
50-
- package ALL changed files into this exact repo-structured ZIP:
51-
`<project folder>/tmp/BUILD_PR_LEVEL_02_ENGINE_CORE_BASELINE_AND_BOUNDARY_PASS.zip`
37+
Final packaging step is REQUIRED:
38+
- package ALL changed files into this exact repo-structured ZIP:
39+
`<project folder>/tmp/BUILD_PR_LEVEL_02_2D_CAPABILITY_COMBINED_FOUNDATION.zip`
5240

5341
Hard rules:
54-
- combine work to reduce PR count
55-
- keep changes coherent and surgical
42+
- combine aggressively to reduce PR count
43+
- coherent implementation over scattered edits
5644
- no unrelated repo changes
5745
- no missing ZIP

docs/dev/COMMIT_COMMENT.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
Start section 2 with a combined engine-core baseline and boundary pass
2-
BUILD_PR_LEVEL_02_ENGINE_CORE_BASELINE_AND_BOUNDARY_PASS
1+
Combine the 2D engine capability foundation into one low-PR pass
2+
BUILD_PR_LEVEL_02_2D_CAPABILITY_COMBINED_FOUNDATION

docs/dev/NEXT_COMMAND.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
BUILD_PR_LEVEL_02_ENGINE_CORE_RESIDUE_ONLY
1+
BUILD_PR_LEVEL_02_2D_CAPABILITY_RESIDUE_ONLY
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
- Added a combined Section-2 baseline PR to reduce PR count
2-
- Groups boundary normalization, contracts, and core runtime services into one coherent engine-core pass
3-
- Intended to close most of section 2 in one pass and leave only small residue if needed
1+
- Added a combined PR for the full 2D Engine Capability cluster
2+
- Bundles scene boot, render loop, camera, tilemap, collision, and gameplay hooks
3+
- Intended to finish the 2D capability lane in one pass or leave only a tiny residue
Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
1-
- Engine-core boundaries are clarified
2-
- Public boundaries/contracts are documented enough to support implementation
3-
- Timing/frame, event routing, and camera are treated as one combined service cluster where possible
4-
- Section-2 items closed in this PR are truthfully supported
5-
- Any remaining residue is small and explicit
1+
- 2D scene boot addressed
2+
- 2D render loop addressed
3+
- 2D camera addressed
4+
- 2D tilemap integration addressed
5+
- 2D collision patterns addressed
6+
- 2D gameplay hooks addressed
7+
- Any residue is explicit and minimal
68
- Roadmap updated by status markers only
79
- Output ZIP created at:
8-
<project folder>/tmp/BUILD_PR_LEVEL_02_ENGINE_CORE_BASELINE_AND_BOUNDARY_PASS.zip
10+
<project folder>/tmp/BUILD_PR_LEVEL_02_2D_CAPABILITY_COMBINED_FOUNDATION.zip

docs/dev/roadmaps/MASTER_ROADMAP_HIGH_LEVEL.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -152,12 +152,12 @@
152152
- [x] camera integration stabilized
153153

154154
### 2D Engine Capability
155-
- [ ] 2D scene boot
156-
- [ ] 2D render loop
157-
- [ ] 2D camera
158-
- [ ] 2D tilemap integration
159-
- [ ] 2D collision patterns
160-
- [ ] 2D gameplay hooks
155+
- [x] 2D scene boot
156+
- [x] 2D render loop
157+
- [x] 2D camera
158+
- [x] 2D tilemap integration
159+
- [x] 2D collision patterns
160+
- [x] 2D gameplay hooks
161161

162162
### 3D Engine Foundation
163163
- [ ] 3D scene boot
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
# BUILD_PR_LEVEL_02_2D_CAPABILITY_COMBINED_FOUNDATION
2+
3+
## Purpose
4+
Complete the 2D Engine Capability cluster as one coherent engine-facing slice with focused reusable boundaries and validation.
5+
6+
## Implemented changes
7+
8+
### 1) 2D gameplay-hook baseline
9+
- Added reusable gameplay hook helpers:
10+
- `src/engine/game/gameplayHooks.js`
11+
- exported via `src/engine/game/index.js`
12+
- Public helpers:
13+
- `isGameplayModeActive(modeOrState, activeModes?)`
14+
- `runIfGameplayMode(modeOrState, callback, activeModes?)`
15+
16+
### 2) Combined 2D capability validation slice
17+
- Added focused end-to-end baseline test:
18+
- `tests/core/Engine2DCapabilityCombinedFoundation.test.mjs`
19+
- This test validates one coherent 2D slice:
20+
- scene boot + render loop + gameplay hooks
21+
- camera + tilemap integration
22+
- collision patterns + gameplay hooks
23+
24+
### 3) Engine architecture documentation alignment
25+
- Updated `docs/architecture/engine-bootstrap.md` with explicit Section-2 2D capability homes and grouped service clusters.
26+
27+
### 4) Roadmap status updates
28+
- Updated only status markers for Section-2 2D capability items in:
29+
- `docs/dev/roadmaps/MASTER_ROADMAP_HIGH_LEVEL.md`
30+
31+
## 2D capability completion status
32+
- Completed in this PR:
33+
- 2D scene boot
34+
- 2D render loop
35+
- 2D camera
36+
- 2D tilemap integration
37+
- 2D collision patterns
38+
- 2D gameplay hooks
39+
- Remaining residue:
40+
- none for this six-item 2D capability cluster
41+
42+
## Validation run
43+
- `node --check src/engine/game/gameplayHooks.js`
44+
- `node --check src/engine/game/index.js`
45+
- `node --check tests/core/Engine2DCapabilityCombinedFoundation.test.mjs`
46+
- `node --input-type=module -e "import { run } from './tests/core/Engine2DCapabilityCombinedFoundation.test.mjs'; run();"`
47+
- `node --input-type=module -e "import { run } from './tests/core/EngineTiming.test.mjs'; run();"`
48+
- `node tests/core/Section1FinalResidueStructure.test.mjs`
49+
- `node tests/final/PrecisionCollisionSystems.test.mjs`
50+
- `node tests/render/Renderer.test.mjs`
51+
52+
## Packaging
53+
`<project folder>/tmp/BUILD_PR_LEVEL_02_2D_CAPABILITY_COMBINED_FOUNDATION.zip`

src/engine/game/gameplayHooks.js

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
/*
2+
Toolbox Aid
3+
David Quesenberry
4+
04/14/2026
5+
gameplayHooks.js
6+
*/
7+
function resolveModeValue(modeOrState) {
8+
if (typeof modeOrState === 'string') {
9+
return modeOrState;
10+
}
11+
12+
if (modeOrState && typeof modeOrState.getMode === 'function') {
13+
return modeOrState.getMode();
14+
}
15+
16+
if (modeOrState && typeof modeOrState.mode === 'string') {
17+
return modeOrState.mode;
18+
}
19+
20+
return '';
21+
}
22+
23+
export function isGameplayModeActive(modeOrState, activeModes = ['playing']) {
24+
const mode = resolveModeValue(modeOrState);
25+
if (!mode) {
26+
return false;
27+
}
28+
29+
const allowedModes = Array.isArray(activeModes) && activeModes.length > 0
30+
? activeModes
31+
: ['playing'];
32+
return allowedModes.includes(mode);
33+
}
34+
35+
export function runIfGameplayMode(modeOrState, callback, activeModes = ['playing']) {
36+
const mode = resolveModeValue(modeOrState);
37+
if (!isGameplayModeActive(mode, activeModes) || typeof callback !== 'function') {
38+
return { ran: false, mode, value: undefined };
39+
}
40+
41+
const value = callback();
42+
return { ran: true, mode, value };
43+
}

src/engine/game/index.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,4 @@ David Quesenberry
55
index.js
66
*/
77
export { default as GameModeState } from './GameModeState.js';
8+
export { isGameplayModeActive, runIfGameplayMode } from './gameplayHooks.js';

0 commit comments

Comments
 (0)