X-Git-Url: http://deadsoftware.ru/gitweb?a=blobdiff_plain;f=core%2Fsrc%2Fru%2Fdeadsoftware%2Fcavedroid%2Fgame%2FGameInput.java;h=29c8188d9d6c44f07946a8f464913a01fab1e0ea;hb=e7a1e15a93abaafa8e2e0435336483a198cc697c;hp=3da4e2e10c44b28e88bfb0236878acab48c15de6;hpb=2aa65a4cdb47df8014f28342d460fc6639bed885;p=cavedroid.git diff --git a/core/src/ru/deadsoftware/cavedroid/game/GameInput.java b/core/src/ru/deadsoftware/cavedroid/game/GameInput.java index 3da4e2e..29c8188 100644 --- a/core/src/ru/deadsoftware/cavedroid/game/GameInput.java +++ b/core/src/ru/deadsoftware/cavedroid/game/GameInput.java @@ -3,6 +3,7 @@ package ru.deadsoftware.cavedroid.game; import com.badlogic.gdx.Gdx; import com.badlogic.gdx.Input; import com.badlogic.gdx.graphics.g2d.TextureRegion; +import com.badlogic.gdx.math.MathUtils; import com.badlogic.gdx.utils.TimeUtils; import com.google.common.collect.Range; import ru.deadsoftware.cavedroid.MainConfig; @@ -68,7 +69,7 @@ public class GameInput { if (checkSwim()) { mPlayer.swim = true; } else if (mPlayer.canJump()) { - mPlayer.getVelocity().add(0, -180); + mPlayer.getVelocity().add(0, GamePhysics.PL_JUMP_VELOCITY); } else if (!mPlayer.isFlyMode() && mPlayer.gameMode == 1) { mPlayer.setFlyMode(true); mPlayer.getVelocity().y = 0; @@ -169,11 +170,18 @@ public class GameInput { Gdx.graphics.getWidth()) + gameRenderer.getCamX()); mCurX = tmpX / 16; - mCurY = (int) (Gdx.input.getY() * (mMainConfig.getHeight() / - Gdx.graphics.getHeight()) + gameRenderer.getCamY()) / 16; + final int tmpY = (int) (Gdx.input.getY() * (mMainConfig.getHeight() / + Gdx.graphics.getHeight()) + gameRenderer.getCamY()); + mCurY = tmpY / 16; + if (tmpX < 0) { mCurX--; } + + final double a = tmpX - mPlayer.x; + final double b = tmpY - mPlayer.y; + + mPlayer.headRotation = (float) Math.atan(b / a) * MathUtils.radDeg; } if (pastX != mCurX || pastY != mCurY) { @@ -386,6 +394,10 @@ public class GameInput { } public void touchDragged(float screenX, float screenY) { + if (Math.abs(screenX - mTouchDownX) < 16 && Math.abs(screenY - mTouchDownY) < 16) { + return; + } + mDragging = true; if (mMainConfig.checkGameUiWindow(GameUiWindow.CREATIVE_INVENTORY) && Math.abs(screenY - mTouchDownY) > 16) { if (insideCreativeInv(screenX, screenY)) {