Skip to content

Instantly share code, notes, and snippets.

@nklsrh
Created July 10, 2013 02:36
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/5963029 to your computer and use it in GitHub Desktop.
Save nklsrh/5963029 to your computer and use it in GitHub Desktop.
// if ball goes off the top side (side of table)
if (ball.position.y <= -fieldHeight/2)
{
ballDirY = -ballDirY;
}
// if ball goes off the bottom side (side of table)
if (ball.position.y >= fieldHeight/2)
{
ballDirY = -ballDirY;
}
//// --------------------------------- ////
CHANGED CODE
//// --------------------------------- ////
// if ball goes off the 'left' side (Player's side)
if (ball.position.x <= -fieldWidth/2)
{
// CPU scores a point
// update scoreboard
// and reset ball
}
// if ball goes off the 'right' side (CPU's side)
if (ball.position.x >= fieldWidth/2)
{
// player scores a point
// update scoreboard
// and reset ball
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment