From bce2e832c2664e9d5a9f8988da92e6d6f8d4f000 Mon Sep 17 00:00:00 2001 From: nrp Date: Sun, 31 Aug 2008 18:16:44 +0000 Subject: fixing the bridge error --- (limited to 'tools.py') 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) -- cgit v0.9.1