Add Q/E rotation
This commit is contained in:
@@ -42,6 +42,9 @@ public class InputSynchronizer {
|
|||||||
|
|
||||||
private boolean clickAllowed = true;
|
private boolean clickAllowed = true;
|
||||||
|
|
||||||
|
private boolean isRotateLeft = false;
|
||||||
|
private boolean isRotateRight = false;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor initializes the InputSynchronizer with the application context.
|
* Constructor initializes the InputSynchronizer with the application context.
|
||||||
* Sets up input mappings and listeners for user interactions.
|
* Sets up input mappings and listeners for user interactions.
|
||||||
@@ -57,6 +60,18 @@ public class InputSynchronizer {
|
|||||||
setupInput();
|
setupInput();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void update(float tpf) {
|
||||||
|
if(isRotateLeft && isRotateRight) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if(isRotateLeft) {
|
||||||
|
rotationAngle += 180 * tpf;
|
||||||
|
}
|
||||||
|
if(isRotateRight) {
|
||||||
|
rotationAngle -= 180 * tpf;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Configures input mappings for various actions and binds them to listeners.
|
* Configures input mappings for various actions and binds them to listeners.
|
||||||
*/
|
*/
|
||||||
@@ -64,17 +79,19 @@ private void setupInput() {
|
|||||||
inputManager.addMapping("Settings", new KeyTrigger(KeyInput.KEY_ESCAPE));
|
inputManager.addMapping("Settings", new KeyTrigger(KeyInput.KEY_ESCAPE));
|
||||||
inputManager.addMapping("Forward", new KeyTrigger(KeyInput.KEY_RETURN));
|
inputManager.addMapping("Forward", new KeyTrigger(KeyInput.KEY_RETURN));
|
||||||
|
|
||||||
|
inputManager.addMapping("Left", new KeyTrigger(KeyInput.KEY_Q));
|
||||||
|
inputManager.addMapping("Right", new KeyTrigger(KeyInput.KEY_E));
|
||||||
|
|
||||||
inputManager.addMapping("RotateRightMouse", new MouseButtonTrigger(MouseInput.BUTTON_RIGHT));
|
inputManager.addMapping("RotateRightMouse", new MouseButtonTrigger(MouseInput.BUTTON_RIGHT));
|
||||||
inputManager.addMapping("MouseLeft", new MouseAxisTrigger(MouseInput.AXIS_X, false)); // Left movement
|
inputManager.addMapping("MouseLeft", new MouseAxisTrigger(MouseInput.AXIS_X, false)); // Left movement
|
||||||
inputManager.addMapping("MouseRight", new MouseAxisTrigger(MouseInput.AXIS_X, true)); // Right movement
|
inputManager.addMapping("MouseRight", new MouseAxisTrigger(MouseInput.AXIS_X, true)); // Right movement
|
||||||
inputManager.addMapping("MouseVertical", new MouseAxisTrigger(MouseInput.AXIS_Y, false), new MouseAxisTrigger(MouseInput.AXIS_Y, true)); //Mouse Up Down movement
|
|
||||||
inputManager.addMapping("MouseScrollUp", new MouseAxisTrigger(MouseInput.AXIS_WHEEL, false)); // Scroll up
|
inputManager.addMapping("MouseScrollUp", new MouseAxisTrigger(MouseInput.AXIS_WHEEL, false)); // Scroll up
|
||||||
inputManager.addMapping("MouseScrollDown", new MouseAxisTrigger(MouseInput.AXIS_WHEEL, true)); // Scroll down
|
inputManager.addMapping("MouseScrollDown", new MouseAxisTrigger(MouseInput.AXIS_WHEEL, true)); // Scroll down
|
||||||
inputManager.addMapping("Test", new KeyTrigger(KeyInput.KEY_J));
|
inputManager.addMapping("Test", new KeyTrigger(KeyInput.KEY_J));
|
||||||
inputManager.addMapping("Click", new MouseButtonTrigger(MouseInput.BUTTON_LEFT));
|
inputManager.addMapping("Click", new MouseButtonTrigger(MouseInput.BUTTON_LEFT));
|
||||||
|
|
||||||
|
|
||||||
inputManager.addListener(actionListener, "Settings", "Forward", "RotateRightMouse", "Click", "Test");
|
inputManager.addListener(actionListener, "Settings", "Forward", "RotateRightMouse", "Click", "Left", "Right", "Test");
|
||||||
inputManager.addListener(analogListener, "MouseLeft", "MouseRight", "MouseScrollUp", "MouseScrollDown");
|
inputManager.addListener(analogListener, "MouseLeft", "MouseRight", "MouseScrollUp", "MouseScrollDown");
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -127,6 +144,12 @@ else if(boardSelect != null) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
if (name.equals("Left")) {
|
||||||
|
isRotateLeft = !isRotateLeft;
|
||||||
|
}
|
||||||
|
if (name.equals("Right")) {
|
||||||
|
isRotateRight = !isRotateRight;
|
||||||
}
|
}
|
||||||
if(name.equals("Test") &&isPressed){
|
if(name.equals("Test") &&isPressed){
|
||||||
if(app.getView() instanceof GameView gameView){
|
if(app.getView() instanceof GameView gameView){
|
||||||
|
|||||||
@@ -80,16 +80,23 @@ public MdgaApp() {
|
|||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
AppSettings settings = new AppSettings(true);
|
AppSettings settings = new AppSettings(true);
|
||||||
settings.setSamples(128);
|
settings.setSamples(128);
|
||||||
settings.setWidth(prefs.getInt("width", 1280));
|
|
||||||
settings.setHeight(prefs.getInt("height", 720));
|
if(prefs.getBoolean("fullscreen", false)) {
|
||||||
settings.setFullscreen(prefs.getBoolean("fullscreen", false));
|
settings.setFullscreen(true);
|
||||||
|
} else {
|
||||||
|
settings.setWidth(prefs.getInt("width", 1280));
|
||||||
|
settings.setHeight(prefs.getInt("height", 720));
|
||||||
|
}
|
||||||
|
|
||||||
settings.setCenterWindow(true);
|
settings.setCenterWindow(true);
|
||||||
settings.setVSync(false);
|
settings.setVSync(false);
|
||||||
settings.setTitle("MDGA");
|
settings.setTitle("MDGA");
|
||||||
|
settings.setVSync(true);
|
||||||
MdgaApp app = new MdgaApp();
|
MdgaApp app = new MdgaApp();
|
||||||
app.setSettings(settings);
|
app.setSettings(settings);
|
||||||
app.setShowSettings(false);
|
app.setShowSettings(false);
|
||||||
app.setPauseOnLostFocus(false);
|
app.setPauseOnLostFocus(false);
|
||||||
|
app.setDisplayStatView(false);
|
||||||
|
|
||||||
app.start();
|
app.start();
|
||||||
}
|
}
|
||||||
@@ -128,6 +135,7 @@ public void simpleUpdate(float tpf) {
|
|||||||
view.update(tpf);
|
view.update(tpf);
|
||||||
acousticHandler.update();
|
acousticHandler.update();
|
||||||
notificationSynchronizer.update();
|
notificationSynchronizer.update();
|
||||||
|
inputSynchronizer.update(tpf);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
Reference in New Issue
Block a user