X-Git-Url: https://deadsoftware.ru/gitweb?a=blobdiff_plain;f=core%2Fsrc%2Fru%2Fdeadsoftware%2Fcavecraft%2Fgame%2FGamePhysics.java;h=f8843f2c6851ba086a4c3a8e3fbb6aeccb61e529;hb=50082e8304a80c41dd8b1c1d80142e7c91a2d924;hp=f49eb178b9f9501ebfb783cc0382debde6ac190e;hpb=083e40ac85e4aca2df81d1ca16c0a54561c3bd38;p=cavedroid.git diff --git a/core/src/ru/deadsoftware/cavecraft/game/GamePhysics.java b/core/src/ru/deadsoftware/cavecraft/game/GamePhysics.java index f49eb17..f8843f2 100644 --- a/core/src/ru/deadsoftware/cavecraft/game/GamePhysics.java +++ b/core/src/ru/deadsoftware/cavecraft/game/GamePhysics.java @@ -21,12 +21,12 @@ public class GamePhysics { private boolean checkColl(Rectangle rect) { int[] bl = new int [6]; - bl[0] = gameProc.world.getForeMap(((int)(rect.x+2)/16), ((int)rect.y/16)); - bl[1] = gameProc.world.getForeMap(((int)(rect.x+rect.width-2)/16), ((int)rect.y/16)); - bl[2] = gameProc.world.getForeMap(((int)(rect.x+2)/16), ((int)(rect.y+rect.height/2)/16)); - bl[3] = gameProc.world.getForeMap(((int)(rect.x+rect.width-2)/16), ((int)(rect.y+rect.height/2)/16)); - bl[4] = gameProc.world.getForeMap(((int)(rect.x+2)/16), ((int)(rect.y+rect.height-1)/16)); - bl[5] = gameProc.world.getForeMap(((int)(rect.x+rect.width-2)/16), ((int)(rect.y+(rect.height-1))/16)); + bl[0] = gameProc.world.getForeMap(((int)(rect.x)/16), ((int)rect.y/16)); + bl[1] = gameProc.world.getForeMap(((int)(rect.x+rect.width-1)/16), ((int)rect.y/16)); + bl[2] = gameProc.world.getForeMap(((int)(rect.x)/16), ((int)(rect.y+rect.height/2)/16)); + bl[3] = gameProc.world.getForeMap(((int)(rect.x+rect.width-1)/16), ((int)(rect.y+rect.height/2)/16)); + bl[4] = gameProc.world.getForeMap(((int)(rect.x)/16), ((int)(rect.y+rect.height-1)/16)); + bl[5] = gameProc.world.getForeMap(((int)(rect.x+rect.width-1)/16), ((int)(rect.y+(rect.height-1))/16)); for (int b: bl) if (b>0) { return true; } @@ -36,6 +36,7 @@ public class GamePhysics { private void playerPhy(Player pl) { pl.position.add(pl.moveY); if (checkColl(pl.getRect())) { + pl.flyMode = false; pl.canJump = true; int d = -1; if (pl.moveY.y<0) d=1; else if (pl.moveY.y>0) d=-1; @@ -45,7 +46,7 @@ public class GamePhysics { } else { pl.canJump = false; } - pl.moveY.add(gravity); + if (!pl.flyMode) pl.moveY.add(gravity); pl.position.add(pl.moveX); if (pl.position.x<0 || pl.position.x+pl.width>gameProc.world.getWidth()*16)