Hardware Reference
In-Depth Information
cBackground =(255,255,255)
cBall = (0,0,0)
background.fill(cBackground) # make background colour
cText = (0,0,0)
box = [screenWidth-10,screenHeight-10]
deltaChoice = [ [15,1], [14,1], [13,1], [12,1], [11,1],;
[10,1], [15,2], [14,2], [13,2], [12,2], [11,2], [10,2] ]
maxDelta = 11
delta = deltaChoice[random.randint(0,maxDelta)]
hw = screenWidth / 2
hh = screenHeight /2
ballPosition = [-hw,hh] # position of the ball off-screen
batMargin = 30 # how far in from the wall is the bat
batHeight = 24
batThick = 6
batInc = 20 # bat / key movement
batX = [batMargin, screenWidth - batMargin]
batY = [hh, hh] # initial bat position
limit = [0, 0, 0, 0, 0, 0] #wall limits & bat limits
ballRad = 8 # size of the ball
rally = True
pause = True
server = 0 # player to serve
serve =[False,False]
score = [0,0] # players score
balls = 5 # number of balls in a turn
ballsLeft = balls
batMiddle = (ballRad - (batHeight + ballRad))/2
def main():
global ballPosition, rally, balls, pause, score, server
updateBox(0,0) # set up wall limits
updateScore()
screen.blit(background,[0,0])
while True :
ballsLeft = balls
score = [0,0]
updateScore()
while ballsLeft > 0:
ballPosition = waitForServe(ballPosition,server)
while rally :
checkForEvent()
time.sleep(0.05)
continued
Search WWH ::




Custom Search