From 61c885730ad359bcfbaeea493dfd6f5d53dd814f Mon Sep 17 00:00:00 2001 From: Alex Levenson Date: Mon, 14 Jul 2008 18:04:58 +0000 Subject: created a seperate world.add.motor() function --- (limited to 'elements') diff --git a/elements/add_objects.py b/elements/add_objects.py index bac1606..3842b75 100644 --- a/elements/add_objects.py +++ b/elements/add_objects.py @@ -465,18 +465,14 @@ class Add: self.parent.world.CreateJoint(jointDef) def fixedJoint(self, *args): - if len(args) >= 2: + if len(args) == 2: # Fixed Joint to the Background, don't assume the center of the body b1 = self.parent.world.GetGroundBody() b2 = args[0] p1 = self.to_b2vec(args[1]) jointDef = box2d.b2RevoluteJointDef() - jointDef.Initialize(b1, b2, p1) - if len(args) == 3: - jointDef.maxMotorTorque = 900.0 - jointDef.motorSpeed = 20.0 - jointDef.enableMotor = True + jointDef.Initialize(b1, b2, p1) self.parent.world.CreateJoint(jointDef) elif len(args) == 1: # Fixed Joint to the Background, assume the center of the body @@ -522,6 +518,17 @@ class Add: self.parent.world.CreateJoint(jointDef) + def motor(self, body,pt,torque=900,speed=-10): + # Fixed Joint to the Background with a motor on it + b1 = self.parent.world.GetGroundBody() + pt = self.to_b2vec(pt) + + jointDef = box2d.b2RevoluteJointDef() + jointDef.Initialize(b1, body, pt) + jointDef.maxMotorTorque = torque + jointDef.motorSpeed = speed + jointDef.enableMotor = True + self.parent.world.CreateJoint(jointDef) #def jointMotor(self,b1,b2,p1,speed): # p1 = self.tob2vec(p1) # jointDef = box2d.b2RevoluteJointDef() -- cgit v0.9.1