package gulper; import java.awt.event.*; public class Listening implements KeyListener { public void keyPressed(KeyEvent e) { int key = e.getKeyCode(); switch(key) { case KeyEvent.VK_D: Component.isMoving = true; Component.dir = Component.character.movementSpeed; break; case KeyEvent.VK_A: Component.isMoving = true; Component.dir = -Component.character.movementSpeed; break; case KeyEvent.VK_W: Component.isJumping = true; break; case KeyEvent.VK_K: if(Inventory.selected < Tile.invLength-1) { Inventory.selected += 1; } else { Inventory.selected = 0; if(Inventory.selected > 0) { } } } public void keyReleased(KeyEvent e) { int key = e.getKeyCode(); switch(key) { case KeyEvent.VK_D: if(Component.dir == Component.character.movementSpeed) { Component.isMoving = false; } break; case KeyEvent.VK_A: if(Component.dir == -Component.character.movementSpeed) { Component.isMoving = false; } break; case KeyEvent.VK_W: Component.isJumping = false; break; } } public void keyTyped(KeyEvent e) { } }