code format
This commit is contained in:
@@ -1,5 +1,6 @@
|
|||||||
package main.entities;
|
package main.entities;
|
||||||
|
|
||||||
|
import ea.Farbe;
|
||||||
import ea.Taste;
|
import ea.Taste;
|
||||||
import main.Main;
|
import main.Main;
|
||||||
import main.SheetLoader;
|
import main.SheetLoader;
|
||||||
|
|||||||
@@ -10,18 +10,18 @@ import main.Tile;
|
|||||||
public class Snake extends LivingEntity {
|
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 });
|
private static SheetLoader loader = new SheetLoader("/res/images/snake_spritesheet_calciumtrice.png", 32, 32, new int[] { 10, 10, 10, 10, 10 });
|
||||||
|
|
||||||
public Snake() {
|
public Snake() {
|
||||||
super(loader.getFigur(0), "idle");
|
super(loader.getFigur(0), "idle");
|
||||||
|
|
||||||
posX = 9f;
|
posX = 9f;
|
||||||
posY = 9f;
|
posY = 9f;
|
||||||
accelleration = 0.008f;
|
accelleration = 0.006f;
|
||||||
spriteOffsetY = -0.6f;
|
spriteOffsetY = -0.6f;
|
||||||
width = 0.65f;
|
width = 0.65f;
|
||||||
height = 0.8f;
|
height = 0.8f;
|
||||||
mirrored = true;
|
mirrored = true;
|
||||||
|
|
||||||
actionFigur.neuerZustand(loader.getFigur(1), "lost_sight");
|
actionFigur.neuerZustand(loader.getFigur(1), "lost_sight");
|
||||||
actionFigur.neuerZustand(loader.getFigur(2), "walk");
|
actionFigur.neuerZustand(loader.getFigur(2), "walk");
|
||||||
actionFigur.neuerZustand(loader.getFigur(3), "attack");
|
actionFigur.neuerZustand(loader.getFigur(3), "attack");
|
||||||
@@ -49,7 +49,8 @@ public class Snake extends LivingEntity {
|
|||||||
if (actionFigur.aktuellesVerhalten().equals("walk")) {
|
if (actionFigur.aktuellesVerhalten().equals("walk")) {
|
||||||
zustandSetzen("lost_sight");
|
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);
|
actionFigur.aktuelleFigur().animationsBildSetzen(0);
|
||||||
zustandSetzen("idle");
|
zustandSetzen("idle");
|
||||||
}
|
}
|
||||||
@@ -57,7 +58,7 @@ public class Snake extends LivingEntity {
|
|||||||
this.checkTileCollisions(Main.instance.getWorld().getCurrentMap());
|
this.checkTileCollisions(Main.instance.getWorld().getCurrentMap());
|
||||||
super.update();
|
super.update();
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean lineOfSightClear(Entity e) {
|
private boolean lineOfSightClear(Entity e) {
|
||||||
Vektor direct = new Vektor(e.posX - posX, e.posY - posY).normiert();
|
Vektor direct = new Vektor(e.posX - posX, e.posY - posY).normiert();
|
||||||
direct = direct.teilen(4f);
|
direct = direct.teilen(4f);
|
||||||
@@ -69,7 +70,7 @@ public class Snake extends LivingEntity {
|
|||||||
loc = loc.summe(direct);
|
loc = loc.summe(direct);
|
||||||
lastDist = dist;
|
lastDist = dist;
|
||||||
dist = Math.abs(e.posX - loc.x) + Math.abs(e.posY - loc.y);
|
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()) {
|
if (t != null && t.isCollidable()) {
|
||||||
clear = false;
|
clear = false;
|
||||||
break;
|
break;
|
||||||
|
|||||||
Reference in New Issue
Block a user