Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions Chapter01/Game.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -141,9 +141,9 @@ void Game::UpdateGame()
{
mPaddlePos.y = paddleH/2.0f + thickness;
}
else if (mPaddlePos.y > (768.0f - paddleH/2.0f - thickness))
else if (mPaddlePos.y > (768.0f - (paddleH/2.0f - thickness)))
{
mPaddlePos.y = 768.0f - paddleH/2.0f - thickness;
mPaddlePos.y = 768.0f - (paddleH/2.0f - thickness);
}
}

Expand All @@ -160,7 +160,7 @@ void Game::UpdateGame()
// Our y-difference is small enough
diff <= paddleH / 2.0f &&
// We are in the correct x-position
mBallPos.x <= 25.0f && mBallPos.x >= 20.0f &&
mBallPos.x <= 30.0f && mBallPos.x >= 25.0f &&
// The ball is moving to the left
mBallVel.x < 0.0f)
{
Expand All @@ -172,18 +172,18 @@ void Game::UpdateGame()
mIsRunning = false;
}
// Did the ball collide with the right wall?
else if (mBallPos.x >= (1024.0f - thickness) && mBallVel.x > 0.0f)
else if (mBallPos.x >= (1024.0f - thickness * 1.5) && mBallVel.x > 0.0f)
{
mBallVel.x *= -1.0f;
}

// Did the ball collide with the top wall?
if (mBallPos.y <= thickness && mBallVel.y < 0.0f)
if (mBallPos.y <= thickness * 1.5 && mBallVel.y < 0.0f)
{
mBallVel.y *= -1;
}
// Did the ball collide with the bottom wall?
else if (mBallPos.y >= (768 - thickness) &&
else if (mBallPos.y >= (768 - thickness * 1.5) &&
mBallVel.y > 0.0f)
{
mBallVel.y *= -1;
Expand Down