diff --git a/core/src/ru/deadsoftware/cavecraft/game/GamePhysics.java b/core/src/ru/deadsoftware/cavecraft/game/GamePhysics.java
index 101ff7950f8d7f5560a84daf0c772212265e4d85..88791dc67a59d337235c8a79d55c9080cb117c04 100644 (file)
private boolean checkJump(Rectangle rect, int dir) {
int bl;
- switch (dir) {
- case 0:
- bl = gp.world.getForeMap((int) ((rect.x - 8) / 16), (int) ((rect.y + rect.height - 8) / 16));
- if (checkColl(new Rectangle(rect.x - 8, rect.y - 18, rect.width, rect.height))) bl = 0;
- break;
- case 1:
- bl = gp.world.getForeMap((int) ((rect.x + rect.width + 8) / 16), (int) ((rect.y + rect.height - 8) / 16));
- if (checkColl(new Rectangle(rect.x + rect.width + 8, rect.y - 18, rect.width, rect.height))) bl = 0;
- break;
- default:
- bl = 0;
- }
+ int blX = (int) (rect.x + rect.width * dir - 8 + 16 * dir);
+ int blY = (int) (rect.y + rect.height - 8);
+
+ bl = gp.world.getForeMap(blX / 16, blY / 16);
+ if (checkColl(new Rectangle(blX, rect.y - 18, rect.width, rect.height))) bl = 0;
+
return (bl > 0 && GameItems.getBlock(bl).toJump() &&
- (rect.y + rect.height) - GameItems.getBlock(bl).getRect((int) ((rect.x - 8) / 16), (int) ((rect.y + rect.height - 8) / 16)).y > 8);
+ (rect.y + rect.height) - GameItems.getBlock(bl).getRect(blX / 16, blY / 16).y > 8);
}
private boolean checkColl(Rectangle rect) {
private void playerPhy(Player pl) {
pl.pos.y += pl.mov.y;
mobYColl(pl);
+ if (pl.isDead()) return;
if (GameItems.isFluid(getBlock(pl.getRect()))) {
if (CaveGame.TOUCH && pl.mov.x != 0 && !pl.swim && !pl.flyMode) pl.swim = true;
private void mobPhy(Mob mob) {
mob.pos.y += mob.mov.y;
mobYColl(mob);
+ if (mob.isDead()) return;
if (mob.getType() == 0 && GameItems.isFluid(getBlock(mob.getRect()))) {
if (mob.mov.y > 9) mob.mov.add(0, -.9f);