Retired Document
Important: This sample code may not represent best practices for current development. The project may use deprecated symbols and illustrate technologies and techniques that are no longer recommended.
PongAI.js
var lastBallY = 0; |
function nextMove(paddle, ball) |
{ |
var ballY = ball.middleY; |
var ballDirection = ballY > lastBallY |
? kUpDirection |
: kDownDirection; |
lastBallY = ballY; |
if (ballY > paddle.top) |
return kUpDirection; |
if (ballY < paddle.bottom) |
return kDownDirection; |
return ballDirection; |
} |
Copyright © 2007 Apple Inc. All Rights Reserved. Terms of Use | Privacy Policy | Updated: 2007-06-06