This commit is contained in:
Asecave
2021-06-27 18:27:14 +02:00
2 changed files with 28 additions and 4 deletions

View File

@@ -1,7 +1,9 @@
package main.entities;
import ea.Vektor;
import main.Main;
import main.SheetLoader;
import main.entities.player.Player;
public class Spider extends LivingEntity {
@@ -16,6 +18,7 @@ public class Spider extends LivingEntity {
spriteScale = 0.8f;
posX = 4f;
posY = 4f;
mirrored = true;
actionFigur.neuerZustand(loader.getFigur(1), "lost_sight");
actionFigur.neuerZustand(loader.getFigur(2), "walk");
@@ -28,11 +31,32 @@ public class Spider extends LivingEntity {
}
protected void update() {
// Player player = Main.instance.getWorld().getCurrentMap().getPlayer();
Player player = Main.instance.getWorld().getCurrentMap().getPlayer();
if (!actionFigur.aktuellesVerhalten().equals(getDamageAnimationName())) {
if (lineOfSightClear(player)) {
if (dist(player) < 1f) {
zustandSetzen("attack");
} else {
Vektor toPlayer = vectorToEntity(player).normiert();
velX += toPlayer.x * accelleration;
velY += toPlayer.y * accelleration;
zustandSetzen("walk");
}
} else {
if (!actionFigur.aktuellesVerhalten().equals("idle")) {
zustandSetzen("lost_sight");
if (actionFigur.aktuelleFigur().aktuellesBild() == actionFigur.aktuelleFigur().animation().length - 1) {
zustandSetzen("idle");
}
}
}
} else {
if (actionFigur.aktuelleFigur().aktuellesBild() == actionFigur.aktuelleFigur().animation().length - 1) {
zustandSetzen("walk");
}
}
this.checkTileCollisions(Main.instance.getWorld().getCurrentMap());
super.update();
}
@Override

View File

@@ -7,7 +7,7 @@ public class Item {
* @return
*/
public String getIconPath(){
TODO:
// TODO:
return "";
}
}