Created
July 10, 2013 02:40
-
-
Save nklsrh/5963052 to your computer and use it in GitHub Desktop.
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
// if ball is aligned with paddle1 on x plane | |
// remember the position is the CENTER of the object | |
// we only check between the front and the middle of the paddle (one-way collision) | |
if (ball.position.x <= paddle1.position.x + paddleWidth | |
&& ball.position.x >= paddle1.position.x) | |
{ | |
// and if ball is aligned with paddle1 on y plane | |
if (ball.position.y <= paddle1.position.y + paddleHeight/2 | |
&& ball.position.y >= paddle1.position.y - paddleHeight/2) | |
{ | |
// ball is intersecting with the front half of the paddle | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment