Added Scatter-strategy
This commit is contained in:
@ -18,19 +18,20 @@ import java.util.Arrays;
|
||||
@Slf4j
|
||||
public class PacMan {
|
||||
public static final int PACMAN_SIZE = 32;
|
||||
public static final int PACMAN_OFFSET = PACMAN_SIZE / 2;
|
||||
private static final int COLLISION_BOX_SIZE = 16;
|
||||
private static final int COLLISION_BOX_OFFSET = (PACMAN_SIZE - COLLISION_BOX_SIZE) / 2;
|
||||
private final Game game;
|
||||
private int aniTick = 0;
|
||||
private int aniIndex = 0;
|
||||
private static final int ANIMATION_UPDATE_FREQUENCY = 25;
|
||||
private static final int ANIMATION_UPDATE_FREQUENCY = 10;
|
||||
private int speed = 1;
|
||||
@Setter
|
||||
private boolean moving;
|
||||
private final BufferedImage[][] movmentImages = new BufferedImage[4][4];
|
||||
private Point position;
|
||||
private static final BufferedImage COLLISION_BOX = MiscUtil.createOutlinedBox(COLLISION_BOX_SIZE, COLLISION_BOX_SIZE, Color.yellow, 2);
|
||||
private CollisionChecker collisionChecker;
|
||||
private final CollisionChecker collisionChecker;
|
||||
@Setter
|
||||
@Getter
|
||||
private Direction direction = Direction.NONE;
|
||||
@ -65,17 +66,16 @@ public class PacMan {
|
||||
.toArray(BufferedImage[]::new);
|
||||
}
|
||||
|
||||
|
||||
public void draw(Graphics g) {
|
||||
g.drawImage(
|
||||
movmentImages[direction==Direction.NONE?0:direction.ordinal()][aniIndex],
|
||||
position.x - PACMAN_SIZE / 2,
|
||||
position.y - PACMAN_SIZE / 2,
|
||||
movmentImages[direction==Direction.NONE ? 0 : direction.ordinal()][aniIndex],
|
||||
position.x - PACMAN_OFFSET,
|
||||
position.y - PACMAN_OFFSET,
|
||||
PACMAN_SIZE,
|
||||
PACMAN_SIZE, null);
|
||||
g.drawImage(COLLISION_BOX, position.x - COLLISION_BOX_OFFSET, position.y - COLLISION_BOX_OFFSET, COLLISION_BOX_SIZE, COLLISION_BOX_SIZE, null);
|
||||
g.setColor(Color.BLUE);
|
||||
g.fillRect(position.x-1, position.y-1, 3, 3);
|
||||
//g.fillRect(position.x-1, position.y-1, 3, 3);
|
||||
}
|
||||
|
||||
public void update() {
|
||||
@ -98,7 +98,6 @@ public class PacMan {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private void updateAnimationTick() {
|
||||
if (moving) {
|
||||
aniTick++;
|
||||
|
||||
Reference in New Issue
Block a user