diff options
author | Alex <alex@Tiresias.(none)> | 2008-07-07 21:55:31 (GMT) |
---|---|---|
committer | Alex <alex@Tiresias.(none)> | 2008-07-07 21:55:31 (GMT) |
commit | 3cc4321a5be8406a91ba30a0f606dff1d1c56bc5 (patch) | |
tree | 6c912f18e6d0216dbd3c745fc58e073805801a27 | |
parent | 961eee131538f4c7eccf37aa9469b7b3118c4fcb (diff) |
Added a red trail to the destroy tool
-rw-r--r-- | activity.py | 17 |
1 files changed, 16 insertions, 1 deletions
diff --git a/activity.py b/activity.py index a9fe70d..9bfebd4 100644 --- a/activity.py +++ b/activity.py @@ -274,13 +274,28 @@ class JointTool(Tool): class DestroyTool(Tool): def __init__(self): self.name = "Destroy" + self.vertices = None def handleEvents(self,event): #look for default events, and if none are handled then try the custom events if not super(DestroyTool,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) tokill = world.get_bodies_at_pos(pygame.mouse.get_pos()) if tokill: - world.world.DestroyBody(tokill[0]) + world.world.DestroyBody(tokill[0]) + elif event.type == MOUSEBUTTONUP and event.button == 1: + self.cancel() + def draw(self): + # draw the trail + if self.vertices: + for i in range(len(self.vertices)-1): + pygame.draw.line(screen,(255,0,0),self.vertices[i],self.vertices[i+1],3) + + def cancel(self): + self.vertices = None # set up pygame pygame.init() size = (pygame.display.list_modes()[0]) |