Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGary Martin <gary@garycmartin.com>2009-08-23 18:51:18 (GMT)
committer Gary Martin <gary@garycmartin.com>2009-08-23 18:51:18 (GMT)
commit95d395e27a129fcec35057a76b68f6bf613ed472 (patch)
tree5b8f5b66ccfeeabebfbff0328ee205eebd9b5896
parentda07cde3f683a2e52528d48ed4632b8ceff85744 (diff)
Use a user event for stop/start rather than injecting a key event.
-rw-r--r--activity.py2
-rw-r--r--tools.py15
2 files changed, 8 insertions, 9 deletions
diff --git a/activity.py b/activity.py
index eafb155..b7f0d33 100644
--- a/activity.py
+++ b/activity.py
@@ -68,7 +68,7 @@ class PhysicsActivity(olpcgames.PyGameActivity):
return activity_toolbar
def stop_play_cb(self, button):
- pygame.event.post(olpcgames.eventwrap.Event(pygame.KEYDOWN, key=pygame.K_SPACE))
+ pygame.event.post(olpcgames.eventwrap.Event(pygame.USEREVENT, action="stop_start_toggle"))
self.stop_play_state = not self.stop_play_state
# Update button
if self.stop_play_state:
diff --git a/tools.py b/tools.py
index 136896b..c768da2 100644
--- a/tools.py
+++ b/tools.py
@@ -26,20 +26,19 @@ class Tool(object):
if event.type == QUIT:
# bye bye! Hope you had fun!
self.game.running = False
- elif event.type == KEYDOWN:
- if event.key == K_SPACE:
- #space pauses
- self.game.world.run_physics = not self.game.world.run_physics
-
elif event.type == USEREVENT:
if hasattr(event,"action"):
- if self.game.toolList.has_key(event.action): self.game.setTool(event.action)
- if hasattr(event,"code"):
+ if event.action == "stop_start_toggle":
+ # stop/start simulation
+ self.game.world.run_physics = not self.game.world.run_physics
+ elif self.game.toolList.has_key(event.action):
+ self.game.setTool(event.action)
+ elif hasattr(event,"code"):
if event.code == olpcgames.FILE_WRITE_REQUEST:
#saving to journal
self.game.world.add.remove_mouseJoint()
self.game.world.json_save(event.filename)
- if event.code == olpcgames.FILE_READ_REQUEST:
+ elif event.code == olpcgames.FILE_READ_REQUEST:
#loading from journal
self.game.world.json_load(event.filename)
elif event.type == MOUSEBUTTONDOWN and event.button == 1: