Compare commits

...

2 Commits

Author SHA1 Message Date
Asecave
758c944ec6 Merge branch 'master' of https://git.ngb.schule/Tim/Zoelda 2021-06-23 23:11:29 +02:00
Asecave
38e9266696 code format 2021-06-23 23:11:17 +02:00
2 changed files with 9 additions and 7 deletions

View File

@@ -1,5 +1,6 @@
package main.entities;
import ea.Farbe;
import ea.Taste;
import main.Main;
import main.SheetLoader;

View File

@@ -10,18 +10,18 @@ import main.Tile;
public class Snake extends LivingEntity {
private static SheetLoader loader = new SheetLoader("/res/images/snake_spritesheet_calciumtrice.png", 32, 32, new int[] { 10, 10, 10, 10, 10 });
public Snake() {
super(loader.getFigur(0), "idle");
posX = 9f;
posY = 9f;
accelleration = 0.008f;
accelleration = 0.006f;
spriteOffsetY = -0.6f;
width = 0.65f;
height = 0.8f;
mirrored = true;
actionFigur.neuerZustand(loader.getFigur(1), "lost_sight");
actionFigur.neuerZustand(loader.getFigur(2), "walk");
actionFigur.neuerZustand(loader.getFigur(3), "attack");
@@ -49,7 +49,8 @@ public class Snake extends LivingEntity {
if (actionFigur.aktuellesVerhalten().equals("walk")) {
zustandSetzen("lost_sight");
}
if (actionFigur.aktuellesVerhalten().equals("lost_sight") && actionFigur.aktuelleFigur().aktuellesBild() == actionFigur.aktuelleFigur().animation().length - 1) {
if (actionFigur.aktuellesVerhalten().equals("lost_sight")
&& actionFigur.aktuelleFigur().aktuellesBild() == actionFigur.aktuelleFigur().animation().length - 1) {
actionFigur.aktuelleFigur().animationsBildSetzen(0);
zustandSetzen("idle");
}
@@ -57,7 +58,7 @@ public class Snake extends LivingEntity {
this.checkTileCollisions(Main.instance.getWorld().getCurrentMap());
super.update();
}
private boolean lineOfSightClear(Entity e) {
Vektor direct = new Vektor(e.posX - posX, e.posY - posY).normiert();
direct = direct.teilen(4f);
@@ -69,7 +70,7 @@ public class Snake extends LivingEntity {
loc = loc.summe(direct);
lastDist = dist;
dist = Math.abs(e.posX - loc.x) + Math.abs(e.posY - loc.y);
Tile t = Main.instance.getWorld().getCurrentMap().getTile((int) loc.x, (int) loc.y);
Tile t = Main.instance.getWorld().getCurrentMap().getTile((int) loc.x, (int) loc.y);
if (t != null && t.isCollidable()) {
clear = false;
break;