diff options
author | Alex Levenson <alexlevenson@laptop.org> | 2008-07-16 19:50:38 (GMT) |
---|---|---|
committer | Alex Levenson <alexlevenson@laptop.org> | 2008-07-16 19:50:38 (GMT) |
commit | 4f0083f24f608bf4627fdf0fd8629833116691db (patch) | |
tree | afec3a89130a4d7e8800300577763e8126c2aa19 /physics.py | |
parent | 3f87c94f1854c536430052e3bf58d5def23568b6 (diff) |
Improved toolbar automation
Diffstat (limited to 'physics.py')
-rw-r--r-- | physics.py | 21 |
1 files changed, 7 insertions, 14 deletions
@@ -22,7 +22,7 @@ from pygame.color import * import olpcgames import elements from elements import Elements -from tools import * +import tools from helpers import * class PhysicsGame: @@ -33,18 +33,11 @@ class PhysicsGame: self.font = pygame.font.Font(None, 24) # font object self.canvas = olpcgames.ACTIVITY.canvas - # setup tools - self.tools = { - "triangle": TriangleTool(self), - "box": BoxTool(self), - "circle": CircleTool(self), - "polygon": PolygonTool(self), - "magicpen": MagicPenTool(self), - "joint": JointTool(self), - "grab": GrabTool(self), - "destroy": DestroyTool(self) - } - self.currentTool = self.tools["triangle"] + # create the name --> instance map for components + self.toolList = {} + for c in tools.allTools: + self.toolList[c.name] = c(self) + self.currentTool = self.toolList[tools.allTools[0].name] # set up the world (instance of Elements) self.world = elements.Elements(self.screen.get_size()) @@ -81,7 +74,7 @@ class PhysicsGame: def setTool(self,tool): self.currentTool.cancel() - self.currentTool = self.tools[tool] + self.currentTool = self.toolList[tool] def main(): toolbarheight = 75 |