diff options
author | Wade Brainerd <wadetb@gmail.com> | 2009-10-30 02:29:42 (GMT) |
---|---|---|
committer | Wade Brainerd <wadetb@gmail.com> | 2009-10-30 02:29:42 (GMT) |
commit | 802387fcbca231fb54fa5caad3affda942b5bc39 (patch) | |
tree | e6dcd14a45a6f18b7ef849b828f815c59c18aad4 /activity.py | |
parent | e245a2fbca067dee091ae27c78cad063bd3ffbec (diff) |
Update to newer sugargame.
Diffstat (limited to 'activity.py')
-rw-r--r-- | activity.py | 24 |
1 files changed, 10 insertions, 14 deletions
diff --git a/activity.py b/activity.py index be85085..c689147 100644 --- a/activity.py +++ b/activity.py @@ -11,25 +11,26 @@ import sugargame.activity import physics import tools -class PhysicsActivity(sugargame.activity.PygameActivity): +class PhysicsActivity(activity.Activity): def __init__(self, handle): super(PhysicsActivity, self).__init__(handle) self.metadata['mime_type'] = 'application/x-physics-activity' - - self._resume_path = None + + self.game = physics.PhysicsGame() self.build_toolbar() self.build_canvas() - self.game = physics.PhysicsGame(self.get_pygame_screen()) - if self._resume_path: - self.read_file(self._resume_path) - self.run_pygame(self.run) + self.canvas.run_pygame(self.run) def run(self): self.game.run() - + + def build_canvas(self): + self._canvas = sugargame.canvas.PygameCanvas(self) + self.set_canvas(self._canvas) + def build_toolbar(self): # make a toolbox toolbox = activity.ActivityToolbox(self) @@ -96,12 +97,7 @@ class PhysicsActivity(sugargame.activity.PygameActivity): self.game.set_tool(self.radioList[button]) def read_file(self, file_path): - # Read file is called before the constructor returns when game is not yet valid. - # Caching the file path seems to work in this specific instance. - if not self.game: - self._resume_path = file_path - else: - self.game.read_file(file_path) + self.game.read_file(file_path) def write_file(self, file_path): self.game.write_file(file_path) |