mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 14:37:45 +00:00
Breakout: Use the pending new ball rect for brick collision testing
Otherwise the ball will bounce one frame *after* hitting a brick.
This commit is contained in:
parent
8e4e77fcf4
commit
0bf927a824
1 changed files with 2 additions and 2 deletions
|
@ -204,10 +204,10 @@ void Game::tick()
|
|||
for (auto& brick : m_bricks) {
|
||||
if (brick.dead)
|
||||
continue;
|
||||
if (m_ball.rect().intersects(brick.rect)) {
|
||||
if (new_ball.rect().intersects(brick.rect)) {
|
||||
brick.dead = true;
|
||||
|
||||
auto overlap = m_ball.rect().intersected(brick.rect);
|
||||
auto overlap = new_ball.rect().intersected(brick.rect);
|
||||
if (overlap.width() < overlap.height()) {
|
||||
new_ball.x = m_ball.x;
|
||||
new_ball.vx *= -1;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue