added gamestates and started pause screen
This commit is contained in:
@@ -6,9 +6,14 @@ import java.awt.event.KeyListener;
|
||||
public class KeyHandler implements KeyListener {
|
||||
|
||||
public boolean upPressed, downPressed, leftPressed, rightPressed;
|
||||
public GamePanel panel;
|
||||
// DEBUG
|
||||
public boolean checkDrawTime = false;
|
||||
|
||||
public KeyHandler(GamePanel panel) {
|
||||
this.panel = panel;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void keyTyped(KeyEvent e) {}
|
||||
|
||||
@@ -16,11 +21,17 @@ public class KeyHandler implements KeyListener {
|
||||
public void keyPressed(KeyEvent e) {
|
||||
int code = e.getKeyCode();
|
||||
switch (code) {
|
||||
// CONTROLS
|
||||
case KeyEvent.VK_W, KeyEvent.VK_UP -> upPressed = true;
|
||||
case KeyEvent.VK_S, KeyEvent.VK_DOWN -> downPressed = true;
|
||||
case KeyEvent.VK_A, KeyEvent.VK_LEFT -> leftPressed = true;
|
||||
case KeyEvent.VK_D, KeyEvent.VK_RIGHT -> rightPressed = true;
|
||||
|
||||
// DEBUG OPTIONS
|
||||
case KeyEvent.VK_T -> checkDrawTime = !checkDrawTime;
|
||||
|
||||
// GAME STATES
|
||||
case KeyEvent.VK_ESCAPE -> panel.gameState = (panel.gameState == GameState.PAUSE) ? GameState.PLAY : GameState.PAUSE;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user