From fa21364a3fc6119dd7d391e8367b0b07ec6d2525 Mon Sep 17 00:00:00 2001 From: 04Mlg04 <74152989+04Mlg04@users.noreply.github.com> Date: Sun, 27 Jun 2021 15:29:43 +0200 Subject: [PATCH] Spider death animation+ tracking added --- Zoelda/src/main/entities/Spider.java | 30 +++++++++++++++++++++++++--- Zoelda/src/main/items/Item.java | 2 +- 2 files changed, 28 insertions(+), 4 deletions(-) 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 ""; } }