Combat done
This commit is contained in:
Binary file not shown.
@@ -1,6 +1,5 @@
|
|||||||
package main;
|
package main;
|
||||||
|
|
||||||
import java.awt.geom.AffineTransform;
|
|
||||||
import java.awt.image.BufferedImage;
|
import java.awt.image.BufferedImage;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
|
||||||
|
|||||||
@@ -70,7 +70,7 @@ public abstract class LivingEntity extends Entity {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected float getHealthPoints() {
|
public float getHP() {
|
||||||
return hp;
|
return hp;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -2,7 +2,6 @@ package main.entities;
|
|||||||
|
|
||||||
import main.Main;
|
import main.Main;
|
||||||
import main.SheetLoader;
|
import main.SheetLoader;
|
||||||
import main.entities.player.Player;
|
|
||||||
|
|
||||||
public class Spider extends LivingEntity {
|
public class Spider extends LivingEntity {
|
||||||
|
|
||||||
@@ -29,7 +28,7 @@ public class Spider extends LivingEntity {
|
|||||||
}
|
}
|
||||||
|
|
||||||
protected void update() {
|
protected void update() {
|
||||||
Player player = Main.instance.getWorld().getCurrentMap().getPlayer();
|
// Player player = Main.instance.getWorld().getCurrentMap().getPlayer();
|
||||||
|
|
||||||
this.checkTileCollisions(Main.instance.getWorld().getCurrentMap());
|
this.checkTileCollisions(Main.instance.getWorld().getCurrentMap());
|
||||||
super.update();
|
super.update();
|
||||||
|
|||||||
@@ -11,8 +11,10 @@ import main.entities.LivingEntity;
|
|||||||
|
|
||||||
public class Player extends 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 boolean onlyAttackOnceTrigger;
|
||||||
|
private float range = 1.2f; // die reichweite der Attacke
|
||||||
|
|
||||||
public Player() {
|
public Player() {
|
||||||
super(loader.getFigur(0), "idle");
|
super(loader.getFigur(0), "idle");
|
||||||
@@ -46,8 +48,8 @@ public class Player extends LivingEntity {
|
|||||||
if (!((actionFigur.aktuellesVerhalten().equals("strike"))
|
if (!((actionFigur.aktuellesVerhalten().equals("strike"))
|
||||||
&& actionFigur.aktuelleFigur().aktuellesBild() < actionFigur.aktuelleFigur().animation().length - 1)) {
|
&& actionFigur.aktuelleFigur().aktuellesBild() < actionFigur.aktuelleFigur().animation().length - 1)) {
|
||||||
// Bei diser soll man sich nicht bewegen können aber weiter rutschen
|
// Bei diser soll man sich nicht bewegen können aber weiter rutschen
|
||||||
if (!((actionFigur.aktuellesVerhalten().equals("swipe"))
|
if (!((actionFigur.aktuellesVerhalten().equals("swipe")) && actionFigur.aktuelleFigur()
|
||||||
&& actionFigur.aktuelleFigur().aktuellesBild() < actionFigur.aktuelleFigur().animation().length - 1)) {
|
.aktuellesBild() < actionFigur.aktuelleFigur().animation().length - 1)) {
|
||||||
|
|
||||||
// wasd movement
|
// wasd movement
|
||||||
if (Main.instance.tasteGedrueckt(Taste.A)) {
|
if (Main.instance.tasteGedrueckt(Taste.A)) {
|
||||||
@@ -95,12 +97,14 @@ public class Player extends LivingEntity {
|
|||||||
// auf Kollisionen prüfen
|
// auf Kollisionen prüfen
|
||||||
checkTileCollisions(Main.instance.getWorld().getCurrentMap());
|
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;
|
onlyAttackOnceTrigger = true;
|
||||||
ArrayList<Entity> entities = Main.instance.getWorld().getCurrentMap().getEntities();
|
ArrayList<Entity> entities = Main.instance.getWorld().getCurrentMap().getEntities();
|
||||||
for (Entity e : entities) {
|
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;
|
LivingEntity le = (LivingEntity) e;
|
||||||
|
if (le.getHP() > 0) {
|
||||||
Vektor toE = vectorToEntity(le);
|
Vektor toE = vectorToEntity(le);
|
||||||
toE = toE.normiert();
|
toE = toE.normiert();
|
||||||
if ((toE.x > 0 && !side) || (toE.x <= 0 && side)) {
|
if ((toE.x > 0 && !side) || (toE.x <= 0 && side)) {
|
||||||
@@ -112,6 +116,7 @@ public class Player extends LivingEntity {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getDeathAnimationName() {
|
public String getDeathAnimationName() {
|
||||||
|
|||||||
Reference in New Issue
Block a user