Hi,
I'm currently coding a 3D game in lwjgl 2, and have a problem with my frame rate. I have a key based system of moving the camera, and a mouse based system of looking around, each contained in separate methods. Whenever I move the camera, the game runs at 60fps, however, when I move the mouse to look around, the frame rate drops until I stop moving the mouse.
The look around code:
public void moveMouse(Camera cam) {
int dx = Mouse.getDX();
int dy = Mouse.getDY();
if(inMenu == false) {
Mouse.setGrabbed(true);
cam.yaw(dx * 0.05f);
cam.pitch(dy * -0.05f);
} else {
Mouse.setGrabbed(false);
}
}
and the player movement code:
if (Keyboard.isKeyDown(Keyboard.KEY_W))
{
camera.walkForward(movementSpeed*dt);
}
if (Keyboard.isKeyDown(Keyboard.KEY_S))
{
camera.walkBackwards(movementSpeed*dt);
}
if (Keyboard.isKeyDown(Keyboard.KEY_A))
{
camera.strafeLeft(movementSpeed*dt);
}
if (Keyboard.isKeyDown(Keyboard.KEY_D))
{
camera.strafeRight(movementSpeed*dt);
}
if (Keyboard.isKeyDown(Keyboard.KEY_E))
{
camera.rollLeft(0.5f*dt);
}
*I'm trying to reveal as little code as possible as I plan to market this game in the near future.
Hope I provided enough evidence. Thanks in advance!