@@ -261,7 +261,7 @@ export class GameScene extends Phaser.Scene {
261261
262262 if ( this . pauseMenu . isOpen ) {
263263 this . updatePauseInput ( ) ;
264- const snapshot = this . player . getSnapshot ( ) ;
264+ let snapshot = this . player . getSnapshot ( ) ;
265265 this . playerView . render ( snapshot ) ;
266266 this . renderLighting ( snapshot ) ;
267267 this . updateHUD ( snapshot , [ ] ) ;
@@ -295,7 +295,7 @@ export class GameScene extends Phaser.Scene {
295295
296296 if ( this . roomTransition ) {
297297 this . updateRoomTransition ( rawFrameDt ) ;
298- const snapshot = this . player . getSnapshot ( ) ;
298+ let snapshot = this . player . getSnapshot ( ) ;
299299 this . playerView . render ( snapshot ) ;
300300 this . renderLighting ( snapshot ) ;
301301 this . updateHUD ( snapshot , effects ) ;
@@ -380,13 +380,17 @@ export class GameScene extends Phaser.Scene {
380380 }
381381 }
382382
383- const snapshot = this . player . getSnapshot ( ) ;
383+ let snapshot = this . player . getSnapshot ( ) ;
384384 this . playerView . tick ( snapshot , stepEffects , this . fixedDt ) ;
385385 effects . push ( ...stepEffects ) ;
386386
387387 if ( this . tryStartRoomTransition ( snapshot ) ) {
388388 break ;
389389 }
390+ if ( this . tryHandleBottomFallout ( snapshot ) ) {
391+ break ;
392+ }
393+ snapshot = this . player . getSnapshot ( ) ;
390394
391395 this . updateCamera ( snapshot , this . fixedDt ) ;
392396 this . accumulator = subFloat ( this . accumulator , this . fixedDt ) ;
@@ -871,6 +875,47 @@ export class GameScene extends Phaser.Scene {
871875 return true ;
872876 }
873877
878+ private tryHandleBottomFallout ( snapshot : ReturnType < Player [ "getSnapshot" ] > ) : boolean {
879+ const bounds = this . currentRoom . bounds ;
880+ if ( snapshot . top <= bounds . y + bounds . h ) {
881+ return false ;
882+ }
883+
884+ const roomBelow = findAdjacentRoom ( this . rooms , this . currentRoom , "down" , snapshot . centerX ) ;
885+ if ( roomBelow !== null ) {
886+ return false ;
887+ }
888+
889+ if ( this . beginBottomFalloutRespawn ( snapshot ) ) {
890+ return true ;
891+ }
892+
893+ this . player . bounceFromBottom ( bounds . y + bounds . h , this . keys . jump . isDown ) ;
894+ return false ;
895+ }
896+
897+ private beginBottomFalloutRespawn ( snapshot : ReturnType < Player [ "getSnapshot" ] > ) : boolean {
898+ if ( ! this . player . die ( { x : 0 , y : 0 } ) ) {
899+ return false ;
900+ }
901+ this . requestDeathShake ( ) ;
902+ this . controls . clearTransientState ( ) ;
903+ this . accumulator = 0 ;
904+ this . freezeTimer = 0 ;
905+ this . roomTransition = null ;
906+ this . startDeathRespawnSequence ( {
907+ kind : "normal" ,
908+ exploded : false ,
909+ revealStarted : false ,
910+ respawnStarted : false ,
911+ respawnSourceX : snapshot . centerX ,
912+ respawnSourceY : snapshot . centerY ,
913+ knockback : null ,
914+ } ) ;
915+ this . startTransitionExplosion ( snapshot ) ;
916+ return true ;
917+ }
918+
874919 private enforceCurrentRoomTopLimit ( ) : void {
875920 const snapshot = this . player . getSnapshot ( ) ;
876921 const roomAbove = findAdjacentRoom ( this . rooms , this . currentRoom , "up" , snapshot . centerX ) ;
0 commit comments