// Diese Klasse stellt die einzelnen Geister dar. public class Ghost extends Picture { // Die übergeordnete Klasse ist Picture private static final long serialVersionUID = -5352006665147359473L; public int xPos; public int yPos; public boolean up; public boolean down; public boolean left; public boolean right; //private float speed = 0.00000007f; private int HCost; public Ghost(int index) { super("Pinky"); // Aufrufen der übergeordneten Klasse // xPos = 150 + 40 * index; if (index == 0) { this.changeSauce("Blinky"); } else if (index == 2) { this.changeSauce("Inky"); } else if (index == 3) { this.changeSauce("Clyde"); } } public void setPos(char coordinate, int newPos) { if (coordinate == 'x') { xPos = newPos; } else if (coordinate == 'y') { yPos = newPos; } } /* public void setDirection(String dir) { direction = dir; } public String getDirection() { return direction; } */ public int getHCost(Player player, int mod_x, int mod_y) { HCost = (int) Math.sqrt(Math.pow((((xPos - 10 )/20) + mod_x) - (( player.getPos('x', 0) - 10)/20), 2) + Math.pow((((yPos - 10 )/20) + mod_y) - ((player.getPos('y', 0) - 10)/20), 2)); return HCost; } public int getPos(char coordinate, long dt) { // Hier kommt die zuvor erwähnte delta time ins Spiel if (coordinate == 'x') { // Auslesen der 'x' - Koordinate: if (left && dt != 0) { // xPos -= speed * dt; xPos -= 1; } else if (right && dt != 0) { // xPos += speed * dt; xPos += 1; } return (int) xPos; } else if (coordinate == 'y') { // Auslesen der 'y' - Koordinate: if (down && dt != 0) { // yPos += speed * dt; yPos += 1; } else if (up && dt != 0) { // yPos -= speed * dt; yPos -= 1; } return (int) yPos; //(int) } else { return -1; } } }