DEADSOFTWARE

Some refactor and javadocs
[cavedroid.git] / core / src / ru / deadsoftware / cavedroid / game / mobs / Pig.java
index 5bc0426eaac7c86e28edce896cd5d69a3124a4fb..e36da71cdb37d855235287fe8c00a9ac6a4799d7 100644 (file)
@@ -9,13 +9,13 @@ public class Pig extends Mob {
 
     public Pig(float x, float y) {
         super(x, y, 25, 18, MathUtils.random(1));
-        mov = new Vector2(-1 + getDir() * 2, 0);
+        mov = new Vector2(looksLeft() ? -1 : 1, 0);
     }
 
     @Override
     public void changeDir() {
         switchDir();
-        mov.x = -1 + 2 * getDir();
+        mov.x = -1 + 2 * getDirection();
     }
 
     @Override
@@ -23,7 +23,7 @@ public class Pig extends Mob {
         if (MathUtils.randomBoolean(.0025f)) changeDir();
         else if (MathUtils.randomBoolean(.0025f)) {
             if (mov.x != 0f) mov.x = 0;
-            else mov.x = -1 + 2 * getDir();
+            else mov.x = -1 + 2 * getDirection();
         }
         if (mov.x != 0f) anim += animDelta;
         else anim = 0;
@@ -37,17 +37,17 @@ public class Pig extends Mob {
         Assets.pigSprite[0][1].setRotation(anim);
         Assets.pigSprite[1][1].setRotation(-anim);
         //back legs
-        Assets.pigSprite[1][1].setPosition(x - 4 + (9 - getDir() * 9), y + 6);
+        Assets.pigSprite[1][1].setPosition(x - 4 + (9 - getDirection() * 9), y + 6);
         Assets.pigSprite[1][1].draw(spriteBatch);
-        Assets.pigSprite[1][1].setPosition(x + 17 - (9 * getDir()), y + 6);
+        Assets.pigSprite[1][1].setPosition(x + 17 - (9 * getDirection()), y + 6);
         Assets.pigSprite[1][1].draw(spriteBatch);
         //front legs
-        Assets.pigSprite[0][1].setPosition(x - 4 + (9 - getDir() * 9), y + 6);
+        Assets.pigSprite[0][1].setPosition(x - 4 + (9 - getDirection() * 9), y + 6);
         Assets.pigSprite[0][1].draw(spriteBatch);
-        Assets.pigSprite[0][1].setPosition(x + 17 - (9 * getDir()), y + 6);
+        Assets.pigSprite[0][1].setPosition(x + 17 - (9 * getDirection()), y + 6);
         Assets.pigSprite[0][1].draw(spriteBatch);
         //head & body
-        spriteBatch.draw(Assets.pigSprite[getDir()][0], x, y);
+        spriteBatch.draw(Assets.pigSprite[getDirection()][0], x, y);
     }
 
     @Override