diff --git a/Zoelda/lib/Engine.Alpha.jar b/Zoelda/lib/Engine.Alpha.jar index 41e6a31..efbc5d0 100644 Binary files a/Zoelda/lib/Engine.Alpha.jar and b/Zoelda/lib/Engine.Alpha.jar differ diff --git a/Zoelda/src/main/HUD.java b/Zoelda/src/main/HUD.java index 0f51778..19bba77 100644 --- a/Zoelda/src/main/HUD.java +++ b/Zoelda/src/main/HUD.java @@ -1,6 +1,5 @@ package main; -import java.awt.geom.AffineTransform; import java.awt.image.BufferedImage; import java.io.IOException; diff --git a/Zoelda/src/main/entities/LivingEntity.java b/Zoelda/src/main/entities/LivingEntity.java index c370dfb..53b150b 100644 --- a/Zoelda/src/main/entities/LivingEntity.java +++ b/Zoelda/src/main/entities/LivingEntity.java @@ -70,7 +70,7 @@ public abstract class LivingEntity extends Entity { } } - protected float getHealthPoints() { + public float getHP() { return hp; } diff --git a/Zoelda/src/main/entities/Spider.java b/Zoelda/src/main/entities/Spider.java index b817a26..362ba39 100644 --- a/Zoelda/src/main/entities/Spider.java +++ b/Zoelda/src/main/entities/Spider.java @@ -2,7 +2,6 @@ package main.entities; import main.Main; import main.SheetLoader; -import main.entities.player.Player; public class Spider extends LivingEntity { @@ -29,7 +28,7 @@ public class Spider extends LivingEntity { } protected void update() { - Player player = Main.instance.getWorld().getCurrentMap().getPlayer(); +// Player player = Main.instance.getWorld().getCurrentMap().getPlayer(); this.checkTileCollisions(Main.instance.getWorld().getCurrentMap()); super.update(); diff --git a/Zoelda/src/main/entities/player/Player.java b/Zoelda/src/main/entities/player/Player.java index d970723..1150884 100644 --- a/Zoelda/src/main/entities/player/Player.java +++ b/Zoelda/src/main/entities/player/Player.java @@ -11,8 +11,10 @@ import main.entities.LivingEntity; public class Player extends LivingEntity { - private static SheetLoader loader = new SheetLoader("/res/images/player_sprite_sheet.png", 64, 32, new int[] { 5, 8, 7, 6, 2, 5, 4, 7 }); + private static SheetLoader loader = new SheetLoader("/res/images/player_sprite_sheet.png", 64, 32, + new int[] { 5, 8, 7, 6, 2, 5, 4, 7 }); private boolean onlyAttackOnceTrigger; + private float range = 1.2f; // die reichweite der Attacke public Player() { super(loader.getFigur(0), "idle"); @@ -46,8 +48,8 @@ public class Player extends LivingEntity { if (!((actionFigur.aktuellesVerhalten().equals("strike")) && actionFigur.aktuelleFigur().aktuellesBild() < actionFigur.aktuelleFigur().animation().length - 1)) { // Bei diser soll man sich nicht bewegen können aber weiter rutschen - if (!((actionFigur.aktuellesVerhalten().equals("swipe")) - && actionFigur.aktuelleFigur().aktuellesBild() < actionFigur.aktuelleFigur().animation().length - 1)) { + if (!((actionFigur.aktuellesVerhalten().equals("swipe")) && actionFigur.aktuelleFigur() + .aktuellesBild() < actionFigur.aktuelleFigur().animation().length - 1)) { // wasd movement if (Main.instance.tasteGedrueckt(Taste.A)) { @@ -95,18 +97,21 @@ public class Player extends LivingEntity { // auf Kollisionen prüfen checkTileCollisions(Main.instance.getWorld().getCurrentMap()); - if (!onlyAttackOnceTrigger && actionFigur.aktuellesVerhalten().equals("swipe") && actionFigur.aktuelleFigur().aktuellesBild() == 1) { + if (!onlyAttackOnceTrigger && actionFigur.aktuellesVerhalten().equals("swipe") + && actionFigur.aktuelleFigur().aktuellesBild() == 1) { onlyAttackOnceTrigger = true; ArrayList entities = Main.instance.getWorld().getCurrentMap().getEntities(); for (Entity e : entities) { - if (e instanceof LivingEntity && e != this && e.dist(this) <= 1f) { + if (e instanceof LivingEntity && e != this && e.dist(this) <= range) { LivingEntity le = (LivingEntity) e; - Vektor toE = vectorToEntity(le); - toE = toE.normiert(); - if ((toE.x > 0 && !side) || (toE.x <= 0 && side)) { - le.setVelX(le.getVelX() + toE.x * 0.1f); - le.setVelY(le.getVelY() + toE.y * 0.1f); - le.takeDamage(0.1f, this); + if (le.getHP() > 0) { + Vektor toE = vectorToEntity(le); + toE = toE.normiert(); + if ((toE.x > 0 && !side) || (toE.x <= 0 && side)) { + le.setVelX(le.getVelX() + toE.x * 0.1f); + le.setVelY(le.getVelY() + toE.y * 0.1f); + le.takeDamage(0.1f, this); + } } } }