public void keyPressed(KeyEvent e) {
        int key = e.getKeyCode();
        if (key == KeyEvent.VK_A) {
            pressedLeft = true;
            dx = -1;
        }
        if (key == KeyEvent.VK_D) {
            pressedRight = true;
            dx = 1;
        }
        if (key == KeyEvent.VK_W) {
            pressedUp = true;
            dy = -1;
        }
        if (key == KeyEvent.VK_S) {
            pressedDown = true;
            dy = 1;
        }
    }