diff --git a/Zoelda/src/main/entities/Spider.java b/Zoelda/src/main/entities/Spider.java index 362ba39..c696fbc 100644 --- a/Zoelda/src/main/entities/Spider.java +++ b/Zoelda/src/main/entities/Spider.java @@ -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 = false; 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 diff --git a/Zoelda/src/main/items/Item.java b/Zoelda/src/main/items/Item.java index f7b665e..a6bc585 100644 --- a/Zoelda/src/main/items/Item.java +++ b/Zoelda/src/main/items/Item.java @@ -7,7 +7,7 @@ public class Item { * @return */ public String getIconPath(){ - TODO: + // TODO: return ""; } }