Skip to main content
1 of 3
user avatar
user avatar

Draw Rectangle To All Dimensions of Image

I have some rudimentary collision code:

public class Collision {

static boolean isColliding = false;
static Rectangle player;
static Rectangle female;

public static void collision(){
    Rectangle player = Game.Playerbounds();
    Rectangle female = Game.Femalebounds();
    
    if(player.intersects(female)){
        isColliding = true;
        }else{
            isColliding = false;
        }
    }
}

And this is the rectangle code:

public static Rectangle Playerbounds() {
    return(new Rectangle(posX, posY, 25, 25));
}

public static Rectangle Femalebounds() {
    return(new Rectangle(femaleX, femaleY, 25, 25));
}

The code works partially. Only the right and top side of the images collide. How do I correct the rectangle so it will draw on all sides? Thanks for any suggestions!

user20439