diff --git a/core/src/ru/deadsoftware/cavedroid/game/GamePhysics.java b/core/src/ru/deadsoftware/cavedroid/game/GamePhysics.java
index cb5b64c844e1ca85886ea58c6269756d669f4f2c..9149705aefc07f1e97c337164434a93221928d2c 100644 (file)
import ru.deadsoftware.cavedroid.game.mobs.Player;
import ru.deadsoftware.cavedroid.game.objects.Drop;
import ru.deadsoftware.cavedroid.game.objects.DropController;
+import ru.deadsoftware.cavedroid.game.world.GameWorld;
import javax.inject.Inject;
import java.util.Iterator;
@GameScope
public class GamePhysics {
- public static final int PL_SPEED = 120;
+ public static final float PL_SPEED = 69.072f;
+ public static final float PL_JUMP_VELOCITY = -133.332f;
+ public static final float PL_TERMINAL_VELOCITY = 1254.4f;
- private final Vector2 gravity = new Vector2(0, .09f);
+ private final Vector2 gravity = new Vector2(0, 444.44f);
private final GameWorld mGameWorld;
private final MainConfig mMainConfig;
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) System.out.println("Damage: " + dmg);
}
mob.y = MathUtils.round(mob.getY());
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
+
} else {
mob.y += 1;
mob.setCanJump(checkColl(mob));
player.swim = true;
}
if (!player.swim) {
- if (!player.isFlyMode() && player.getVelocity().y < 270f) {
- player.getVelocity().x += gravity.y / 4;
+ if (!player.isFlyMode() && player.getVelocity().y < 32f) {
+ player.getVelocity().y += gravity.y * delta;
}
- if (!player.isFlyMode() && player.getVelocity().y > 270f) {
- player.getVelocity().add(0, -60f);
+ if (!player.isFlyMode() && player.getVelocity().y > 32f) {
+ player.getVelocity().y -= player.getVelocity().y * 32f * delta;
}
} else {
- player.getVelocity().add(0, -30f);
- if (player.getVelocity().y < -180) {
- player.getVelocity().y = -180;
+ player.getVelocity().y += PL_JUMP_VELOCITY * delta;
+ if (player.getVelocity().y < -PL_SPEED) {
+ player.getVelocity().y = -PL_SPEED;
}
}
} else {
- if (!player.isFlyMode() && player.getVelocity().y < 1080) {
- player.getVelocity().add(gravity);
+ if (!player.isFlyMode() && player.getVelocity().y < PL_TERMINAL_VELOCITY) {
+ player.getVelocity().y += gravity.y * delta;
}
}
mobXColl(player);
if (mMainConfig.isTouch() && !player.isFlyMode() && player.canJump() && player.getVelocity().x != 0 && checkJump(player)) {
- player.getVelocity().add(0, -480);
+ player.getVelocity().y = PL_JUMP_VELOCITY;
player.setCanJump(false);
}
}