From d6973b1f4a1f8aefa98efe8e4f4115825e725903 Mon Sep 17 00:00:00 2001 From: Peter Ward Date: Wed, 30 Sep 2009 11:11:47 +1000 Subject: Removed unnecesary code, exit on game end. --- pyglet_snake.py | 40 ++++------------------------------------ 1 file changed, 4 insertions(+), 36 deletions(-) diff --git a/pyglet_snake.py b/pyglet_snake.py index 5b90209..c183c59 100755 --- a/pyglet_snake.py +++ b/pyglet_snake.py @@ -97,42 +97,10 @@ class PygletSnakeEngine(SnakeEngine, pyglet.window.Window): w, h = self.eyes.size self.eyes.blit(left, top, width=w, height=h) - def run(self): - clock = pygame.time.Clock() - - running = True - while running and self.bots: - for event in pygame.event.get(): - if event.type == pygame.QUIT or \ - (event.type == pygame.KEYDOWN and event.key == K_ESCAPE): - running = False - break - if not running: break - - # Clear the screen. - self.screen.fill((0, 0, 0)) - self.surface.fill((0, 0, 0)) - - # Draw the board. - self.draw_board() - - # Center the board. - x = (self.width - self.board_width) / 2 - y = (self.height - self.board_height) / 2 - self.screen.blit(self.surface, (x, y)) - - # Update the display. - pygame.display.flip() - clock.tick(20) - - # Let the snakes move! - self.update_snakes() - - if running: - time.sleep(2) - - # Early window close, late process cleanup. - pygame.display.quit() + def update_snakes(self, *args): + if not self.bots: + pyglet.app.exit() + super(PygletSnakeEngine, self).update_snakes(*args) if __name__ == '__main__': from bots import * -- cgit v1.2.3