def play(self):
"""Initialize the software."""
self.load_score_images()
while True:
for event in pygame.event.get():
if event.type == pygame.QUIT:
return 0
if not self.pipes_stop:
if event.type == pygame.KEYDOWN:
if event.key == pygame.K_UP:
self.y_increase = -5
# Initialize the bird and the background.
self.screen.blit(self.background_img, (0, 0))
self.y_increase += 0.25 # Simulates gravity acceleration
self.pipes() # Update pipes
# Count the score.
self.score()
if self.bird_dies():
# Bird dies
self.bird()
self.gameover()
pygame.display.flip()
return 1
self.y_increase = 0
self.pipes_stop = True
else:
self.pipes_stop = False
self.bird()
self.y_bird += self.y_increase
# Update the screen.
pygame.display.flip()
self.clock.tick(60)
评论列表
文章目录