diff --git a/core/src/ru/deadsoftware/cavedroid/game/mobs/Mob.java b/core/src/ru/deadsoftware/cavedroid/game/mobs/Mob.java
index bcab5867bc4e8ee9186543eebd206e4733437b86..716c3df07f44dc8e45b06c048716fc721fedeb52 100644 (file)
package ru.deadsoftware.cavedroid.game.mobs;
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;
public static final int LEFT = 0;
public static final int RIGHT = 1;
- private float width, height;
+ private final float width;
+ private final float height;
private int dir;
- public boolean flyMode;
- public Vector2 pos;
- public Vector2 mov;
+ protected final Vector2 pos;
+ protected Vector2 mov;
private boolean dead;
+ private boolean canJump, flyMode;
protected int animDelta = 6;
- public boolean canJump;
- int anim;
+ protected int anim;
+
+ protected static int randomDir() {
+ return MathUtils.random(1);
+ }
/**
*
* @param dir integer representing a direction where 0 is left and 1 is right.
* You should use {@link #LEFT} and {@link #RIGHT} constants
*/
- public Mob(float x, float y, float width, float height, int dir) {
+ protected Mob(float x, float y, float width, float height, int dir) {
pos = new Vector2(x, y);
mov = new Vector2(0, 0);
this.width = width;
this.height = height;
canJump = false;
- flyMode = false;
dead = false;
this.dir = dir;
}
return dead;
}
+ public int getAnim() {
+ return anim;
+ }
+
/**
* Set's mob's dead variable to true and nothing else. It doesn't delete the mob.
*/
return new Rectangle(pos.x, pos.y, getWidth(), getHeight());
}
- public abstract void ai();
+ public Vector2 getPos() {
+ return pos;
+ }
- public abstract void changeDir();
+ public Vector2 getMov() {
+ return mov;
+ }
+
+ public float getX() {
+ return pos.x;
+ }
+
+ public float getY() {
+ return pos.y;
+ }
+
+ public boolean canJump() {
+ return canJump;
+ }
+
+ public void setCanJump(boolean canJump) {
+ this.canJump = canJump;
+ }
+
+ public boolean isFlyMode() {
+ return flyMode;
+ }
+
+ public void setFlyMode(boolean flyMode) {
+ this.flyMode = flyMode;
+ }
public abstract void draw(SpriteBatch spriteBatch, float x, float y);
+ public abstract void ai();
+
+ public abstract void changeDir();
+
/**
*
* @return 0 - if regular mob. <br>