List of usage examples for com.badlogic.gdx Input getAccelerometerY
public float getAccelerometerY();
From source file:com.davidykay.shootout.screens.GameLoop.java
License:Apache License
@Override public void update(Application app) { simulation.update(app.getGraphics().getDeltaTime()); Input input = app.getInput(); final boolean ACCELEROMETER_STEERING = false; if (ACCELEROMETER_STEERING) { if (input.getAccelerometerY() < 0) simulation.moveShipLeft(app.getGraphics().getDeltaTime(), Math.abs(input.getAccelerometerY()) / 10); else/* w w w . j av a 2s.c o m*/ simulation.moveShipRight(app.getGraphics().getDeltaTime(), Math.abs(input.getAccelerometerY()) / 10); } if (input.isKeyPressed(Keys.DPAD_LEFT)) simulation.moveShipLeft(app.getGraphics().getDeltaTime(), 0.5f); if (input.isKeyPressed(Keys.DPAD_RIGHT)) simulation.moveShipRight(app.getGraphics().getDeltaTime(), 0.5f); if (input.justTouched()) { final float x = input.getX(); final float y = input.getY(); Vector3 nearVector = new Vector3(x, y, 0); Vector3 farVector = new Vector3(x, y, 1); renderer.unproject(nearVector); renderer.unproject(farVector); /** Vector tracing between the near plane and the far plane **/ Vector3 inVector = new Vector3(nearVector); final Plane gamePlane = new Plane(new Vector3(0, 0, 0), new Vector3(1, 0, 0), new Vector3(0, 0, 1)); Ray pickRay = renderer.getCamera().getPickRay(x, y); Vector3 intersection = new Vector3(); Vector3 finalVector; if (FLAT_MODE) { // Flat Mode if (Intersector.intersectRayPlane(pickRay, gamePlane, intersection)) { finalVector = new Vector3(intersection); if (finalVector.equals(nearVector)) { Gdx.app.log(TAG, String.format("Near Vector! finalVector:(%s)", finalVector.toString())); } else { Gdx.app.log(TAG, String.format("INTERSECTION! finalVector:(%s)", finalVector.toString())); } } else { Gdx.app.log(TAG, String.format("NO INTERSECTION. nearVector:(%s)", nearVector.toString())); finalVector = new Vector3(nearVector); } } else { // 3D Mode finalVector = new Vector3(nearVector); //for (Alien alien : aliens) { // if ( // Intersector.intersectRayPlane( // pickRay, // gamePlane, // intersection // ) // ) { // } //} } //simulation.tapShot(nearVector); //simulation.tapShot(finalVector); simulation.tapRay(pickRay); } else { // If we haven't been touched, let's look at the orientation. This in an attempt to lower // impulse from user's finger. float azimuth = input.getAzimuth(); float pitch = input.getPitch(); float roll = input.getRoll(); simulation.updateOrientation(azimuth, pitch, roll); } }
From source file:com.digitale.screens.GameLoop.java
License:Open Source License
/** * @param input//from www .j av a 2 s. com */ public void accellerometer(Input input) { // accelerometer if (input.getAccelerometerY() < -Stardust3d.deadzoneX || input.getAccelerometerY() > Stardust3d.deadzoneX) Ship.yawAngle -= (input.getAccelerometerY() * Stardust3d.accelXsensitivity); if (input.getAccelerometerX() < 4 - Stardust3d.deadzoneY) { Ship.pitchAngle -= Math.abs(input.getAccelerometerX() - (4 - Stardust3d.deadzoneY)) * Stardust3d.accelYsensitivity; } else if (input.getAccelerometerX() > 5 + Stardust3d.deadzoneY) { Ship.pitchAngle += Math.abs(input.getAccelerometerX() - (5 + Stardust3d.deadzoneY)) * Stardust3d.accelYsensitivity; } }