LWJGL Forum

Programming => OpenGL => Topic started by: ug02070 on March 21, 2005, 17:20:51

Title: Problems with mouse speed
Post by: ug02070 on March 21, 2005, 17:20:51
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
Title: Problems with mouse speed
Post by: Matzon on March 21, 2005, 18:00:40
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.
Title: Problems with mouse speed
Post by: ug02070 on March 21, 2005, 20:22:46
what do you mean by this mate? how would i do it?
"I suggest you multiply with the actually moved amount of pixels"???
thanks :)
Title: Problems with mouse speed
Post by: kappa on March 25, 2005, 15:47:44
have a look at the space invaders demo included with lwjgl, it has it done nicely in there.