Skip to content

Commit ecaba39

Browse files
author
DavidQ
committed
Fix bezel path and gameplay background draw order, add transparent-window canvas fitting
BUILD_PR_LEVEL_10_20_FIX_BEZEL_PATH_AND_BACKGROUND_DRAW_ORDER & Fix bezel path and gameplay background draw order, improve transparent-window canvas fitting BUILD_PR_LEVEL_10_20_FIX_BEZEL_PATH_AND_BACKGROUND_DRAW_ORDER & Fix bezel path and gameplay background draw order, add exact transparency-window fitting rule BUILD_PR_LEVEL_10_20_FIX_BEZEL_PATH_AND_BACKGROUND_DRAW_ORDER
1 parent f87efd7 commit ecaba39

10 files changed

Lines changed: 631 additions & 27 deletions

asteroids.txt

-530 Bytes
Binary file not shown.

docs/dev/CODEX_COMMANDS.md

Lines changed: 22 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,10 @@ Implement the confirmed Asteroids runtime fixes:
1313
`games/Asteroids/assets/images/bezel.png`
1414

1515
2. Preserve canvas layout
16-
- do NOT resize the canvas
17-
- do NOT stretch the canvas to the viewport
16+
- do NOT resize the canvas internal game dimensions
17+
- do NOT stretch the game resolution
1818
- keep canvas centered
19-
- preserve intended game W x H dimensions
19+
- preserve intended game width and height
2020

2121
3. Fix background rendering
2222
- keep `backgroundImage` as a separate class/module from `fullscreenBezel`
@@ -30,16 +30,32 @@ Implement the confirmed Asteroids runtime fixes:
3030
- only show it in fullscreen
3131
- ensure it is visibly on screen, not just present in the DOM
3232

33-
5. Validate
33+
5. Use this exact bezel transparency fit rule
34+
- from left to right, find first transparent pixel
35+
- from right to left, find first transparent pixel
36+
- from top to bottom, find first transparent pixel
37+
- from bottom to top, find first transparent pixel
38+
- use those four values as the transparency window
39+
- maintain canvas aspect ratio
40+
- stretch the displayed canvas to fill the transparency window as much as possible
41+
- keep the displayed canvas centered in that window
42+
- do NOT change internal game resolution
43+
- if top/bottom does not fill, use that result for resize
44+
- if left/right does not fill, use that result for resize
45+
- if no valid transparency window is found, fall back to existing centered-canvas behavior
46+
47+
6. Validate
3448
- bezel URL/path not duplicated
3549
- bezel visible in fullscreen
36-
- canvas size unchanged
50+
- canvas internal size unchanged
3751
- canvas centered
52+
- exact four-direction transparency rule used
53+
- displayed canvas fills transparency window as fully as possible while preserving aspect ratio
3854
- background visible during gameplay
3955
- background absent in non-gameplay states
4056
- starfield no longer hides background incorrectly
4157

42-
6. Final packaging step is REQUIRED
58+
7. Final packaging step is REQUIRED
4359
- package ALL changed files into this exact repo-structured ZIP:
4460
`<project folder>/tmp/BUILD_PR_LEVEL_10_20_FIX_BEZEL_PATH_AND_BACKGROUND_DRAW_ORDER.zip`
4561

docs/dev/COMMIT_COMMENT.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
Fix bezel path duplication and background draw order without resizing canvas
1+
Fix bezel path and gameplay background draw order, add exact transparency-window fitting rule
22
BUILD_PR_LEVEL_10_20_FIX_BEZEL_PATH_AND_BACKGROUND_DRAW_ORDER
Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
- Reissued as strict docs-only BUILD_PR bundle
22
- Codex instructed to fix bezel path duplication
3-
- Canvas must remain centered at original W x H
3+
- Canvas internal size must remain unchanged and centered
44
- backgroundImage must render after clear and before starfield/world
55
- backgroundImage limited to gameplay states only
6+
- Updated bezel fitting requirement to use the exact four-direction first-transparent-pixel rule

docs/dev/reports/validation_checklist.txt

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
11
- Bundle is docs-only
22
- Codex command requires implementation by Codex, not ChatGPT
33
- Bezel URL/path must resolve once
4-
- Canvas must remain centered and unchanged in size
4+
- Canvas internal size must remain unchanged
5+
- Canvas must remain centered
6+
- Transparency window must use the exact four-direction first-transparent-pixel rule
7+
- Canvas display box must fill the transparency window as fully as possible while preserving aspect ratio
58
- Background must draw only during gameplay
69
- Background must draw before starfield/world content
710
- Codex output ZIP path must be:

docs/pr/BUILD_PR_LEVEL_10_20_FIX_BEZEL_PATH_AND_BACKGROUND_DRAW_ORDER.md

Lines changed: 33 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,14 @@ Prepare a docs-only BUILD_PR bundle for Codex to implement the confirmed Asteroi
88
Example bad URL:
99
`http://127.0.0.1:5500/games/Asteroids/games/Asteroids/assets/images/bezel.png`
1010

11-
2. Canvas must remain centered and keep its intended W x H dimensions.
11+
2. Canvas must keep its intended internal W x H dimensions and remain centered.
1212

1313
3. Background is still not visible and is likely being covered by starfield or another later draw pass.
1414

1515
4. Background should render only during gameplay, not attract, title, select-player, menu, or other non-gameplay states.
1616

17+
5. When a bezel image is loaded, the displayed canvas should be fit to the bezel transparency using the exact edge-detection rule below.
18+
1719
## Required implementation for Codex
1820

1921
### A. Fix fullscreen bezel path resolution
@@ -24,8 +26,8 @@ Prepare a docs-only BUILD_PR bundle for Codex to implement the confirmed Asteroi
2426
- Keep bezel as an HTML-level overlay above the canvas.
2527

2628
### B. Preserve canvas sizing and centering
27-
- Do not resize the canvas.
28-
- Do not stretch the canvas to the viewport.
29+
- Do not resize the canvas internal game dimensions.
30+
- Do not stretch the game resolution.
2931
- Keep the game canvas centered.
3032
- Preserve intended game width and height.
3133

@@ -43,12 +45,39 @@ Prepare a docs-only BUILD_PR bundle for Codex to implement the confirmed Asteroi
4345
- Show bezel only while fullscreen is active.
4446
- Ensure bezel is visibly on screen, not just present in the DOM.
4547

48+
### E. Exact bezel transparency fit rule
49+
When `bezel.png` is loaded, determine the transparent gameplay window exactly as follows:
50+
51+
1. From left to right, find the first transparent pixel.
52+
2. From right to left, find the first transparent pixel.
53+
3. From top to bottom, find the first transparent pixel.
54+
4. From bottom to top, find the first transparent pixel.
55+
56+
Use those four bounds as the bezel transparency window.
57+
58+
Then:
59+
- maintain canvas aspect ratio
60+
- stretch the displayed canvas to fill the transparency window as much as possible
61+
- do not change internal game resolution
62+
- keep the displayed canvas centered in that window
63+
64+
Selection rule:
65+
- If top/bottom does not fill, use that result for resize.
66+
- If left/right does not fill, use that result for resize.
67+
68+
Interpretation:
69+
- the display box should be driven by the transparency bounds
70+
- the goal is to fill the transparent gameplay area as fully as possible while keeping aspect ratio
71+
- fallback to existing centered-canvas behavior only if a valid transparency window cannot be determined
72+
4673
## Validation targets
4774
Codex must validate:
4875
- bezel URL/path is not duplicated
4976
- bezel is visible in fullscreen
50-
- canvas dimensions are unchanged
77+
- canvas internal dimensions are unchanged
5178
- canvas remains centered
79+
- transparency bounds are determined by the exact four-direction first-transparent-pixel rule
80+
- displayed canvas fills the transparency window as fully as possible while preserving aspect ratio
5281
- background is visible during gameplay
5382
- background does not render in non-gameplay states
5483
- starfield no longer hides background by draw order mistake

src/engine/runtime/backgroundImage.js

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,13 @@ export default class backgroundImage {
140140
return;
141141
}
142142

143-
const image = this.imageFactory(this.layer.path);
143+
const runtimePath = resolveRuntimeAssetUrl(this.layer.path, this.documentRef);
144+
if (!runtimePath) {
145+
this.layer.status = "missing";
146+
return;
147+
}
148+
149+
const image = this.imageFactory(runtimePath);
144150
if (!image || typeof image !== "object") {
145151
this.layer.status = "missing";
146152
return;
@@ -157,7 +163,7 @@ export default class backgroundImage {
157163
};
158164

159165
try {
160-
image.src = resolveRuntimeAssetUrl(this.layer.path, this.documentRef);
166+
image.src = runtimePath;
161167
} catch {
162168
this.layer.status = "missing";
163169
}

0 commit comments

Comments
 (0)