From: fred-boy Date: Sat, 21 Apr 2018 17:24:32 +0000 (+0700) Subject: Fix controls on Android X-Git-Tag: alpha0.2~1 X-Git-Url: https://deadsoftware.ru/gitweb?p=cavedroid.git;a=commitdiff_plain;h=19eb912d7ac7d2ef99f85ea4dd87c6611586891f Fix controls on Android --- diff --git a/core/src/ru/deadsoftware/cavecraft/game/GamePhysics.java b/core/src/ru/deadsoftware/cavecraft/game/GamePhysics.java index 2fdc29b..b20575a 100644 --- a/core/src/ru/deadsoftware/cavecraft/game/GamePhysics.java +++ b/core/src/ru/deadsoftware/cavecraft/game/GamePhysics.java @@ -24,6 +24,7 @@ public class GamePhysics { private boolean checkJump(Rectangle rect, int dir) { int bl = 0; + if (rect.x<0) rect.x-=16; switch (dir) { case 0: bl = gameProc.world.getForeMap( diff --git a/core/src/ru/deadsoftware/cavecraft/game/GameProc.java b/core/src/ru/deadsoftware/cavecraft/game/GameProc.java index 6c532ac..f3ea4ac 100644 --- a/core/src/ru/deadsoftware/cavecraft/game/GameProc.java +++ b/core/src/ru/deadsoftware/cavecraft/game/GameProc.java @@ -52,26 +52,22 @@ public class GameProc { } private void moveCursor() { - if (ctrlMode==0 && CaveGame.TOUCH) { - if (player.canJump) { - cursorX = (int) (player.position.x + player.texWidth / 2) / 16; - if (player.dir == 0) cursorX--; + if (ctrlMode == 0 && CaveGame.TOUCH) { + cursorX = (int) (player.position.x + player.texWidth / 2) / 16; + if (player.dir == 0) cursorX--; else cursorX++; - cursorY = (int) (player.position.y + player.texWidth) / 16; - if (!isAutoselectable(cursorX, cursorY)) { - cursorY++; - } - if (!isAutoselectable(cursorX, cursorY)) { - cursorY++; - } - if (!isAutoselectable(cursorX, cursorY)) { - if (player.dir == 0) cursorX++; - else cursorX--; - } - } else { - cursorX = (int) (player.position.x + player.texWidth / 2) / 16; - cursorY = (int) (player.position.y + player.height+8)/16; + cursorY = (int) (player.position.y + player.texWidth) / 16; + if (!isAutoselectable(cursorX, cursorY)) { + cursorY++; } + if (!isAutoselectable(cursorX, cursorY)) { + cursorY++; + } + if (!isAutoselectable(cursorX, cursorY)) { + if (player.dir == 0) cursorX++; + else cursorX--; + } + if (player.position.x<0) cursorX--; } else if (!CaveGame.TOUCH){ cursorX = (int)(Gdx.input.getX()* (renderer.camera.viewportWidth/GameScreen.getWidth())+renderer.camera.position.x)/16; @@ -86,10 +82,12 @@ public class GameProc { private void checkCursorBounds() { if (cursorY < 0) cursorY = 0; if (cursorY >= world.getHeight()) cursorY = world.getHeight()-1; - if (cursorX<(player.position.x+player.texWidth/2)/16) - player.dir=0; - if (cursorX>(player.position.x+player.texWidth/2)/16) - player.dir=1; + if (ctrlMode==1) { + if (cursorX*16+8player.position.x+player.texWidth/2) + player.dir=1; + } } public void update(float delta) {