I tested it in windows, and the problem was not the same. I had all directions unless the space bar was pressed. I had similar trouble with Choppacide. I would up adding the “F” key as an alternative fire key and that cleared it up. In Choppacide I tried Shift, Cntl, and Alt, and it behaved the same as the Space Bar. There is either a java error with the arrow keys, or with the control keys.
When the space bar is pressed in your game, I have these directions in windows. “N, NE, E, S, W, NW”.
I will be back in a little bit.
Here is my key handling code. It seems to work well on most platforms.
public void keyPressed(KeyEvent e) {
// System.out.println(e.toString());
// TODO Auto-generated method stub
if(e.getKeyCode() == KeyEvent.VK_UP)
verticle = 1;
if(e.getKeyCode() == KeyEvent.VK_DOWN)
verticle = -1;
if(e.getKeyCode() == KeyEvent.VK_RIGHT)
rotation = 1;
if(e.getKeyCode() == KeyEvent.VK_LEFT)
rotation = -1;
if(e.getKeyCode() == KeyEvent.VK_F || e.getKeyCode() == KeyEvent.VK_SPACE)
fire = true;
if(e.getKeyCode() == KeyEvent.VK_ENTER)
button = 1;
if(e.getKeyCode() == KeyEvent.VK_ESCAPE)
button = 2;
}
public void keyReleased(KeyEvent e) {
// TODO Auto-generated method stub
if(e.getKeyCode() == KeyEvent.VK_UP)
if(verticle == 1)
verticle = 0;
if(e.getKeyCode() == KeyEvent.VK_DOWN)
if(verticle == -1)
verticle = 0;
if(e.getKeyCode() == KeyEvent.VK_RIGHT)
if(rotation == 1)
rotation = 0;
if(e.getKeyCode() == KeyEvent.VK_LEFT)
if(rotation == -1)
rotation = 0;
if(e.getKeyCode() == KeyEvent.VK_F || e.getKeyCode() == KeyEvent.VK_SPACE)
fire = false;
}