diff --git a/core/src/ru/deadsoftware/cavedroid/game/mobs/Player.java b/core/src/ru/deadsoftware/cavedroid/game/mobs/Player.java
index 8fce1169be150a7a5e568adf1925ef6cb014afd2..70013367928b170cd8296542983c7780f2879b84 100644 (file)
private static final float SPEED = 69.072f;
private static final float JUMP_VELOCITY = -133.332f;
+ private static final int MAX_HEALTH = 20;
private boolean hitting = false;
private float hitAnim = 0f;
public final int[] inventory;
public int slot;
- public final int gameMode;
+ public int gameMode;
public boolean swim;
public float headRotation = 0f;
public Player() {
- super(0, 0, 4, 30, randomDir(), Type.MOB);
- this.gameMode = 1;
+ super(0, 0, 4, 30, randomDir(), Type.MOB, MAX_HEALTH);
inventory = new int[9];
swim = false;
}
this.y = pos.y;
mVelocity.setZero();
mDead = false;
+ heal(MAX_HEALTH);
}
public void pickUpDrop(Drop drop) {
}
}
+ public void setCurrentInventorySlotItem(int itemId) {
+ inventory[slot] = itemId;
+ }
+
@Override
public float getSpeed() {
return SPEED;
public void changeDir() {
}
+ @Override
+ public void damage(int damage) {
+ if (gameMode == 1) {
+ return;
+ }
+ super.damage(damage);
+ }
+
+ @Override
+ public void heal(int heal) {
+ if (gameMode == 1) {
+ return;
+ }
+ super.heal(heal);
+ }
+
private void drawItem(SpriteBatch spriteBatch, float x, float y, float anim) {
final int itemId = inventory[slot];
final Item item = GameItems.getItem(itemId);
if (hitAnim < 30f || hitAnim > 90f) {
if (hitting) {
+ hitAnim = MathUtils.clamp(hitAnim, 30f, 90f);
hitAnimDelta = -hitAnimDelta;
} else {
hitAnimDelta = ANIMATION_SPEED;