diff options
author | Alex Levenson <alexlevenson@laptop.org> | 2008-07-10 19:48:40 (GMT) |
---|---|---|
committer | Alex Levenson <alexlevenson@laptop.org> | 2008-07-10 19:48:40 (GMT) |
commit | 1772023f122fe0ceab52edd0124272247a144c5b (patch) | |
tree | bf33b7cbc69e8a82c8c8b9516936dfd3abdd0624 /tools.py | |
parent | 191893b5f035acc0f9d5dfb20c2819065a75c42c (diff) |
Added the prismatic joint to elements
Diffstat (limited to 'tools.py')
-rw-r--r-- | tools.py | 10 |
1 files changed, 7 insertions, 3 deletions
@@ -259,15 +259,19 @@ class JointTool(Tool): # grab the first body self.jb1pos = event.pos self.jb1 = self.game.world.get_bodies_at_pos(event.pos) - self.jb2 = self.jb2pos = None + self.jb2 = self.jb2pos = None + if event.button == 2: + bodies = self.game.world.get_bodies_at_pos(event.pos) + if len(bodies) >=2: + self.game.world.add.revoluteJoint(bodies[0],bodies[1],event.pos) elif event.type == MOUSEBUTTONUP: if event.button == 1: # grab the second body self.jb2pos = event.pos self.jb2 = self.game.world.get_bodies_at_pos(event.pos) - # if we have two distinct bodies, add a joint! + # if we have two distinct bodies, add a distance joint! if self.jb1 and self.jb2 and str(self.jb1) != str(self.jb2): - self.game.world.add.distanceJoint(self.jb1[0],self.jb2[0],self.jb1pos,self.jb2pos) + self.game.world.add.distanceJoint(self.jb1[0],self.jb2[0],self.jb1pos,self.jb2pos) # If there's only one body, add a fixed joint elif self.jb2: self.game.world.add.fixedJoint(self.jb2[0],self.jb2pos) |