Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/tools.py
diff options
context:
space:
mode:
authornrp <olpc@spongezone.net>2008-08-31 18:16:44 (GMT)
committer nrp <olpc@spongezone.net>2008-08-31 18:16:44 (GMT)
commitbce2e832c2664e9d5a9f8988da92e6d6f8d4f000 (patch)
tree71168671661c8daedd6280518c7fc5e2c19afe04 /tools.py
parentdf3cce02bb640989714dbdc2b5f2a60c29c7721b (diff)
fixing the bridge error
Diffstat (limited to 'tools.py')
-rw-r--r--tools.py19
1 files changed, 15 insertions, 4 deletions
diff --git a/tools.py b/tools.py
index 68b2c1e..4ad4d46 100644
--- a/tools.py
+++ b/tools.py
@@ -285,12 +285,23 @@ class BridgeJointTool(Tool):
bodies = self.game.world.get_bodies_at_pos(event.pos,
include_static=True)
- if not bodies or len(bodies) != 2:
- print len(bodies)
+ if not bodies or len(bodies) > 2:
return
-
jointDef = box2d.b2RevoluteJointDef()
- jointDef.Initialize(bodies[0], bodies[1], self.to_b2vec(event.pos))
+ if len(bodies) == 1:
+ if not bodies[0].IsStatic():
+ if event.pos[1] > 550 and (event.pos[0] < 350 or event.pos[0] > 850):
+ jointDef.Initialize(self.game.world.world.GetGroundBody(),
+ bodies[0], self.to_b2vec(event.pos))
+ else:
+ if bodies[0].IsStatic():
+ jointDef.Initialize(self.game.world.world.GetGroundBody(),
+ bodies[1], self.to_b2vec(event.pos))
+ elif bodies[1].IsStatic():
+ jointDef.Initialize(self.game.world.world.GetGroundBody(),
+ bodies[0], self.to_b2vec(event.pos))
+ else:
+ jointDef.Initialize(bodies[0], bodies[1], self.to_b2vec(event.pos))
joint = self.game.world.world.CreateJoint(jointDef)
self.game.bridge.joint_added(joint)