X-Git-Url: https://deadsoftware.ru/gitweb?p=cavedroid.git;a=blobdiff_plain;f=core%2Fsrc%2Fru%2Fdeadsoftware%2Fcavecraft%2Fgame%2Fmobs%2FMob.java;h=241f01889b18df12d97c8e91f2037fe307a61736;hp=67df9f7198fac95681fef3b508f099f202c2e0f8;hb=cef4b5a9985bcbdfea6dc652147ecde0721d7fdc;hpb=d7f5950fc751cec8fa64005dd1886cac4081ee99 diff --git a/core/src/ru/deadsoftware/cavecraft/game/mobs/Mob.java b/core/src/ru/deadsoftware/cavecraft/game/mobs/Mob.java index 67df9f7..241f018 100644 --- a/core/src/ru/deadsoftware/cavecraft/game/mobs/Mob.java +++ b/core/src/ru/deadsoftware/cavecraft/game/mobs/Mob.java @@ -8,12 +8,60 @@ import java.io.Serializable; public abstract class Mob implements Serializable { - public int ANIM_SPEED = 6; + protected int anim, animSpeed = 6; + private float width, height; + private int dir; + public Vector2 pos; - public Vector2 move; - public int width, height, dir, anim; + public Vector2 mov; + private boolean dead; + public boolean canJump; - public boolean dead; + + protected Mob(float x, float y, float width, float height, int dir) { + pos = new Vector2(x, y); + this.width = width; + this.height = height; + canJump = false; + dead = false; + this.dir = dir; + } + + public int getMapX() { + return (int) (pos.x + (getWidth() / 2)) / 16; + } + + public int getMapY() { + return (int) (pos.y + (getHeight() / 2)) / 16; + } + + public float getWidth() { + return width; + } + + public float getHeight() { + return height; + } + + public int getDir() { + return dir; + } + + protected void switchDir() { + dir = -dir + 1; + } + + public boolean isDead() { + return dead; + } + + public void kill() { + dead = true; + } + + public Rectangle getRect() { + return new Rectangle(pos.x, pos.y, getWidth(), getHeight()); + } public abstract void ai(); @@ -21,7 +69,5 @@ public abstract class Mob implements Serializable { public abstract void draw(SpriteBatch spriteBatch, float x, float y); - public abstract Rectangle getRect(); - public abstract int getType(); //0 - mob, 10 - sand, 11 - gravel }