Skip to content

Commit

Permalink
Collisions more efficient
Browse files Browse the repository at this point in the history
  • Loading branch information
kliao2016 committed Nov 13, 2017
1 parent 1393848 commit b00a8b3
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions game.c
Original file line number Diff line number Diff line change
Expand Up @@ -189,15 +189,15 @@ void handleBrickCollisions(Brick *brptr, Ball *ballptr, int *numBricks, int bric
*(numBricks) -= 1;
cur->isHit = 1;
ballptr->xDir *= -1;
ballptr->col = ballptr->col + (ballptr->xDir * 5);
ballptr->col = ballptr->col + (ballptr->xDir * 3);
} else if ((((ballptr->row + BALLSIZE) == brptr->row)
|| (ballptr->row == (cur->row + BRICKHEIGHT)))
&& ((ballptr->col >= (cur->col - BALLSIZE))
&& (ballptr->col <= (cur->col + BRICKWIDTH)))) {
*(numBricks) -= 1;
cur->isHit = 1;
ballptr->yDir *= -1;
ballptr->row = ballptr->row + (ballptr->yDir * 5);
ballptr->row = ballptr->row + (ballptr->yDir * 3);
}
drawRect(cur->row, cur->col, BRICKHEIGHT, BRICKWIDTH, cur->color);
}
Expand Down

0 comments on commit b00a8b3

Please sign in to comment.