DEADSOFTWARE

Add player animation and fly mode
[cavedroid.git] / core / src / ru / deadsoftware / cavecraft / game / mobs / Human.java
index 318ea153be76b578418df085492bab1039a99659..97b1c18dc0b16f86bed4e7ba3998202691f3be48 100644 (file)
@@ -1,8 +1,10 @@
 package ru.deadsoftware.cavecraft.game.mobs;
 
+import com.badlogic.gdx.graphics.g2d.SpriteBatch;
 import com.badlogic.gdx.math.RandomXS128;
 import com.badlogic.gdx.math.Rectangle;
 import com.badlogic.gdx.math.Vector2;
+import ru.deadsoftware.cavecraft.Assets;
 import ru.deadsoftware.cavecraft.game.GameProc;
 
 public class Human extends Mob{
@@ -32,6 +34,23 @@ public class Human extends Mob{
         moveX.add(-2+4*dir, 0);
     }
 
+    @Override
+    public void draw(SpriteBatch spriteBatch, float x, float y) {
+        spriteBatch.draw(Assets.playerSkin[dir][0], x-2, y-2);
+        if (Assets.playerSkin[0][2].getRotation()>=60 || Assets.playerSkin[0][2].getRotation()<=-60)
+            Mob.ANIM_SPEED = -Mob.ANIM_SPEED;
+        Assets.playerSkin[1][2].setPosition(x-6,y);
+        Assets.playerSkin[1][2].draw(spriteBatch);
+        Assets.playerSkin[1][3].setPosition(x-6, y+10);
+        Assets.playerSkin[1][3].draw(spriteBatch);
+        Assets.playerSkin[0][3].setPosition(x-6, y+10);
+        Assets.playerSkin[0][3].draw(spriteBatch);
+        spriteBatch.draw(Assets.playerSkin[dir][1], x-2, y + 8);
+
+        Assets.playerSkin[0][2].setPosition(x-6, y);
+        Assets.playerSkin[0][2].draw(spriteBatch);
+    }
+
     public Rectangle getRect() {
         return new Rectangle(position.x, position.y, width, height);
     }