Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class KeyBinding implements KeyListener
- {
- public static int KEY_JUMP = KeyEvent.VK_Y;
- public static int KEY_ACTION = KeyEvent.VK_X;
- public static int KEY_INVENTORY = KeyEvent.VK_A;
- public static int KEY_LEFT = KeyEvent.VK_LEFT;
- public static int KEY_RIGHT = KeyEvent.VK_RIGHT;
- public static int KEY_UP = KeyEvent.VK_UP;
- public static int KEY_DOWN = KeyEvent.VK_DOWN;
- public static int KEY_RUN = KeyEvent.VK_C;
- public static boolean jumpDown;
- public static boolean actionDown;
- public static boolean inventoryDown;
- public static boolean leftDown;
- public static boolean rightDown;
- public static boolean upDown;
- public static boolean downDown;
- public static boolean runDown;
- @Override
- public void keyTyped(KeyEvent e)
- {
- }
- @Override
- public void keyPressed(KeyEvent e)
- {
- if(e.getKeyCode() == KEY_JUMP)
- {
- jumpDown = true;
- }
- if(e.getKeyCode() == KEY_ACTION)
- {
- actionDown = true;
- }
- if(e.getKeyCode() == KEY_INVENTORY)
- {
- inventoryDown = true;
- }
- if(e.getKeyCode() == KEY_LEFT)
- {
- leftDown = true;
- }
- if(e.getKeyCode() == KEY_RIGHT)
- {
- rightDown = true;
- }
- if(e.getKeyCode() == KEY_UP)
- {
- upDown = true;
- }
- if(e.getKeyCode() == KEY_DOWN)
- {
- downDown = true;
- }
- if(e.getKeyCode() == KEY_RUN)
- {
- runDown = true;
- }
- }
- @Override
- public void keyReleased(KeyEvent e)
- {
- if(e.getKeyCode() == KEY_JUMP)
- {
- jumpDown = false;
- }
- if(e.getKeyCode() == KEY_ACTION)
- {
- actionDown = false;
- }
- if(e.getKeyCode() == KEY_INVENTORY)
- {
- inventoryDown = false;
- }
- if(e.getKeyCode() == KEY_LEFT)
- {
- leftDown = false;
- }
- if(e.getKeyCode() == KEY_RIGHT)
- {
- rightDown = false;
- }
- if(e.getKeyCode() == KEY_UP)
- {
- upDown = false;
- }
- if(e.getKeyCode() == KEY_DOWN)
- {
- downDown = false;
- }
- if(e.getKeyCode() == KEY_RUN)
- {
- runDown = false;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement