Reworked pacman position. Now centers in the middle of the sprite
This commit is contained in:
@ -38,7 +38,9 @@ public class PacMan {
|
||||
public PacMan(Game game, CollisionChecker collisionChecker) {
|
||||
this.game = game;
|
||||
this.collisionChecker = collisionChecker;
|
||||
position = new Point(26 * GameMap.MAP_TILESIZE + 8 + GameMap.OFFSET_X, 13 * GameMap.MAP_TILESIZE + GameMap.OFFSET_Y);
|
||||
position = new Point(
|
||||
26 * GameMap.MAP_TILESIZE + GameMap.OFFSET_X,
|
||||
13 * GameMap.MAP_TILESIZE + GameMap.OFFSET_Y + (GameMap.MAP_TILESIZE / 2));
|
||||
loadAnimation();
|
||||
}
|
||||
|
||||
@ -67,11 +69,13 @@ public class PacMan {
|
||||
public void draw(Graphics g) {
|
||||
g.drawImage(
|
||||
movmentImages[direction==Direction.NONE?0:direction.ordinal()][aniIndex],
|
||||
position.x - COLLISION_BOX_OFFSET,
|
||||
position.y - COLLISION_BOX_OFFSET,
|
||||
position.x - PACMAN_SIZE / 2,
|
||||
position.y - PACMAN_SIZE / 2,
|
||||
PACMAN_SIZE,
|
||||
PACMAN_SIZE, null);
|
||||
g.drawImage(COLLISION_BOX, position.x, position.y, COLLISION_BOX_SIZE, COLLISION_BOX_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);
|
||||
}
|
||||
|
||||
public void update() {
|
||||
|
||||
Reference in New Issue
Block a user