@@ -26,7 +26,6 @@ import {
2626 isKeyDown ,
2727 isKeyPressed ,
2828 createSolidTexture ,
29- getViewportSize ,
3029 drawText ,
3130 setAmbientLight ,
3231 addPointLight ,
@@ -81,8 +80,7 @@ setGIQuality({ probeSpacing: 4, cascadeCount: 5 });
8180
8281// --- Scene builders ---
8382
84- function drawDungeonScene ( dt : number ) {
85- const { width : VPW , height : VPH } = getViewportSize ( ) ;
83+ function drawDungeonScene ( dt : number , VPW : number , VPH : number ) {
8684 setBackgroundColor ( { r : 0.02 , g : 0.02 , b : 0.05 } ) ;
8785 setAmbientLight ( 0.05 , 0.05 , 0.08 ) ;
8886
@@ -155,8 +153,7 @@ function drawDungeonScene(dt: number) {
155153 addPointLight ( VPW - 72 , 408 , 120 , torchColor [ 0 ] , torchColor [ 1 ] , torchColor [ 2 ] , flicker * 0.5 ) ;
156154}
157155
158- function drawLavaScene ( dt : number ) {
159- const { width : VPW , height : VPH } = getViewportSize ( ) ;
156+ function drawLavaScene ( dt : number , VPW : number , VPH : number ) {
160157 setBackgroundColor ( { r : 0.05 , g : 0.01 , b : 0.0 } ) ;
161158 setAmbientLight ( 0.08 , 0.03 , 0.02 ) ;
162159
@@ -197,8 +194,7 @@ function drawLavaScene(dt: number) {
197194 }
198195}
199196
200- function drawOutdoorScene ( dt : number ) {
201- const { width : VPW , height : VPH } = getViewportSize ( ) ;
197+ function drawOutdoorScene ( dt : number , VPW : number , VPH : number ) {
202198
203199 // Use day/night cycle
204200 setDayNightCycle ( { timeOfDay } ) ;
@@ -257,8 +253,7 @@ function drawOutdoorScene(dt: number) {
257253 }
258254}
259255
260- function drawNeonScene ( dt : number ) {
261- const { width : VPW , height : VPH } = getViewportSize ( ) ;
256+ function drawNeonScene ( dt : number , VPW : number , VPH : number ) {
262257 setBackgroundColor ( { r : 0.02 , g : 0.02 , b : 0.04 } ) ;
263258 setAmbientLight ( 0.03 , 0.03 , 0.05 ) ;
264259
@@ -303,8 +298,7 @@ function drawNeonScene(dt: number) {
303298 }
304299}
305300
306- function drawComparisonScene ( dt : number ) {
307- const { width : VPW , height : VPH } = getViewportSize ( ) ;
301+ function drawComparisonScene ( dt : number , VPW : number , VPH : number ) {
308302 setBackgroundColor ( { r : 0.02 , g : 0.02 , b : 0.05 } ) ;
309303 setAmbientLight ( 0.05 , 0.05 , 0.08 ) ;
310304
@@ -375,7 +369,7 @@ game.onFrame((ctx) => {
375369 const dt = ctx . dt ;
376370 frameCount ++ ;
377371
378- const { width : VPW , height : VPH } = getViewportSize ( ) ;
372+ const { vpW : VPW , vpH : VPH } = ctx ;
379373
380374 clearLights ( ) ;
381375 clearEmissives ( ) ;
@@ -414,7 +408,6 @@ game.onFrame((ctx) => {
414408
415409 // Player movement with collision
416410 const speed = 200 * dt ;
417- const { width : VPW2 , height : VPH2 } = getViewportSize ( ) ;
418411 let newX = playerX ;
419412 let newY = playerY ;
420413 if ( isKeyDown ( "ArrowLeft" ) ) newX -= speed ;
@@ -427,14 +420,14 @@ game.onFrame((ctx) => {
427420 // Wall thickness on each side
428421 const wallW = 64 ;
429422 // Pillar bounds (scene 1 only)
430- const pillarL = VPW2 / 2 - 32 ;
431- const pillarR = VPW2 / 2 + 32 ;
432- const pillarT = VPH2 / 2 - 64 ;
423+ const pillarL = VPW / 2 - 32 ;
424+ const pillarR = VPW / 2 + 32 ;
425+ const pillarT = VPH / 2 - 64 ;
433426 const pillarB = pillarT + 128 ;
434427
435428 // Clamp to walls
436- newX = Math . max ( wallW + ph , Math . min ( VPW2 - wallW - ph , newX ) ) ;
437- newY = Math . max ( ph , Math . min ( VPH2 - ph , newY ) ) ;
429+ newX = Math . max ( wallW + ph , Math . min ( VPW - wallW - ph , newX ) ) ;
430+ newY = Math . max ( ph , Math . min ( VPH - ph , newY ) ) ;
438431
439432 // Pillar collision (dungeon scene)
440433 if ( currentScene === 1 ) {
@@ -459,19 +452,19 @@ game.onFrame((ctx) => {
459452 // Draw current scene
460453 switch ( currentScene ) {
461454 case 1 :
462- drawDungeonScene ( dt ) ;
455+ drawDungeonScene ( dt , VPW , VPH ) ;
463456 break ;
464457 case 2 :
465- drawLavaScene ( dt ) ;
458+ drawLavaScene ( dt , VPW , VPH ) ;
466459 break ;
467460 case 3 :
468- drawOutdoorScene ( dt ) ;
461+ drawOutdoorScene ( dt , VPW , VPH ) ;
469462 break ;
470463 case 4 :
471- drawNeonScene ( dt ) ;
464+ drawNeonScene ( dt , VPW , VPH ) ;
472465 break ;
473466 case 5 :
474- drawComparisonScene ( dt ) ;
467+ drawComparisonScene ( dt , VPW , VPH ) ;
475468 break ;
476469 }
477470
0 commit comments