Package engine

Source Code of engine.Keyboard

package engine;

import java.awt.event.KeyEvent;

import com.threed.jpct.util.KeyMapper;
import com.threed.jpct.util.KeyState;

public class Keyboard {
  public static boolean KEY_P;
  public static boolean KEY_ESC;
 
  public static boolean PAGE_UP_PRESSED;
  public static boolean PAGE_DOWN_PRESSED;
  public static boolean UP_PRESSED;
  public static boolean DOWN_PRESSED;
  public static boolean LEFT_PRESSED;
  public static boolean RIGHT_PRESSED;
 
  public static boolean KEY_1;
  public static boolean KEY_2;
  public static boolean KEY_3;
  public static boolean KEY_4;
  public static boolean KEY_5;
  public static boolean KEY_6;
  public static boolean KEY_7;
  public static boolean KEY_8;
  public static boolean KEY_9;
  public static boolean KEY_0;
 
  public static boolean KEY_F1;
 
  private static KeyMapper keyMapper = new KeyMapper();
 
  public static void handleKeys(){
    KeyState state = null;
    while((state = keyMapper.poll()) != KeyState.NONE){
      int code = state.getKeyCode();
      if(code == KeyEvent.VK_1){
        KEY_1 = state.getState();
      }
      else if(code == KeyEvent.VK_2){
        KEY_2 = state.getState();
     
      else if(code == KeyEvent.VK_3){
        KEY_3 = state.getState();
      }
      else if(code == KeyEvent.VK_4){
        KEY_4 = state.getState();
     
      else if(code == KeyEvent.VK_5){
        KEY_5 = state.getState();
      }
      else if(code == KeyEvent.VK_6){
        KEY_6 = state.getState();
      }
      else if(code == KeyEvent.VK_7){
        KEY_7 = state.getState();
      }
      else if(code == KeyEvent.VK_8){
        KEY_8 = state.getState();
      }
      else if(code == KeyEvent.VK_9){
        KEY_9 = state.getState();
      }
      else if(code == KeyEvent.VK_0){
        KEY_0 = state.getState();
      }
      else if(code == KeyEvent.VK_DOWN){
        DOWN_PRESSED = state.getState();
      }
      else if(code == KeyEvent.VK_UP){
        UP_PRESSED = state.getState();
     
      else if(code == KeyEvent.VK_LEFT){
        LEFT_PRESSED = state.getState();
      }
      else if(code == KeyEvent.VK_RIGHT){
        RIGHT_PRESSED = state.getState();
     
      else if(code == KeyEvent.VK_PAGE_DOWN){
        PAGE_DOWN_PRESSED = state.getState();
      }
      else if(code == KeyEvent.VK_PAGE_UP){
        PAGE_UP_PRESSED = state.getState();
      }
      else if(code == KeyEvent.VK_F1){
        KEY_F1 = state.getState();
      }
      else if(code == KeyEvent.VK_P){
        KEY_P = state.getState();
      }
      else if(code == KeyEvent.VK_ESCAPE){
        KEY_ESC = state.getState();
      }
    }   
  }
}
TOP

Related Classes of engine.Keyboard

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.