Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--activity.py5
-rw-r--r--elements/add_objects.py19
2 files changed, 21 insertions, 3 deletions
diff --git a/activity.py b/activity.py
index 9231966..601e409 100644
--- a/activity.py
+++ b/activity.py
@@ -253,6 +253,9 @@ class JointTool(Tool):
# if we have two distinct bodies, add a joint!
if self.jb1 and self.jb2 and str(self.jb1) != str(self.jb2):
world.add.joint(self.jb1[0],self.jb2[0],self.jb1pos,self.jb2pos)
+ # If there's only one body, add a fixed joint
+ elif self.jb2:
+ world.add.joint(self.jb2[0],self.jb2pos)
# regardless, clean everything up
self.jb1 = self.jb2 = self.jb1pos = self.jb2pos = None
def draw(self):
@@ -276,7 +279,7 @@ class DestroyTool(Tool):
world.world.DestroyBody(tokill[0])
# set up pygame
pygame.init()
-size = (900,700)
+size = (700,700)
screen = pygame.display.set_mode(size)
clock = pygame.time.Clock()
font = pygame.font.Font(None, 24) # font object
diff --git a/elements/add_objects.py b/elements/add_objects.py
index b93c479..7954852 100644
--- a/elements/add_objects.py
+++ b/elements/add_objects.py
@@ -476,9 +476,24 @@ class Add:
elif len(args) == 3:
# Revolute Joint
pass
-
+
+ elif len(args) == 2:
+
+ # Revolute Joint to the Background, don't assume the center of the body
+ b1 = self.parent.world.GetGroundBody()
+ b2 = args[0]
+ p1 = self.parent.to_world(args[1])
+ p1x, p1y = p1
+ p1x /= self.parent.ppm
+ p1y /= self.parent.ppm
+ p1 = box2d.b2Vec2(p1x, p1y)
+
+ jointDef = box2d.b2RevoluteJointDef()
+ jointDef.Initialize(b1, b2, p1)
+
+ self.parent.world.CreateJoint(jointDef)
elif len(args) == 1:
- # Revolute Joint to the Background
+ # Revolute Joint to the Background, assume the center of the body
b1 = self.parent.world.GetGroundBody()
b2 = args[0]
p1 = b2.GetWorldCenter()