Refactoring to use pixel-perfect Collision check
This commit is contained in:
@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user