Hardware Reference
In-Depth Information
bounceSound.play()
delta[1] = - delta[1]
p[1] = limit[3]
elif p[0] <= limit[0] : # test missed ball left player
outSound.play()
rally = False
score[1] += 1
server = 0
p[0] = hw
updateScore()
elif p[0] >= limit[1] : # test missed ball right player
outSound.play()
rally = False
score[0] += 1
server = 1
p[0] = hw
updateScore()
# Test left bat collision
elif p[0] < limit[4] and p[1] >= batY[0] - ballRad ;
and p[1] <= batY[0] + ballRad + batHeight:
batBounce(p[1],batY[0],0)
p[0] = limit[4]
# Test right bat collision
elif p[0] >= limit[5] and p[1] >= batY[1] - ballRad ;
and p[1] <= batY[1] + ballRad + batHeight:
batBounce(p[1],batY[1],1)
p[0] = limit[5]
return p
def batBounce(ball, bat, player) :
global delta
point = bat - ball
delta[1] = int(-14.0 * ((point * 0.05) + 0.6))
delta[0] = 16 - abs(delta[1])
if player == 1 :
delta[0] = -delta[0]
p1hitSound.play()
else:
p0hitSound.play()
def updateScore():
global scoreRect, scoreSurface
scoreSurface = font.render(str(score[0])+” : “;
continued
Search WWH ::




Custom Search