changeset 506:6c1d44c12454

Make space and pause also pause.
author Simon Cross <hodgestar@gmail.com>
date Sun, 18 Sep 2011 00:04:46 +0200
parents b459652f8c27
children f4f883418ac2
files TODO.txt mamba/widgets/game.py
diffstat 2 files changed, 6 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/TODO.txt	Sun Sep 18 00:01:04 2011 +0200
+++ b/TODO.txt	Sun Sep 18 00:04:46 2011 +0200
@@ -9,7 +9,6 @@
   - numpad keys
   - cursor
 * Give a 2 second pause to view the level before starting.
-* Use spacebar and pause key as pause keys too
 * Don't pause forever while loading unofficial levels
   * For user levels, we can update the cache on level save, but that
     would require a more global cache. Maybe centralise this in
--- a/mamba/widgets/game.py	Sun Sep 18 00:01:04 2011 +0200
+++ b/mamba/widgets/game.py	Sun Sep 18 00:04:46 2011 +0200
@@ -1,7 +1,8 @@
 """Display the game area."""
 
 from pygame.rect import Rect
-from pygame.locals import KEYDOWN, K_LEFT, K_RIGHT, K_DOWN, K_UP, K_p
+from pygame.locals import (KEYDOWN, K_LEFT, K_RIGHT, K_DOWN, K_UP, K_p,
+                           K_SPACE, K_PAUSE)
 
 from mamba.constants import UP, DOWN, LEFT, RIGHT
 from mamba.widgets.base import Widget
@@ -20,11 +21,14 @@
 
     def create_action_map(self):
         actions = {}
+        pause = (self.world.toggle_pause, ())
         actions[K_LEFT] = (self.world.snake.send_new_direction, (LEFT,))
         actions[K_RIGHT] = (self.world.snake.send_new_direction, (RIGHT,))
         actions[K_DOWN] = (self.world.snake.send_new_direction, (DOWN,))
         actions[K_UP] = (self.world.snake.send_new_direction, (UP,))
-        actions[K_p] = (self.world.toggle_pause, ())
+        actions[K_p] = pause
+        actions[K_SPACE] = pause
+        actions[K_PAUSE] = pause
         return actions
 
     def action_callback(self, ev, widget):