def player_death(self): self.lives -= 1 if self.lives == 0: self.msg = "GAME OVER!" t = util.get_millis() def ending(event): self.frame.render() if util.get_millis() - t > 2000: self.new_game() self.play_intro() self.updatefn = ending else: t = util.get_millis() def continue_game(event): self.frame.render() if util.get_millis() - t > 2000: self.respawn_entities() self.replay_level() self.msg = "{0} LIVES LEFT".format(self.lives) self.updatefn = continue_game
def next(num, key): if self.konami_stack == num and event.key_is_pressed(key): self.konami_stack += 1 self.konami_last_press = util.get_millis() return True return False
def next_level(self): self.level += 1 self.msg = "NEXT LEVEL {0}".format(self.level) self.maze.reset() self.respawn_entities() t = util.get_millis() def wait(event): if util.get_millis() - t > 2000: self.play_intro() self.updatefn = wait
def update(self, event): try: t = util.get_millis() if t - self.t > 1: self.konami_code(event) self.update_icons() self.updatefn(event) self.t = t if self.konami: self.msg = "KONAMI!" except Exception as ex: util.Error.log("PacMan Runtime", ex)
def konami_code(self, event): def next(num, key): if self.konami_stack == num and event.key_is_pressed(key): self.konami_stack += 1 self.konami_last_press = util.get_millis() return True return False lst = [Ev.Key.LEFT, Ev.Key.LEFT, Ev.Key.RIGHT, Ev.Key.RIGHT ] + [Ev.Key.UP, Ev.Key.DOWN] * 2 + ["a", "b"] for i in range(0, len(lst)): if next(i, lst[i]): break if util.get_millis() - self.konami_last_press > 5000: self.konami_stack = 0 if self.konami_stack == len(lst): self.konami_stack = 0 self.konami = not self.konami
def continue_game(event): self.frame.render() if util.get_millis() - t > 2000: self.respawn_entities() self.replay_level()
def ending(event): self.frame.render() if util.get_millis() - t > 2000: self.new_game() self.play_intro()
def wait(event): if util.get_millis() - t > 2000: self.play_intro()