Java Code Examples for org.lwjgl.input.Mouse#getDX()
The following examples show how to use
org.lwjgl.input.Mouse#getDX() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: Camera.java From LowPolyWater with The Unlicense | 5 votes |
/** * Calculate the angle of the camera around the player (when looking down at * the camera from above). Basically the yaw. Changes the yaw when the user * moves the mouse horizontally with the LMB down. */ private void calculateAngleAroundPlayer() { if (Mouse.isButtonDown(0)) { float angleChange = Mouse.getDX() * YAW_SENSITIVITY; angleAroundPlayer.increaseTarget(-angleChange); } angleAroundPlayer.update(1f / 60); }
Example 2
Source File: Camera.java From OpenGL-Animation with The Unlicense | 5 votes |
/** * Calculate the angle of the camera around the player (when looking down at * the camera from above). Basically the yaw. Changes the yaw when the user * moves the mouse horizontally with the LMB down. */ private void calculateAngleAroundPlayer() { if (Mouse.isButtonDown(0)) { float angleChange = Mouse.getDX() * YAW_SENSITIVITY; angleAroundPlayer.increaseTarget(-angleChange); } angleAroundPlayer.update(DisplayManager.getFrameTime()); }
Example 3
Source File: Camera.java From OpenRS with GNU General Public License v3.0 | 5 votes |
public static void acceptInputRotate(float delta) { if(Mouse.isGrabbed()) { float mouseDX = Mouse.getDX(); float mouseDY = -Mouse.getDY(); rotation.y += mouseDX * mouseSensitivity * delta; rotation.x += mouseDY * mouseSensitivity * delta; rotation.x = Math.max(-maxLook, Math.min(maxLook, rotation.x)); } }
Example 4
Source File: Test.java From LWJGL-OpenGL-Tutorials with BSD 3-Clause "New" or "Revised" License | 5 votes |
@Override public void update(long deltaTime) { final float delta = deltaTime / (float)1e9; float turnSpeed = (float)Math.PI * delta; float moveSpeed = (Keyboard.isKeyDown(Keyboard.KEY_LSHIFT) ? 100 : 50) * delta; if(Mouse.isGrabbed()) { angle += turnSpeed * Mouse.getDX() / 20f; angleY -= turnSpeed * Mouse.getDY() / 20f; } if(Keyboard.isKeyDown(Keyboard.KEY_A)) position.add((float)Math.cos(angle + Math.PI) * moveSpeed, 0, (float)Math.sin(angle + Math.PI) * moveSpeed); if(Keyboard.isKeyDown(Keyboard.KEY_D)) position.sub((float)Math.cos(angle + Math.PI) * moveSpeed, 0, (float)Math.sin(angle + Math.PI) * moveSpeed); if(Keyboard.isKeyDown(Keyboard.KEY_W)) position.sub((float)Math.cos(angle + Math.PI / 2) * moveSpeed, 0, (float)Math.sin(angle + Math.PI / 2) * moveSpeed); if(Keyboard.isKeyDown(Keyboard.KEY_S)) position.add((float)Math.cos(angle + Math.PI / 2) * moveSpeed, 0, (float)Math.sin(angle + Math.PI / 2) * moveSpeed); if(Keyboard.isKeyDown(Keyboard.KEY_R)) position.reset(); if(Keyboard.isKeyDown(Keyboard.KEY_SPACE) && position.y() == 0) vy = 30; vy += gravity * delta; position.add(0, vy * delta, 0); if(position.y() < 0) { position.y(0); vy = 0; } }