I'm using a copy of the per pixel collision sample. My code is exactly the same as it is in the sample. The only difference is person is now potion and block is now box. I used those items because they sound similar and if I got lost while adding to them, I could tell them apart in my code.
Anyway, I eventually plan on changing out my box with ground texture and potion with player character. The problem I'm having is in this method
// Check collision with person
if (IntersectPixels(potionRectangle, potionTextureData,
boxRectangle, boxTextureData))
{
potionHit = true;
potionPosition.X = boxRectangle.Left - potionTexture.Width / 1.5f;
}
else
{
potionHit = false;
}
This gets me spot on pixel collision with the left side of box, and keeps the potion out of the box, just like i would want with the character on the ground. My issue is I can't seem to get it to do the same for the Right, Top, and Bottom of the box. If I add those and try again, the potion teleports to left side of the box, I assume because it's the first line in the code. But adding the whole if else if line again with a different location on the box doesn't correct the issue. What am I missing? It's something simple I feel such as a missing keyword.
Anyone know? I'm not good at explaining code(English not my first language), so if you need it to be clearer, just ask and I'll try to say it in a different way.