Skip to content
Snippets Groups Projects
Commit 1f6801c5 authored by CARDILE VINCENT's avatar CARDILE VINCENT
Browse files

some fix to physics but still busted

parent 4ef775c1
Branches
No related merge requests found
......@@ -71,13 +71,13 @@ Physics::brickRectCollision(Ball* ball, Brick<int>* brick)
&& ball->getY() + ball->getRadius() >= brick->getY()
&& ball->getY() - ball->getRadius() <= brick->getY() + brick->getH())
{
if(ball->getX() - ball->getRadius() < brick->getX() && ball->getDirectionX() < 0
|| ball->getX() + ball->getRadius() > brick->getX() + brick->getW() && ball->getDirectionX() < 0)
if(ball->getX() < brick->getX() && ball->getDirectionX() > 0
|| ball->getX() > brick->getX() + brick->getW() && ball->getDirectionX() < 0)
{
ball->setDirectionX(ball->getDirectionX() * -1);
}
if(ball->getY() - ball->getRadius() < brick->getY() && ball->getDirectionY() > 0
|| ball->getY() + ball->getRadius() > brick->getY() + brick->getH() && ball->getDirectionY() < 0)
if(ball->getY() < brick->getY() && ball->getDirectionY() > 0
|| ball->getY() > brick->getY() + brick->getH() && ball->getDirectionY() < 0)
{
ball->setDirectionY(ball->getDirectionY() * -1);
}
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment