minor update

This commit is contained in:
Joseph Aquino 2025-09-24 17:26:22 -04:00
parent 69130c3d94
commit 5f181f45e0
1 changed files with 6 additions and 6 deletions

View File

@ -233,8 +233,8 @@ void Game::collision()
checkBallCollision(); checkBallCollision();
const sf:: FloatRect playerBounds = {player.pos, playerHalfSize};
//player wall collide //player wall collide
const sf:: FloatRect playerBounds = {player.pos, playerHalfSize};
if (playerBounds.position.x + playerBounds.size.x > window.getSize().x) if (playerBounds.position.x + playerBounds.size.x > window.getSize().x)
{ {
player.pos.x = window.getSize().x - playerHalfSize.x; player.pos.x = window.getSize().x - playerHalfSize.x;
@ -371,11 +371,11 @@ void Game::checkBallCollision()
{ {
ball.velocity.x *= -1; ball.velocity.x *= -1;
if (ball.pos.x < player.pos.x) if (ball.pos.x < player.pos.x)
{ {// from the left
ball.pos.x -= intersect.x; ball.pos.x -= intersect.x;
} }
else else
{ {// from the right
ball.pos.x += intersect.x; ball.pos.x += intersect.x;
} }
} }
@ -385,11 +385,11 @@ void Game::checkBallCollision()
{ {
ball.velocity.y *= -1; ball.velocity.y *= -1;
if (ball.pos.y < player.pos.y) if (ball.pos.y < player.pos.y)
{ {// from the top
ball.pos.y -= intersect.y; ball.pos.y -= intersect.y;
} }
else else if (ball.pos.y > player.pos.y)
{ {// from the bottom
ball.pos.y += intersect.y; ball.pos.y += intersect.y;
} }
} }