DEADSOFTWARE

Mobs controller to kotlin
[cavedroid.git] / core / src / ru / deadsoftware / cavedroid / game / GamePhysics.java
index 70afcbfe5d3f1be77cdd772d61584b142022f7bd..1ff603c26148f9a473cd9705bfc29ae665e1690a 100644 (file)
@@ -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<Mob> it = mMobsController.getIterator(); it.hasNext(); ) {
+        for (Iterator<Mob> it = mMobsController.getMobs().iterator(); it.hasNext(); ) {
             Mob mob = it.next();
             mob.ai(mGameWorld, delta);
             mobPhy(mob, delta);