Hi. I’ve been stuck at a dead end for a bit and it’s slowing down my progress at a halt. You see, I have a class called Pet.cs
And in the main class Game1.cs, I have a list of pet classes called Pets.
I added three pets. In Pet.cs, there’s a rectangle called petbounds, meant to be a hitbox so each Pet.cs will have it. They all exist and have the right size and position, I’ve confirmed this to be true. However, I am seeking a way to check if a pet runs into another pet.
I can’t just write in Game1.cs:
for (int i = 0; i < Pets.Count; i++)
{
if (Pets[i].petbounds.Intersects(Pets[i].petbounds))
{
//fight or whatever lol
}
}
That’s not gonna work. Right away, it’s just gonna intersect with itself. At least that’s what I’m presuming, seeing that the if statement becomes true immediately when only one pet is created and there’s not 2 or 3.
How can I construct an if statement or solution to make it that “If pet collides with ANY other pet except for itself”