Refactoring to use pixel-perfect Collision check

This commit is contained in:
Urban Modig
2025-08-15 20:45:29 +02:00
parent fe2eb8cb48
commit 7bcc46122c
4 changed files with 15 additions and 13 deletions

View File

@ -79,12 +79,11 @@ 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);
Point destination = collisionChecker.getValidDestination(direction, newPosition, COLLISION_BOX_SIZE, COLLISION_BOX_SIZE);
if(destination != null) {
position = destination;
System.out.println("Position: + " + position);
}
}