def create_pac_game(self): game = Game('data/pac.conf', PacGame) game.run()
def create_collect_fruit(self): game = Game('data/collect_fruit.conf', CollectFruit) game.run()
def create_snake_game(self): game = Game('data/snake.conf', SnakeGame) game.run()
self.level.place_random_fruit() self.status_box.data['score'] += 100 self.snake.eaten = None if self.snake.crashed: self.update_mode = self.update_finish_moves self.score = self.status_box.data['score'] def update(self): self.update_mode() self.snake.move() def draw(self): self.update() self.level.draw() self.snake.draw() self.status_box.draw() pygame.display.update() def run(self): self.events = EventGenerator() self.events.add_listener(FigureMoveListener(self.snake.set_direction)) self.events.add_listener(ExitListener(self.events.exit_signalled)) with draw_timer(self, self.events): self.events.event_loop() if __name__ == '__main__': game = Game('data/snake.conf', SnakeGame) game.run()
class ColorsLevel: def __init__(self, data, tmap, ghost_speed): self.tmap = tmap self.tmap.set_map(data) self.tmap.cache_map() self.souls_left = 0 self.ghost_speed = ghost_speed def at(self, pos): return self.tmap.at(pos) def remove_soul(self, pos): tile = self.at(pos) self.tmap.set_tile(pos, 'w') self.tmap.cache_map() self.draw() souleatsound.play() def draw(self): self.tmap.draw() def get_speed(self): return self.ghost_speed if __name__ == '__main__': pygame.mixer.music.load("music/menumusic.ogg") pygame.mixer.music.play(-1) game = Game('data/colors.conf', Colors) game.run()