Problems with mouse speed

Started by ug02070, March 21, 2005, 17:20:51

Previous topic - Next topic

ug02070

I am currently using the following to move my ship:

private boolean hasInput(int direction) {
   switch(direction) {
      case Keyboard.KEY_LEFT:
       return
         Keyboard.isKeyDown(Keyboard.KEY_LEFT) ||
         mouseX < 0 ||
         (Controller.isCreated() && Controller.getX() < 0);
     
     case Keyboard.KEY_RIGHT:
       return
         Keyboard.isKeyDown(Keyboard.KEY_RIGHT) ||
         mouseX > 0 ||
         (Controller.isCreated() && Controller.getX() > 0);
     
     case Keyboard.KEY_SPACE:
       return
         Keyboard.isKeyDown(Keyboard.KEY_SPACE) ||
         Mouse.isButtonDown(0) ||
         (Controller.isCreated() && Controller.isButtonDown(0));
   }
      return false;
   }

now movement with the keyboard is great but the mouse seems slow at moving left and right in comparison, is there anything that can be used to speed it up?
thanks

Matzon

2 things:
1 - dont check for isCreated all the time - do it after display creation, and no more.
2 - The reason keyboard is faster, is because it will be true each frame you render (if you hold button down). Mouse will only be true for 1 frame, and then false next frame unless you move it continually - but you can't move a mouse 1px 60fps.
If you want to move faster with the mouse, I suggest you multiply with the actually moved amount of pixels.

ug02070

what do you mean by this mate? how would i do it?
"I suggest you multiply with the actually moved amount of pixels"???
thanks :)

kappa

have a look at the space invaders demo included with lwjgl, it has it done nicely in there.