diff options
author | Wade Brainerd <wadetb@gmail.com> | 2009-10-30 02:40:11 (GMT) |
---|---|---|
committer | Wade Brainerd <wadetb@gmail.com> | 2009-10-30 02:40:11 (GMT) |
commit | 404d5ed2bc2c21add965bc6035443bae086beeed (patch) | |
tree | 18816c7ad93f21f1e6185fe07368f69a1bed0879 | |
parent | 802387fcbca231fb54fa5caad3affda942b5bc39 (diff) |
Move setup code to a function.
-rw-r--r-- | physics.py | 29 |
1 files changed, 16 insertions, 13 deletions
@@ -37,6 +37,21 @@ class PhysicsGame: self.toolList[c.name] = c(self) self.currentTool = self.toolList[tools.allTools[0].name] + def setup(self): + self.screen = pygame.display.get_surface() + + # get everything set up + self.clock = pygame.time.Clock() + self.font = pygame.font.Font(None, 24) # font object + + # set up the world (instance of Elements) + self.box2d = box2d + self.world = elements.Elements(self.screen.get_size()) + self.world.renderer.set_surface(self.screen) + + # set up static environment + self.world.add.ground() + def stop_start_toggle(self): self.world.run_physics = not self.world.run_physics @@ -51,20 +66,8 @@ class PhysicsGame: self.world.json_load(file_path) def run(self): - self.screen = pygame.display.get_surface() - - # get everything set up - self.clock = pygame.time.Clock() - self.font = pygame.font.Font(None, 24) # font object - - # set up the world (instance of Elements) - self.box2d = box2d - self.world = elements.Elements(self.screen.get_size()) - self.world.renderer.set_surface(self.screen) + self.setup() - # set up static environment - self.world.add.ground() - self.running = True while self.running: # Pump GTK messages. |