Hardware Reference
In-Depth Information
True, cText, cBackground)
scoreRect = scoreSurface.get_rect()
scoreRect.centerx = hw
scoreRect.centery = 24
def drawScreen(p) : # draw to the screen
global rally
screen.blit(background,[0,0]) # set background colour
pygame.draw.rect(screen,(255,0,0), (hw - (box[0]/2),;
hh - (box[1]/2),box[0],box[1]), 4)
pygame.draw.line(screen,(0,255,0), (batX[0], batY[0]),;
(batX[0], batY[0]+batHeight),batThick)
pygame.draw.line(screen,(0,255,0), (batX[1], batY[1]),;
(batX[1], batY[1]+batHeight),batThick)
screen.blit(scoreSurface, scoreRect)
if rally :
pygame.draw.circle(screen,cBall, (p[0], p[1]),;
ballRad, 2)
pygame.display.update()
def updateBox(d,amount):
global box, limit
box[d] += amount
limit[0] = hw - (box[0]/2) +ballRad #leftLimit
limit[1] = hw + (box[0]/2) -ballRad #rightLimit
limit[2] = hh - (box[1]/2) + ballRad #topLimit
limit[3] = (hh + (box[1]/2))-ballRad #bottomLimit
limit[4] = batX[0] + ballRad + batThick/2 ;
#x Limit ball approaching from the right
limit[5] = batX[1] - ballRad - batThick/2 ;
#x Limit ball approaching from the left
def terminate(): # close down the program
print (“Closing down please wait”)
pygame.quit() # close pygame
sys.exit()
def checkForEvent(): # see if you need to quit
global batY, rally, pause
event = pygame.event.poll()
if event.type == pygame.QUIT :
terminate()
if event.type == pygame.KEYDOWN :
continued
Search WWH ::




Custom Search