241f01889b18df12d97c8e91f2037fe307a61736
1 package ru
.deadsoftware
.cavecraft
.game
.mobs
;
3 import com
.badlogic
.gdx
.graphics
.g2d
.SpriteBatch
;
4 import com
.badlogic
.gdx
.math
.Rectangle
;
5 import com
.badlogic
.gdx
.math
.Vector2
;
7 import java
.io
.Serializable
;
9 public abstract class Mob
implements Serializable
{
11 protected int anim
, animSpeed
= 6;
12 private float width
, height
;
19 public boolean canJump
;
21 protected Mob(float x
, float y
, float width
, float height
, int dir
) {
22 pos
= new Vector2(x
, y
);
30 public int getMapX() {
31 return (int) (pos
.x
+ (getWidth() / 2)) / 16;
34 public int getMapY() {
35 return (int) (pos
.y
+ (getHeight() / 2)) / 16;
38 public float getWidth() {
42 public float getHeight() {
50 protected void switchDir() {
54 public boolean isDead() {
62 public Rectangle
getRect() {
63 return new Rectangle(pos
.x
, pos
.y
, getWidth(), getHeight());
66 public abstract void ai();
68 public abstract void changeDir();
70 public abstract void draw(SpriteBatch spriteBatch
, float x
, float y
);
72 public abstract int getType(); //0 - mob, 10 - sand, 11 - gravel