X-Git-Url: http://deadsoftware.ru/gitweb?a=blobdiff_plain;f=core%2Fsrc%2Fru%2Fdeadsoftware%2Fcavedroid%2Fgame%2FGamePhysics.java;h=1ff603c26148f9a473cd9705bfc29ae665e1690a;hb=6a71a9abc5bc34547c0e4bea7ab19a6bee628a3c;hp=70afcbfe5d3f1be77cdd772d61584b142022f7bd;hpb=462f97f8da742fe35f516fec00ca9a581d688e7a;p=cavedroid.git diff --git a/core/src/ru/deadsoftware/cavedroid/game/GamePhysics.java b/core/src/ru/deadsoftware/cavedroid/game/GamePhysics.java index 70afcbf..1ff603c 100644 --- a/core/src/ru/deadsoftware/cavedroid/game/GamePhysics.java +++ b/core/src/ru/deadsoftware/cavedroid/game/GamePhysics.java @@ -208,6 +208,11 @@ public class GamePhysics { if (d == -1) { mob.setCanJump(true); mob.setFlyMode(false); + + int dmg = ((int)Math.max(0f, (((mob.getVelocity().y * mob.getVelocity().y) / (2 * gravity.y)) - 48f) / 16f)); + if (dmg > 0) { + mob.damage(dmg); + } } mob.y = MathUtils.round(mob.getY()); @@ -218,14 +223,6 @@ public class GamePhysics { mob.getVelocity().y = 0; - - - //todo fall damage - // h = (v^2) / 2g - // dmg = max(0, (h - 48) / 32) - half of blocks fallen starting from 3 blocks height - // int dmg = ((int)Math.max(0f, (((mob.getVelocity().y * mob.getVelocity().y) / (2 * gravity.y)) - 48f) / 16f)); - // if (dmg > 0) System.out.println("Damage: " + dmg); - } else { mob.y += 1; mob.setCanJump(checkColl(mob)); @@ -321,7 +318,7 @@ public class GamePhysics { } } - for (Iterator it = mMobsController.getIterator(); it.hasNext(); ) { + for (Iterator it = mMobsController.getMobs().iterator(); it.hasNext(); ) { Mob mob = it.next(); mob.ai(mGameWorld, delta); mobPhy(mob, delta);