public GameEngine(String windowTitle, int width, int height, boolean vSync, IGameLogic gameLogic) throws Exception { gameLoopThread = new Thread(this, "GAME_LOOP_THREAD"); window = new Window(windowTitle, width, height, vSync); mouseInput = new MouseInput(); this.gameLogic = gameLogic; timer = new Timer(); }
@Override public void update(float interval, MouseInput mouseInput) { // Update camera position camera.movePosition(cameraInc.x * CAMERA_POS_STEP, cameraInc.y * CAMERA_POS_STEP, cameraInc.z * CAMERA_POS_STEP); // Update camera based on mouse if (mouseInput.isRightButtonPressed()) { Vector2f rotVec = mouseInput.getDisplVec(); camera.moveRotation(rotVec.x * MOUSE_SENSITIVITY, rotVec.y * MOUSE_SENSITIVITY, 0); } }
protected void input() { mouseInput.input(window); gameLogic.input(window, mouseInput); }
protected void init() throws Exception { window.init(); timer.init(); mouseInput.init(window); gameLogic.init(window); }
@Override public void update(float interval, MouseInput mouseInput, Window window) { if (mouseInput.isRightButtonPressed()) { Vector2f rotVec = mouseInput.getDisplVec(); camera.moveRotation(rotVec.x * MOUSE_SENSITIVITY, rotVec.y * MOUSE_SENSITIVITY, 0); sceneChanged = true; boolean aux = mouseInput.isLeftButtonPressed(); if (aux && !this.leftButtonPressed && this.selectDetector.selectGameItem(gameItems, window, mouseInput.getCurrentPos(), camera)) { this.hud.incCounter();
protected void init() throws Exception { window.init(); timer.init(); mouseInput.init(window); gameLogic.init(window); }
@Override public void update(float interval, MouseInput mouseInput, Window window) { if (mouseInput.isRightButtonPressed()) { Vector2f rotVec = mouseInput.getDisplVec(); camera.moveRotation(rotVec.x * MOUSE_SENSITIVITY, rotVec.y * MOUSE_SENSITIVITY, 0); if (mouseInput.isLeftButtonPressed()) { this.selectDetector.selectGameItem(gameItems, window, mouseInput.getCurrentPos(), camera);
@Override public void update(float interval, MouseInput mouseInput) { // Update camera position camera.movePosition(cameraInc.x * CAMERA_POS_STEP, cameraInc.y * CAMERA_POS_STEP, cameraInc.z * CAMERA_POS_STEP); // Update camera based on mouse if (mouseInput.isRightButtonPressed()) { Vector2f rotVec = mouseInput.getDisplVec(); camera.moveRotation(rotVec.x * MOUSE_SENSITIVITY, rotVec.y * MOUSE_SENSITIVITY, 0); } }
public GameEngine(String windowTitle, int width, int height, boolean vSync, IGameLogic gameLogic) throws Exception { gameLoopThread = new Thread(this, "GAME_LOOP_THREAD"); window = new Window(windowTitle, width, height, vSync); mouseInput = new MouseInput(); this.gameLogic = gameLogic; timer = new Timer(); }
protected void init() throws Exception { window.init(); timer.init(); mouseInput.init(window); gameLogic.init(window); }
protected void input() { mouseInput.input(window); gameLogic.input(window, mouseInput); }
@Override public void update(float interval, MouseInput mouseInput) { // Update camera position camera.movePosition(cameraInc.x * CAMERA_POS_STEP, cameraInc.y * CAMERA_POS_STEP, cameraInc.z * CAMERA_POS_STEP); // Update camera based on mouse if (mouseInput.isRightButtonPressed()) { Vector2f rotVec = mouseInput.getDisplVec(); camera.moveRotation(rotVec.x * MOUSE_SENSITIVITY, rotVec.y * MOUSE_SENSITIVITY, 0); } }
public GameEngine(String windowTitle, int width, int height, boolean vSync, Window.WindowOptions opts, IGameLogic gameLogic) throws Exception { gameLoopThread = new Thread(this, "GAME_LOOP_THREAD"); window = new Window(windowTitle, width, height, vSync, opts); mouseInput = new MouseInput(); this.gameLogic = gameLogic; timer = new Timer(); }
protected void init() throws Exception { window.init(); timer.init(); mouseInput.init(window); gameLogic.init(window); }
protected void input() { mouseInput.input(window); gameLogic.input(window, mouseInput); }
@Override public void update(float interval, MouseInput mouseInput, Window window) { if (mouseInput.isRightButtonPressed()) { // Update camera based on mouse Vector2f rotVec = mouseInput.getDisplVec(); camera.moveRotation(rotVec.x * MOUSE_SENSITIVITY, rotVec.y * MOUSE_SENSITIVITY, 0); sceneChanged = true; } // Update camera position camera.movePosition(cameraInc.x * CAMERA_POS_STEP, cameraInc.y * CAMERA_POS_STEP, cameraInc.z * CAMERA_POS_STEP); lightAngle += angleInc; if (lightAngle < 0) { lightAngle = 0; } else if (lightAngle > 180) { lightAngle = 180; } float zValue = (float) Math.cos(Math.toRadians(lightAngle)); float yValue = (float) Math.sin(Math.toRadians(lightAngle)); Vector3f lightDirection = this.scene.getSceneLight().getDirectionalLight().getDirection(); lightDirection.x = 0; lightDirection.y = yValue; lightDirection.z = zValue; lightDirection.normalize(); // Update view matrix camera.updateViewMatrix(); }
public GameEngine(String windowTitle, int width, int height, boolean vSync, Window.WindowOptions opts, IGameLogic gameLogic) throws Exception { this.windowTitle = windowTitle; gameLoopThread = new Thread(this, "GAME_LOOP_THREAD"); window = new Window(windowTitle, width, height, vSync, opts); mouseInput = new MouseInput(); this.gameLogic = gameLogic; timer = new Timer(); }
protected void init() throws Exception { window.init(); timer.init(); mouseInput.init(window); gameLogic.init(window); }
protected void input() { mouseInput.input(window); gameLogic.input(window, mouseInput); }
@Override public void update(float interval, MouseInput mouseInput, Window window) { if (mouseInput.isRightButtonPressed()) { // Update camera based on mouse Vector2f rotVec = mouseInput.getDisplVec(); camera.moveRotation(rotVec.x * MOUSE_SENSITIVITY, rotVec.y * MOUSE_SENSITIVITY, 0); sceneChanged = true; } // Update camera position camera.movePosition(cameraInc.x * CAMERA_POS_STEP, cameraInc.y * CAMERA_POS_STEP, cameraInc.z * CAMERA_POS_STEP); lightAngle += angleInc; if (lightAngle < 0) { lightAngle = 0; } else if (lightAngle > 180) { lightAngle = 180; } float zValue = (float) Math.cos(Math.toRadians(lightAngle)); float yValue = (float) Math.sin(Math.toRadians(lightAngle)); Vector3f lightDirection = this.scene.getSceneLight().getDirectionalLight().getDirection(); lightDirection.x = 0; lightDirection.y = yValue; lightDirection.z = zValue; lightDirection.normalize(); // Update view matrix camera.updateViewMatrix(); }