From 4f0083f24f608bf4627fdf0fd8629833116691db Mon Sep 17 00:00:00 2001 From: Alex Levenson Date: Wed, 16 Jul 2008 19:50:38 +0000 Subject: Improved toolbar automation --- (limited to 'physics.py') diff --git a/physics.py b/physics.py index 5f3c9d6..769de46 100644 --- a/physics.py +++ b/physics.py @@ -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 -- cgit v0.9.1