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