This file contains hidden or 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
| You want to share the core collision logic so other developers can use it in their own games. | |
| /** | |
| * Global Helper for Block Buster Game | |
| * Logic to detect if the ball hits a block | |
| */ | |
| function checkCollision(ball, block) { | |
| if (ball.x + ball.radius > block.x && | |
| ball.x - ball.radius < block.x + block.width && | |
| ball.y + ball.radius > block.y && | |
| ball.y - ball.radius < block.y + block.height) { |