From 1772023f122fe0ceab52edd0124272247a144c5b Mon Sep 17 00:00:00 2001 From: Alex Levenson Date: Thu, 10 Jul 2008 19:48:40 +0000 Subject: Added the prismatic joint to elements --- (limited to 'tools.py') diff --git a/tools.py b/tools.py index 0c13581..125d033 100644 --- a/tools.py +++ b/tools.py @@ -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) -- cgit v0.9.1