|
|
|
|
@@ -10,18 +10,18 @@ import main.Tile;
|
|
|
|
|
public class Snake extends LivingEntity {
|
|
|
|
|
|
|
|
|
|
private static SheetLoader loader = new SheetLoader("/res/images/snake_spritesheet_calciumtrice.png", 32, 32, new int[] { 10, 10, 10, 10, 10 });
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public Snake() {
|
|
|
|
|
super(loader.getFigur(0), "idle");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
posX = 9f;
|
|
|
|
|
posY = 9f;
|
|
|
|
|
accelleration = 0.008f;
|
|
|
|
|
accelleration = 0.006f;
|
|
|
|
|
spriteOffsetY = -0.6f;
|
|
|
|
|
width = 0.65f;
|
|
|
|
|
height = 0.8f;
|
|
|
|
|
mirrored = true;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
actionFigur.neuerZustand(loader.getFigur(1), "lost_sight");
|
|
|
|
|
actionFigur.neuerZustand(loader.getFigur(2), "walk");
|
|
|
|
|
actionFigur.neuerZustand(loader.getFigur(3), "attack");
|
|
|
|
|
@@ -49,7 +49,8 @@ public class Snake extends LivingEntity {
|
|
|
|
|
if (actionFigur.aktuellesVerhalten().equals("walk")) {
|
|
|
|
|
zustandSetzen("lost_sight");
|
|
|
|
|
}
|
|
|
|
|
if (actionFigur.aktuellesVerhalten().equals("lost_sight") && actionFigur.aktuelleFigur().aktuellesBild() == actionFigur.aktuelleFigur().animation().length - 1) {
|
|
|
|
|
if (actionFigur.aktuellesVerhalten().equals("lost_sight")
|
|
|
|
|
&& actionFigur.aktuelleFigur().aktuellesBild() == actionFigur.aktuelleFigur().animation().length - 1) {
|
|
|
|
|
actionFigur.aktuelleFigur().animationsBildSetzen(0);
|
|
|
|
|
zustandSetzen("idle");
|
|
|
|
|
}
|
|
|
|
|
@@ -57,7 +58,7 @@ public class Snake extends LivingEntity {
|
|
|
|
|
this.checkTileCollisions(Main.instance.getWorld().getCurrentMap());
|
|
|
|
|
super.update();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private boolean lineOfSightClear(Entity e) {
|
|
|
|
|
Vektor direct = new Vektor(e.posX - posX, e.posY - posY).normiert();
|
|
|
|
|
direct = direct.teilen(4f);
|
|
|
|
|
@@ -69,7 +70,7 @@ public class Snake extends LivingEntity {
|
|
|
|
|
loc = loc.summe(direct);
|
|
|
|
|
lastDist = dist;
|
|
|
|
|
dist = Math.abs(e.posX - loc.x) + Math.abs(e.posY - loc.y);
|
|
|
|
|
Tile t = Main.instance.getWorld().getCurrentMap().getTile((int) loc.x, (int) loc.y);
|
|
|
|
|
Tile t = Main.instance.getWorld().getCurrentMap().getTile((int) loc.x, (int) loc.y);
|
|
|
|
|
if (t != null && t.isCollidable()) {
|
|
|
|
|
clear = false;
|
|
|
|
|
break;
|
|
|
|
|
|