Created
January 10, 2022 17:43
-
-
Save melcor76/d6632221f65954993b2be600d6b2d913 to your computer and use it in GitHub Desktop.
Breakout brick direction hit
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Check if ball is inside from left side | |
ball.x + 2 * ball.radius > brick x | |
// Decrease by dx and check if position was on left side of brick x | |
ball.x + 2 * ball.radius - ball.dx <= brick.x; | |
// Similarly for right side | |
ball.x < brick.x + brick.width | |
ball.x - ball.dx >= brick.x + brick.width |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment