Minor fixes
This commit is contained in:
@ -2,6 +2,7 @@ package se.urmo.game.entities;
|
||||
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import se.urmo.game.collision.CollisionChecker;
|
||||
import se.urmo.game.util.Direction;
|
||||
import se.urmo.game.main.Game;
|
||||
@ -14,6 +15,7 @@ import java.awt.image.BufferedImage;
|
||||
import java.util.Arrays;
|
||||
|
||||
|
||||
@Slf4j
|
||||
public class PacMan {
|
||||
public static final int PACMAN_SIZE = 32;
|
||||
private static final int COLLISION_BOX_SIZE = 16;
|
||||
@ -36,7 +38,7 @@ public class PacMan {
|
||||
public PacMan(Game game, CollisionChecker collisionChecker) {
|
||||
this.game = game;
|
||||
this.collisionChecker = collisionChecker;
|
||||
position = new Point(26 * 16 + 8 + GameMap.OFFSET_X, 13 * 16 + GameMap.OFFSET_Y);
|
||||
position = new Point(26 * GameMap.MAP_TILESIZE + 8 + GameMap.OFFSET_X, 13 * GameMap.MAP_TILESIZE + GameMap.OFFSET_Y);
|
||||
loadAnimation();
|
||||
}
|
||||
|
||||
@ -46,7 +48,7 @@ public class PacMan {
|
||||
BufferedImage img = LoadSave.GetSpriteAtlas("sprites/PacManAssets-PacMan.png");
|
||||
for (int row = 0; row < 3; row++) {
|
||||
for (int col = 0; col < 4; col++) {
|
||||
image[row][col] = img.getSubimage(32 * col, 32 * row, PACMAN_SIZE, PACMAN_SIZE);
|
||||
image[row][col] = img.getSubimage(PACMAN_SIZE * col, PACMAN_SIZE * row, PACMAN_SIZE, PACMAN_SIZE);
|
||||
}
|
||||
}
|
||||
movmentImages[Direction.RIGHT.ordinal()] = image[0];
|
||||
@ -83,7 +85,7 @@ public class PacMan {
|
||||
case DOWN -> new Point(position.x, position.y + speed);
|
||||
default -> throw new IllegalStateException("Unexpected value: " + direction);
|
||||
};
|
||||
System.out.println("At: " + position+ ",trying to move " + direction.name() + " to " + newPosition);
|
||||
log.debug("At: {},trying to move {} to {}", position, direction.name(), newPosition);
|
||||
Point destination = collisionChecker.getValidDestination(direction, newPosition, COLLISION_BOX_SIZE, COLLISION_BOX_SIZE);
|
||||
|
||||
if(destination != null) {
|
||||
@ -99,7 +101,7 @@ public class PacMan {
|
||||
if (aniTick >= ANIMATION_UPDATE_FREQUENCY) {
|
||||
aniTick = 0;
|
||||
aniIndex++;
|
||||
if (aniIndex >= 3) {
|
||||
if (aniIndex >= 4) {
|
||||
aniIndex = 0;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user