diff --git a/core/src/ru/deadsoftware/cavecraft/game/GameInputHandler.java b/core/src/ru/deadsoftware/cavecraft/game/GameInputHandler.java
index 899fbba6f06578dd4ca66ec47162e596cdc3a231..102a0f7b003f79471cca77e2dc3c65778debe6a3 100644 (file)
}
public void keyDown(int keyCode) {
- if (keyCode == Input.Keys.A) {
- gameProc.player.moveX.add(-GamePhysics.PL_SPEED,0);
- gameProc.player.dir = 0;
+ if (gameProc.ctrlMode==0) {
+ if (keyCode == Input.Keys.A) {
+ gameProc.player.moveX.add(-GamePhysics.PL_SPEED, 0);
+ gameProc.player.dir = 0;
+ }
+ if (keyCode == Input.Keys.D) {
+ gameProc.player.moveX.add(GamePhysics.PL_SPEED, 0);
+ gameProc.player.dir = 1;
+ }
+ } else {
+ if (keyCode == Input.Keys.A) {
+ gameProc.cursorX--;
+ }
+ if (keyCode == Input.Keys.D) {
+ gameProc.cursorX++;
+ }
+ if (keyCode == Input.Keys.W) {
+ gameProc.cursorY--;
+ }
+ if (keyCode == Input.Keys.S) {
+ gameProc.cursorY++;
+ }
+ if (gameProc.cursorX < 0)
+ gameProc.cursorX = 0;
+ if (gameProc.cursorX >= gameProc.world.getWidth())
+ gameProc.cursorX = gameProc.world.getWidth()-1;
+ if (gameProc.cursorY < 0)
+ gameProc.cursorY = 0;
+ if (gameProc.cursorY >= gameProc.world.getHeight())
+ gameProc.cursorY = gameProc.world.getHeight()-1;
}
- if (keyCode == Input.Keys.D) {
- gameProc.player.moveX.add(GamePhysics.PL_SPEED,0);
- gameProc.player.dir = 1;
+ if (keyCode == Input.Keys.ALT_LEFT) {
+ gameProc.ctrlMode++;
+ gameProc.cursorX = (int)(gameProc.player.position.x/16);
+ gameProc.cursorY = (int)(gameProc.player.position.y/16);
+ if (gameProc.ctrlMode > 1) gameProc.ctrlMode = 0;
+ }
+ if (keyCode == Input.Keys.SPACE) {
+ if (gameProc.player.canJump) {
+ gameProc.player.moveY.add(0, -7);
+ } else if (!gameProc.player.flyMode) {
+ gameProc.player.flyMode = true;
+ gameProc.player.moveY.setZero();
+ } else {
+ gameProc.player.moveY.y = -GamePhysics.PL_SPEED;
+ }
+ }
+ if (keyCode == Input.Keys.CONTROL_LEFT) {
+ gameProc.player.moveY.y = GamePhysics.PL_SPEED;
}
- if (keyCode == Input.Keys.SPACE &&
- gameProc.player.canJump) gameProc.player.moveY.add(0,-8);
}
public void keyUp(int keyCode) {
if (keyCode == Input.Keys.A || keyCode == Input.Keys.D) {
gameProc.player.moveX.x = 0;
}
+ if (keyCode == Input.Keys.SPACE) {
+ if (gameProc.player.flyMode) gameProc.player.moveY.setZero();
+ }
+ if (keyCode == Input.Keys.CONTROL_LEFT) {
+ if (gameProc.player.flyMode) gameProc.player.moveY.setZero();
+ }
}
public void mouseMoved(int screenX, int screenY) {
- gameProc.cursorX = (int)((screenX+gameProc.renderer.camera.position.x)/16);
- gameProc.cursorY = (int)((screenY+gameProc.renderer.camera.position.y)/16);
- if (gameProc.cursorX < 0)
- gameProc.cursorX = 0;
- if (gameProc.cursorX >= gameProc.world.getWidth())
- gameProc.cursorX = gameProc.world.getWidth()-1;
- if (gameProc.cursorY < 0)
- gameProc.cursorY = 0;
- if (gameProc.cursorY >= gameProc.world.getHeight())
- gameProc.cursorY = gameProc.world.getHeight()-1;
-
}
public void touchDown(int screenX, int screenY, int button) {