For some reason the switch statement doesn't work for all cases. It only works for the 2nd and 4th cases. It doesn't matter which key it is, I've swapped them around and only the 2nd and 4th actually move the coordinates.
Am I not doing this switch statement correctly?
@Override
public void keyPressed(KeyEvent e) {
int code = e.getKeyCode();
switch(code) {
case KeyEvent.VK_DOWN:
y+=15;
case KeyEvent.VK_UP:
y-=15;
case KeyEvent.VK_RIGHT:
x+=15;
case KeyEvent.VK_LEFT:
x-=15;
}
repaint();
}