src/KeyInput.java
/**
     * Processes all the keys that are currently being held down
     */
Processes all the keys that are currently being held down
Processes all the keys that are currently being held down
public static void process(){
        for(int key : keysDown){
            if(Game.gameState.equals("game")){
                Player p = Game.player;
                if(key == KeyEvent.VK_LEFT) {
                    if(p.speed == 0) p.speed++;
                    p.setVelX(-p.speed);
                    leftPressed = true;
                }else if(key == KeyEvent.VK_RIGHT){
                    if(p.speed == 0) p.speed++;
                    p.setVelX(p.speed);
                    rightPressed = true;
                }else if((key == KeyEvent.VK_SPACE || key == KeyEvent.VK_UP) && (!p.isJumping() || p.boosted) && !p.isSleeping()) {
                    p.setVelY(Math.max(-(p.speed+5),-15));
                    p.setJumping(true);
                }
                if(key == KeyEvent.VK_ESCAPE){
                    System.exit(1);
                }
                if(key == KeyEvent.VK_L){
                    p.speed = 20;
                    p.boosted = true;
                }
            }
        }
    }
public static void process ( ) { for ( int key : keysDown ) { if ( Game . gameState . equals ( "game" ) ) { Player p = Game . player ; if ( key == KeyEvent . VK_LEFT ) { if ( p . speed == 0 ) p . speed ++ ; p . setVelX ( - p . speed ) ; leftPressed = true ; } else if ( key == KeyEvent . VK_RIGHT ) { if ( p . speed == 0 ) p . speed ++ ; p . setVelX ( p . speed ) ; rightPressed = true ; } else if ( ( key == KeyEvent . VK_SPACE || key == KeyEvent . VK_UP ) && ( ! p . isJumping ( ) || p . boosted ) && ! p . isSleeping ( ) ) { p . setVelY ( Math . max ( - ( p . speed + 5 ) , - 15 ) ) ; p . setJumping ( true ) ; } if ( key == KeyEvent . VK_ESCAPE ) { System . exit ( 1 ) ; } if ( key == KeyEvent . VK_L ) { p . speed = 20 ; p . boosted = true ; } } } }
Processes all the keys that are currently being held down
Processes all the keys that are currently being held down