Skip to content

Instantly share code, notes, and snippets.

@nklsrh
Created July 10, 2013 02:37
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/5963036 to your computer and use it in GitHub Desktop.
Save nklsrh/5963036 to your computer and use it in GitHub Desktop.
// resets the ball's position to the centre of the play area
// also sets the ball direction speed towards the last point winner
function resetBall(loser)
{
// position the ball in the center of the table
ball.position.x = 0;
ball.position.y = 0;
// if player lost the last point, we send the ball to opponent
if (loser == 1)
{
ballDirX = -1;
}
// else if opponent lost, we send ball to player
else
{
ballDirX = 1;
}
// set the ball to move +ve in y plane (towards left from the camera)
ballDirY = 1;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment