diff options
author | Seth Woodworth <seth@isforinsects.com> | 2010-02-17 20:23:33 (GMT) |
---|---|---|
committer | Seth Woodworth <seth@isforinsects.com> | 2010-02-17 20:23:33 (GMT) |
commit | 0b53b220363b1ce59f9b5e6af16aa5a0ea58afb0 (patch) | |
tree | 399b497728f0c3dbda6ce5dbeacc6cf0b3765aa3 /tools.py | |
parent | eaa86109dfa899534e354fac7f517caad539ec2f (diff) | |
parent | dd62508faa74fce1de8302f3bfe3d33358628b7a (diff) |
Conflicts:
physics.py
Diffstat (limited to 'tools.py')
-rw-r--r-- | tools.py | 32 |
1 files changed, 31 insertions, 1 deletions
@@ -410,7 +410,35 @@ class RollTool(Tool): self.jb1 = self.jb1pos = None def cancel(self): self.jb1 = self.jb1pos = None - + + +class PaintTool(Tool): + name = 'Paint' + icon = 'paint' + toolTip = _("Paint") + toolAccelerator = _("<ctrl>s") + + def __init__(self,gameInstance): + self.game = gameInstance + self.name = 'Paint' + self.jb1 = self.jb1pos = None + def handleEvents(self,event): + #look for default events, and if none are handled then try the custom events + if not super(PaintTool,self).handleEvents(event): + if event.type == MOUSEBUTTONDOWN: + if event.button == 1: + self.jb1pos = event.pos + self.jb1 = self.game.world.get_bodies_at_pos(event.pos) + if self.jb1: + if type(self.jb1[0].userData) == type({}): + self.jb1[0].userData['paint'] = {} + self.jb1[0].userData['paint']['color'] = self.jb1[0].userData['color'] + x = self.game.world.to_world(event.pos)[0]/self.game.world.ppm + y = self.game.world.to_world(event.pos)[1]/self.game.world.ppm + self.jb1[0].userData['paint']['pos'] = self.jb1[0].GetLocalPoint((x,y)).tuple() + self.jb1 = self.jb1pos = None + def cancel(self): + self.jb1 = self.jb1pos = None # The destroy tool class DestroyTool(Tool): @@ -460,8 +488,10 @@ def getAllTools(): PolygonTool, GrabTool, MotorTool, + RollTool, PinTool, JointTool, + PaintTool, DestroyTool] allTools = getAllTools() |