Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/tools.py
diff options
context:
space:
mode:
authorBrian <brian@laptop.org>2008-07-10 16:02:42 (GMT)
committer Brian <brian@laptop.org>2008-07-10 16:02:42 (GMT)
commit81c112b2e4869da9d572d082bb7ed1e075f2ac22 (patch)
treeb349c792de9be1d74ed91b7345052091f4de7027 /tools.py
parentc1b549f3210b363d2cd07043b5f20bbcc2206d44 (diff)
thicker affixations, more mouse grab power!
Diffstat (limited to 'tools.py')
-rw-r--r--tools.py31
1 files changed, 30 insertions, 1 deletions
diff --git a/tools.py b/tools.py
index 2409527..c7df29b 100644
--- a/tools.py
+++ b/tools.py
@@ -311,4 +311,33 @@ class DestroyTool(Tool):
pygame.draw.lines(self.game.screen,(255,0,0),False,self.vertices,3)
def cancel(self):
- self.vertices = None
+ self.vertices = None
+
+ # The joystick tool
+class JoystickTool(Tool):
+ def __init__(self,gameInstance):
+ self.game = gameInstance
+ self.name = "Joystick"
+ self.vertices = None
+ self.joystickobject
+ def handleEvents(self,event):
+ #look for default events, and if none are handled then try the custom events
+ if not super(JoystickTool,self).handleEvents(event):
+ if pygame.mouse.get_pressed()[0]:
+ if not self.vertices: self.vertices = []
+ self.vertices.append(pygame.mouse.get_pos())
+ if len(self.vertices) > 10:
+ self.vertices.pop(0)
+ self.joystickobject = self.game.world.get_bodies_at_pos(pygame.mouse.get_pos())
+ if tokill:
+ self.game.world.world.DestroyBody(tokill[0])
+ elif event.type == MOUSEBUTTONUP and event.button == 1:
+ self.cancel()
+ def draw(self):
+ # draw the trail
+ if self.vertices:
+ if len(self.vertices) > 1:
+ pygame.draw.lines(self.game.screen,(255,0,0),False,self.vertices,3)
+
+ def cancel(self):
+ self.vertices = None