|
@@ -32,7 +32,9 @@ public class HumanController extends Controller
|
|
|
};
|
|
|
|
|
|
private int walkFrame = 0;
|
|
|
+ private int idleCounter = 0;
|
|
|
private int idleFrame = 0;
|
|
|
+ private int deathFrame = 0;
|
|
|
|
|
|
public HumanController(Entity ent)
|
|
|
{
|
|
@@ -41,21 +43,42 @@ public class HumanController extends Controller
|
|
|
|
|
|
private void nextWalkFrame()
|
|
|
{
|
|
|
- walkFrame = (walkFrame + 1) % 9;
|
|
|
+ deathFrame = 0;
|
|
|
idleFrame = 0;
|
|
|
+ walkFrame = (walkFrame + 1) % 9;
|
|
|
}
|
|
|
|
|
|
private void nextIdleFrame()
|
|
|
{
|
|
|
+ deathFrame = 0;
|
|
|
walkFrame = 0;
|
|
|
- idleFrame = (idleFrame + 1) % 14;
|
|
|
+ idleCounter++;
|
|
|
+ if(idleCounter >= 3)
|
|
|
+ {
|
|
|
+ idleCounter = 0;
|
|
|
+ idleFrame = (idleFrame + 1) % 14;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ private void nextDeathFrame()
|
|
|
+ {
|
|
|
+ walkFrame = 0;
|
|
|
+ idleFrame = 0;
|
|
|
+ deathFrame++;
|
|
|
}
|
|
|
|
|
|
private void resetFrames()
|
|
|
{
|
|
|
+ deathFrame = 0;
|
|
|
walkFrame = 0;
|
|
|
idleFrame = 0;
|
|
|
}
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public boolean isAnimated()
|
|
|
+ {
|
|
|
+ return deathFrame < 17;
|
|
|
+ }
|
|
|
|
|
|
@Override
|
|
|
public void tick()
|
|
@@ -65,6 +88,28 @@ public class HumanController extends Controller
|
|
|
tp.draw = false;
|
|
|
}
|
|
|
|
|
|
+ if(ent.getHealth().isDead())
|
|
|
+ {
|
|
|
+ body.draw = true;
|
|
|
+ body.ox = ent.getFace() == Face.RIGHT ? 0.0f: -32.0f;
|
|
|
+ body.oy = 0.0f;
|
|
|
+ body.h = 64.0f;
|
|
|
+ body.w = 64.0f;
|
|
|
+
|
|
|
+ body.tx = (deathFrame * 64.0f) / SIZE;
|
|
|
+ if(deathFrame < 16)
|
|
|
+ {
|
|
|
+ body.ty = 192.0f / SIZE;
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ body.ty = 256.0f / SIZE;
|
|
|
+ }
|
|
|
+
|
|
|
+ nextDeathFrame();
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
float speed = ent.getMovement().getVelocityX();
|
|
|
if(Keys.RUN.isDown())
|
|
|
{
|
|
@@ -118,6 +163,19 @@ public class HumanController extends Controller
|
|
|
@Override
|
|
|
public void renderTick(float lag)
|
|
|
{
|
|
|
+ if(ent.getHealth().wasHurt())
|
|
|
+ {
|
|
|
+ Shader.setColorEnabled(true);
|
|
|
+ Shader.setMixColorEnabled(true);
|
|
|
+ Shader.setMixColor(1.0f, 0.0f, 0.0f, 1.0f);
|
|
|
+ }
|
|
|
+ if(ent.getHealth().wasHealed())
|
|
|
+ {
|
|
|
+ Shader.setColorEnabled(true);
|
|
|
+ Shader.setMixColorEnabled(true);
|
|
|
+ Shader.setMixColor(0.0f, 1.0f, 0.0f, 1.0f);
|
|
|
+ }
|
|
|
+
|
|
|
HERO.bind();
|
|
|
float x = Utils.interpolate(ent.getLastX(), ent.getX(), lag);
|
|
|
float y = Utils.interpolate(ent.getLastY(), ent.getY(), lag);
|
|
@@ -144,5 +202,11 @@ public class HumanController extends Controller
|
|
|
tp.tx + (tp.w / SIZE), tp.ty + (tp.h / SIZE));
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+ if(ent.getHealth().wasHurt() || ent.getHealth().wasHealed())
|
|
|
+ {
|
|
|
+ Shader.setColorEnabled(false);
|
|
|
+ Shader.setMixColorEnabled(false);
|
|
|
+ }
|
|
|
}
|
|
|
}
|