Skip to content

Instantly share code, notes, and snippets.

@nklsrh
Created July 10, 2013 02:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nklsrh/5963056 to your computer and use it in GitHub Desktop.
Save nklsrh/5963056 to your computer and use it in GitHub Desktop.
// and if ball is travelling towards player (-ve direction)
if (ballDirX < 0)
{
// stretch the paddle to indicate a hit
paddle1.scale.y = 15;
// switch direction of ball travel to create bounce
ballDirX = -ballDirX;
// we impact ball angle when hitting it
// this is not realistic physics, just spices up the gameplay
// allows you to 'slice' the ball to beat the opponent
ballDirY -= paddle1DirY * 0.7;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment