python quit()讲解_Python locals.QUIT属性代码示例

  • Post author:
  • Post category:python


# 需要导入模块: from pygame import locals [as 别名]

# 或者: from pygame.locals import QUIT [as 别名]

def update(self):

“””Called on new frame.”””

self.clock.tick(60)

new_time = time.time()

self.time_delta = new_time – self.last_update_time

self.last_update_time = new_time

self.score += self.energy_per_second * self.time_delta

for event in pygame.event.get():

if event.type == QUIT or (event.type == KEYDOWN

and event.key == K_ESCAPE):

self.exit_requested = True

return

if event.type == MOUSEBUTTONDOWN:

pos = pygame.mouse.get_pos()

if self.crank.rect.collidepoint(pos):

self.crank.clicked()

for button in self.all_buttons:

if button.rect.collidepoint(pos):

button.clicked()

for machine in self.machines.values():

if machine.rect.collidepoint(pos):

if self.score >= machine.cost:

self.score -= machine.cost

machine.count += 1

self.events.send(f”buy_machine_{machine.name}”)

if self.score >= 5.67e5 and not self.congrats_message:

self.congrats_message = StaticImage((0.5, 0.8), images[“congrats”])

self.gui_plain.add(self.congrats_message)

self.events.send(“win”)

for sprite_layer in self.sprite_layers:

sprite_layer.update()

self.screen.blit(self.background, (0, 0))

self.screen.fill(self.overlay_color, rect=self.overlay1, special_flags=pygame.BLEND_MULT)

self.screen.fill(self.overlay_color, rect=self.overlay2, special_flags=pygame.BLEND_MULT)

for sprite_layer in self.sprite_layers:

sprite_layer.draw(self.screen)

pygame.display.flip()

say(self.events.get_current_message())



版权声明:本文为weixin_42210038原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。