summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 75e8bbe)
raw | patch | inline | side by side (parent: 75e8bbe)
author | fred-boy <fred-boy@protonmail.com> | |
Mon, 10 Sep 2018 11:34:47 +0000 (18:34 +0700) | ||
committer | fred-boy <fred-boy@protonmail.com> | |
Mon, 10 Sep 2018 11:34:47 +0000 (18:34 +0700) |
core/src/ru/deadsoftware/cavecraft/game/GameInput.java | patch | blob | history | |
core/src/ru/deadsoftware/cavecraft/game/GamePhysics.java | patch | blob | history |
diff --git a/core/src/ru/deadsoftware/cavecraft/game/GameInput.java b/core/src/ru/deadsoftware/cavecraft/game/GameInput.java
index d151ec6b3279ffae07fc3e1e279e72cf3bb3e0be..c868a8adcb4250bb29c3ccd51127ec6844a3fefb 100644 (file)
this.gameProc = gameProc;
}
+ private boolean checkSwim() {
+ return (CaveGame.TOUCH && Items.isFluid(gameProc.world.getForeMap((int)(gameProc.player.position.x+gameProc.player.width/2)/16,
+ (int)(gameProc.player.position.y+gameProc.player.height/4*3)/16)));
+ }
+
private void wasdPressed(int keycode) {
if (gameProc.ctrlMode==0 || !CaveGame.TOUCH) {
switch (keycode) {
break;
case Input.Keys.SPACE:
- if (Items.isFluid(gameProc.world.getForeMap((int)(gameProc.player.position.x+gameProc.player.width/2)/16,
- (int)(gameProc.player.position.y+gameProc.player.height/4*3)/16))) {
+ if (checkSwim()) {
gameProc.swim = true;
} else if (gameProc.player.canJump) {
gameProc.player.moveY.add(0, -7);
switch (keycode) {
case Input.Keys.A: case Input.Keys.D:
gameProc.player.moveX.x = 0;
+ if (gameProc.swim) gameProc.swim = false;
break;
case Input.Keys.SPACE: case Input.Keys.CONTROL_LEFT:
if (gameProc.player.flyMode) gameProc.player.moveY.setZero();
- gameProc.swim = false;
+ if (gameProc.swim) gameProc.swim = false;
break;
}
}
diff --git a/core/src/ru/deadsoftware/cavecraft/game/GamePhysics.java b/core/src/ru/deadsoftware/cavecraft/game/GamePhysics.java
index 244875d9adecb9fbb33c8e2e4882982d5aa01b76..28a8333214fe4983c95f7e3f5ea868f536384910 100644 (file)
}
if (Items.isFluid(getBlock(pl.getRect()))) {
+ if (CaveGame.TOUCH && pl.moveX.x!=0 && !gameProc.swim && !pl.flyMode) gameProc.swim = true;
if (!gameProc.swim) {
if (!pl.flyMode && pl.moveY.y < 9) pl.moveY.add(gravity.x / 2, gravity.y / 2);
if (!pl.flyMode && pl.moveY.y > 9) pl.moveY.add(0, -.9f);
pl.moveY.add(0, -.5f);
if (pl.moveY.y<-3) pl.moveY.y = -3;
}
- } else if (!pl.flyMode && pl.moveY.y<18) pl.moveY.add(gravity);
+ } else {
+ if (!pl.flyMode && pl.moveY.y<18) pl.moveY.add(gravity);
+ if (CaveGame.TOUCH && gameProc.swim) gameProc.swim = false;
+ }
pl.position.add(pl.moveX);
if (checkColl(pl.getRect())) {