X-Git-Url: http://deadsoftware.ru/gitweb?a=blobdiff_plain;f=core%2Fsrc%2Fru%2Fdeadsoftware%2Fcavedroid%2Fgame%2Fmobs%2FMob.java;h=4ad04e8538affb3b49e3bbf2eb0f80a796ce4510;hb=2aa65a4cdb47df8014f28342d460fc6639bed885;hp=91dfae55e90823ce7fdc91aa6f919835edc6e58c;hpb=f4d52e3e4a3712050532786fca0aded5ff8b5a03;p=cavedroid.git diff --git a/core/src/ru/deadsoftware/cavedroid/game/mobs/Mob.java b/core/src/ru/deadsoftware/cavedroid/game/mobs/Mob.java index 91dfae5..4ad04e8 100644 --- a/core/src/ru/deadsoftware/cavedroid/game/mobs/Mob.java +++ b/core/src/ru/deadsoftware/cavedroid/game/mobs/Mob.java @@ -4,7 +4,7 @@ import com.badlogic.gdx.graphics.g2d.SpriteBatch; import com.badlogic.gdx.math.MathUtils; import com.badlogic.gdx.math.Rectangle; import com.badlogic.gdx.math.Vector2; -import ru.deadsoftware.cavedroid.game.GameWorld; +import ru.deadsoftware.cavedroid.game.world.GameWorld; import java.io.Serializable; @@ -13,6 +13,8 @@ import java.io.Serializable; */ public abstract class Mob extends Rectangle implements Serializable { + protected static int ANIMATION_SPEED = 360; + public enum Type { MOB, SAND, @@ -24,10 +26,10 @@ public abstract class Mob extends Rectangle implements Serializable { RIGHT } - protected Vector2 mMove; + protected Vector2 mVelocity; protected Type mType; - protected int mAnimDelta = 6; - protected int mAnim; + protected int mAnimDelta = ANIMATION_SPEED; + protected float mAnim; private Direction mDirection; private boolean mDead; @@ -35,15 +37,15 @@ public abstract class Mob extends Rectangle implements Serializable { private boolean mFlyMode; /** - * @param x in pixels - * @param y in pixels - * @param width in pixels - * @param height in pixels - * @param mDirection Direction in which mob is looking + * @param x in pixels + * @param y in pixels + * @param width in pixels + * @param height in pixels + * @param mDirection Direction in which mob is looking */ protected Mob(float x, float y, float width, float height, Direction mDirection, Type type) { super(x, y, width, height); - mMove = new Vector2(0, 0); + mVelocity = new Vector2(0, 0); mCanJump = false; mDead = false; this.mDirection = mDirection; @@ -120,7 +122,7 @@ public abstract class Mob extends Rectangle implements Serializable { return mDead; } - public final int getAnim() { + public final float getAnim() { return mAnim; } @@ -131,13 +133,13 @@ public abstract class Mob extends Rectangle implements Serializable { mDead = true; } - public final void move() { - x += mMove.x; - y += mMove.y; + public final void move(float delta) { + x += mVelocity.x * delta; + y += mVelocity.y * delta; } - public final Vector2 getMove() { - return mMove; + public final Vector2 getVelocity() { + return mVelocity; } public final boolean canJump() { @@ -169,9 +171,9 @@ public abstract class Mob extends Rectangle implements Serializable { } } - public abstract void draw(SpriteBatch spriteBatch, float x, float y); + public abstract void draw(SpriteBatch spriteBatch, float x, float y, float delta); - public abstract void ai(GameWorld gameWorld); + public abstract void ai(GameWorld gameWorld, float delta); public abstract void changeDir(); }