Hardware Reference
In-Depth Information
updateScore()
screen.blit(background,[0,0])
while True :
ballsLeft = balls
if score > best:
best = score
score = 0
updateScore()
while ballsLeft > 0:
ballPosition = waitForServe(ballPosition)
while rally :
checkForEvent()
time.sleep(0.05)
drawScreen(ballPosition)
ballPosition = moveBall(ballPosition)
ballsLeft -= 1
print “press space for”,balls,”more balls”
pause = True
while pause :
checkForEvent()
def waitForServe(p) :
global batY, rally, delta
computerBatDelta = 2
serveTime = time.time() + 2.0 #automatically serve again
while time.time() < serveTime :
checkForEvent()
drawScreen(p)
batY[0] += computerBatDelta ;
# move bat up and down when waiting
if batY[0] > limit[3] or batY[0] < limit[2]:
computerBatDelta = -computerBatDelta
p[0] = batX[0]
p[1] = batY[0]
delta = deltaChoice[random.randint(0,maxDelta)]
rally = True
return p
def moveBall(p):
global delta, batY, rally, score, batThick
p[0] += delta[0]
p[1] += delta[1]
continued
Search WWH ::




Custom Search