X-Git-Url: http://deadsoftware.ru/gitweb?a=blobdiff_plain;f=core%2Fsrc%2Fru%2Fdeadsoftware%2Fcavecraft%2Fgame%2FGamePhysics.java;h=2d59d349118d0da781cc7d703aa9a2811768626a;hb=3170dad22d4643ae39e66a0d6a445df198418e73;hp=3bd467d2ab05ce5ae97f0f9dc7f93efb49e0ead4;hpb=503cd1720db3f53b7cbf7e3819968044de29a465;p=cavedroid.git diff --git a/core/src/ru/deadsoftware/cavecraft/game/GamePhysics.java b/core/src/ru/deadsoftware/cavecraft/game/GamePhysics.java index 3bd467d..2d59d34 100644 --- a/core/src/ru/deadsoftware/cavecraft/game/GamePhysics.java +++ b/core/src/ru/deadsoftware/cavecraft/game/GamePhysics.java @@ -4,6 +4,7 @@ import com.badlogic.gdx.math.MathUtils; import com.badlogic.gdx.math.Rectangle; import com.badlogic.gdx.math.Vector2; import com.badlogic.gdx.math.Vector3; +import ru.deadsoftware.cavecraft.Items; import ru.deadsoftware.cavecraft.game.mobs.Mob; import ru.deadsoftware.cavecraft.game.objects.Player; @@ -21,22 +22,24 @@ public class GamePhysics { } private boolean checkJump(Rectangle rect, int dir) { - int bl; + int bl = 0; switch (dir) { case 0: - bl = gameProc.world.getForeMap( + if ((int)((rect.x+(rect.width/2))/16) - 1>=0) + bl = gameProc.world.getForeMap( (int)((rect.x+(rect.width/2))/16) - 1, (int)(rect.y/16)+1); break; case 1: - bl = gameProc.world.getForeMap( + if ((int)((rect.x+(rect.width/2))/16) + 10 && Items.BLOCKS.getValueAt(bl).collision); } private boolean checkColl(Rectangle rect) { @@ -47,7 +50,7 @@ public class GamePhysics { 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) { + for (int b: bl) if (b>0 && Items.BLOCKS.getValueAt(b).collision) { return true; } return false;