#
ClickSound=pygame.mixer.Sound('/home/pi/python_games/match1.wav')
#
###### Play the Game ######################################
#
while True:
for event in pygame.event.get():
if event.type == pygame.MOUSEBUTTONDOWN:
for RNumber in range(RAmount):
RasLoc = 'RasLoc' + str(RNumber)
RasImageLocation = Raspberry[RasLoc]
if RasImageLocation.collidepoint(pygame.mouse.get_pos()):
deleteRaspberry(Raspberry,RNumber)
RAmount = RAmount - 1
ClickSound.play()
pygame.time.delay(50)
if RAmount == 0:
sys.exit()
#Redraw the Screen Background ###############
GameScreen.fill(blue)
#
#Move the Raspberries around the screen #####
for RNumber in range(RAmount):
RasLoc = 'RasLoc' + str(RNumber)
RasImageLocation = Raspberry[RasLoc]
RasOff = 'RasOff' + str(RNumber)
RasImageOffset = Raspberry[RasOff]
#
NewLocation = RasImageLocation.move(RasImageOffset)
#
Raspberry[RasLoc] = NewLocation #Update location
#
#Keep Raspberries on screen ##################
if NewLocation.left < 0 or NewLocation.right > ScreenWidth:
NewOffset = -RasImageOffset[0]
if NewOffset < 0:
NewOffset = NewOffset - 1
else:
NewOffset = NewOffset + 1
#
RasImageOffset = [NewOffset, RasImageOffset[1]]
Raspberry[RasOff] = RasImageOffset #Update offset
#
if NewLocation.top < 0 or NewLocation.bottom > ScreenHeight:
NewOffset = -RasImageOffset[1]
if NewOffset < 0:
NewOffset = NewOffset - 1
else:
NewOffset = NewOffset + 1
#
RasImageOffset = [RasImageOffset[0],NewOffset]
Raspberry[RasOff] = RasImageOffset #Update offset
#
GameScreen.blit(GameImageGraphic,NewLocation) #Put on Screen
#
pygame.display.update()
#
Often games have multiple images on the game screen. The Raspberry Pie game creates 17 Raspberry