// TODO Insert code for assignment 5.2.b
private Set<Rectangle> getCollisionCandidates(final Rectangle rectangle) throws CollisionMapOutOfBoundsException {
        // TODO Insert code for assignment 5.2.b
        if(
                rectangle.getX() < this.gridRectangle.getX() ||
                rectangle.getX() + rectangle.getWidth() > this.gridRectangle.getX() + this.gridRectangle.getWidth() ||
                rectangle.getY() < this.gridRectangle.getY() ||
                rectangle.getY() + rectangle.getHeight() > this.gridRectangle.getY() + this.gridRectangle.getHeight()
        ){
            throw new CollisionMapOutOfBoundsException("a rectangle is out of the bounds of this rectangle");
        }
        Set<Rectangle> rectangleSet = new HashSet<>();
        int startX = (int)transformX(rectangle.getX());
        int startY = (int)transformY(rectangle.getY());
        int endX = (int)transformX(rectangle.getX() + rectangle.getWidth()) + 1;
        int endY = (int)transformY(rectangle.getY() + rectangle.getHeight()) + 1;
        for(int i = startX; i <= endX; i++){
            for(int j = startY; j<=endY; j++){
                for(Rectangle re :map[j][i]){
                    rectangleSet.add(re);
                }
            }
        }
        return rectangleSet;
    }
private Set<Rectangle> getCollisionCandidates(final Rectangle rectangle) throws CollisionMapOutOfBoundsException {
// TODO Insert code for assignment 5.2.b
if(
rectangle.getX() < this.gridRectangle.getX() ||
private Set<Rectangle> getCollisionCandidates(final Rectangle rectangle) throws CollisionMapOutOfBoundsException {
// TODO Insert code for assignment 5.2.b
if(
rectangle.getX() < this.gridRectangle.getX() ||
rectangle.getX() + rectangle.getWidth() > this.gridRectangle.getX() + this.gridRectangle.getWidth() ||
rectangle.getY() < this.gridRectangle.getY() ||
rectangle.getY() + rectangle.getHeight() > this.gridRectangle.getY() + this.gridRectangle.getHeight()
){
throw new CollisionMapOutOfBoundsException("a rectangle is out of the bounds of this rectangle");
}
Set<Rectangle> rectangleSet = new HashSet<>();
int startX = (int)transformX(rectangle.getX());
private Set<Rectangle> getCollisionCandidates(final Rectangle rectangle) throws CollisionMapOutOfBoundsException {
// TODO Insert code for assignment 5.2.b
if(
rectangle.getX() < this.gridRectangle.getX() ||
rectangle.getX() + rectangle.getWidth() > this.gridRectangle.getX() + this.gridRectangle.getWidth() ||
rectangle.getY() < this.gridRectangle.getY() ||
rectangle.getY() + rectangle.getHeight() > this.gridRectangle.getY() + this.gridRectangle.getHeight()
){
throw new CollisionMapOutOfBoundsException("a rectangle is out of the bounds of this rectangle");
}
Set<Rectangle> rectangleSet = new HashSet<>();
int startX = (int)transformX(rectangle.getX());
int startY = (int)transformY(rectangle.getY());
int endX = (int)transformX(rectangle.getX() + rectangle.getWidth()) + 1;
int endY = (int)transformY(rectangle.getY() + rectangle.getHeight()) + 1;
for(int i = startX; i <= endX; i++){
for(int j = startY; j<=endY; j++){
for(Rectangle re :map[j][i]){
rectangleSet.add(re);
}
}
}