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

fixed position sliding that ocured when player hit width bonus/malus

parent 5bf74a9d
Branches
No related merge requests found
......@@ -209,6 +209,12 @@ Physics::collisionBonusPlayer(std::shared_ptr<Player> player, Bonus* bonus)
{
case 0:
player->setWidth(player->getWidth() + player->getScreenWidth()/20);
if(player->getX() - player->getScreenWidth()/40 < 0)
player->setX(0);
else if(player->getX() + player->getWidth() + player->getScreenWidth()/40 > player->getScreenWidth())
player->setX(player->getScreenWidth() - player->getWidth());
else
player->setX(player->getX() - player->getScreenWidth()/40);
break;
case 1:
if (player->getWidth() - player->getScreenWidth()/40 < 0)
......@@ -217,6 +223,8 @@ Physics::collisionBonusPlayer(std::shared_ptr<Player> player, Bonus* bonus)
}
else
player->setWidth(player->getWidth() - player->getScreenWidth()/40);
player->setX(player->getX() + player->getScreenWidth()/80);
break;
case 2:
for (auto ball : *bonus->getBall().get())
......
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