summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPeter Ward <peteraward@gmail.com>2009-09-30 11:11:47 +1000
committerPeter Ward <peteraward@gmail.com>2009-09-30 11:11:47 +1000
commitd6973b1f4a1f8aefa98efe8e4f4115825e725903 (patch)
treedd4f4463f2313783591f3e309771a59bc16b628f
parent13883bccd40638a3c680a5ed1624731726704b6b (diff)
Removed unnecesary code, exit on game end.
-rwxr-xr-xpyglet_snake.py40
1 files 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 *