We can't really tell where what the problem is, since we have no idea what
BoxCollision does.
Additionally I'd advice you to use references instead of pointers and since you're not gonna change anything about the sprites, use const references.
Also
bool can work with
0 and
1 but it's actually meant to work with
false and
true.
And as a side note SFML provides
typedef Rect<float> FloatRect;, so you don't need to write
sf::Rect<float>.
So the code should more look like this:
bool ADVBoxCollision(const sf::gEntity& sprite1, const sf::gEntity& sprite2, bool& pTop, bool& pSide)
{
sf::FloatRect FirstRect(sprite1.GetPosition().x - sprite1.GetCenter().x ,sprite1.GetPosition().y - sprite1.GetCenter().y,sprite1.GetPosition().x+sprite1.GetSize().x - sprite1.GetCenter().x,sprite1.GetPosition().y+sprite1.GetSize().y - sprite1.GetCenter().y);
sf::FloatRect SecondRect(sprite2.GetPosition().x - sprite2.GetCenter().x ,sprite2.GetPosition().y - sprite2.GetCenter().y,sprite2.GetPosition().x+sprite2.GetSize().x - sprite2.GetCenter().x,sprite2.GetPosition().y+sprite2.GetSize().y - sprite2.GetCenter().y);
//ToS stands for Top or side. It tells whether the sprite collided with the top/bottom part or the side part. 0 = top/bottom, 1 = sides
if(BoxCollision(FirstRect, SecondRect))
{
if((FirstRect.Left <= SecondRect.Right) && (FirstRect.Right >= SecondRect.Left))
{
if(!pSide) pSide = true;
else pSide = false; //If RECT1 is to the left of RECT2
}
if((FirstRect.Top <= SecondRect.Bottom) && (FirstRect.Bottom >= SecondRect.Top))
{
if(pTop) pTop = false; //If RECT1 is over RECT2
else pTop = true;
}
return BoxCollision(FirstRect, SecondRect);
}
else
return false;
}
Regarding your problem, it's quite hard for us to spot the problem, since we'd need to go though everything by hand and asume stuuff, since we don't really see with what data you're working.
It's way easier on your side to check. Just start up the debugger, set breakpoints at the if-statements, check why the one if-statement never evaluates to true and trace back from there what happens before.
And since SFML 2 RC got (finally) released yesterday, you may consider switching over to SFML 2.