question: public long loop ( ) { final long currentTimestamp = System . currentTimeMillis ( ) ; final long timeDiff = currentTimestamp - lastRunTimestamp ; final int shutdownDiff = ( int ) ( System . currentTimeMillis ( ) - gameShutdownRequestTimestamp ) ; final float shutdownProgress = shutdownDiff >= FLYING_SUPERMAN_DELAY && gameState . equals ( GameState . SHUTDOWN_REQUESTED ) ? ( shutdownDiff - FLYING_SUPERMAN_DELAY ) / ( float ) ( GAME_SHUTDOWN_DELAY - FLYING_SUPERMAN_DELAY ) : 0 ; snowflakesCollection . onTimePassed ( timeDiff ) ; presentsCollection . onTimePassed ( timeDiff ) ; if ( gameState . equals ( GameState . SHUTDOWN_REQUESTED ) ) { player . setyPos ( getDefaultPlayerHeight ( ) * ( 1 - shutdownProgress ) - ( player . getHeight ( ) * shutdownProgress ) ) ; supermanClouds . setyPos ( supermanClouds . getHeight ( ) * ( 1 - shutdownProgress ) - ( ( supermanClouds . getHeight ( ) - fieldHeight ) * shutdownProgress ) ) ; if ( shutdownProgress >= 1 ) { gameState = GameState . STOPPED ; } } else { if ( player . isInState ( PlayerState . CHEWING ) && player . getChewingDuration ( ) >= PLAYER_CHEWING_DURATION_IN_MS ) { player . setState ( PlayerState . DEFAULT ) ; } if ( player . isInState ( PlayerState . HIT ) && player . getHitDuration ( ) >= PLAYER_HIT_DURATION_IN_MS ) { player . setState ( PlayerState . DEFAULT ) ; } if ( newPlayerLocation != null ) { player . setxPos ( newPlayerLocation . x ) ; player . setyPos ( newPlayerLocation . y ) ; newPlayerLocation = null ; } } boolean playerBelowObject = updateFallingObjects ( timeDiff , shutdownProgress , snowflakesCollection , true , false ) | updateFallingObjects ( timeDiff , shutdownProgress , presentsCollection , false , true ) ; if ( player . isInState ( PlayerState . DEFAULT ) || player . isInState ( PlayerState . LOOKING_UP ) ) { if ( playerBelowObject ) { player . setState ( PlayerState . LOOKING_UP ) ; } else { player . setState ( PlayerState . DEFAULT ) ; } } lastRunTimestamp = currentTimestamp ; return timeDiff ; }
target:  Run the game loop. Call this every couple of ms.