diff --git a/core/src/ru/deadsoftware/cavecraft/game/GamePhysics.java b/core/src/ru/deadsoftware/cavecraft/game/GamePhysics.java
index 3bd467d2ab05ce5ae97f0f9dc7f93efb49e0ead4..2d59d349118d0da781cc7d703aa9a2811768626a 100644 (file)
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;
}
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) + 1<gameProc.world.getWidth())
+ bl = gameProc.world.getForeMap(
(int)((rect.x+(rect.width/2))/16) + 1,
(int)(rect.y/16)+1);
break;
default:
bl=0;
}
- return (bl!=0);
+ return (bl>0 && Items.BLOCKS.getValueAt(bl).collision);
}
private boolean checkColl(Rectangle rect) {
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;