Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/bridge.py
diff options
context:
space:
mode:
Diffstat (limited to 'bridge.py')
-rw-r--r--bridge.py25
1 files changed, 12 insertions, 13 deletions
diff --git a/bridge.py b/bridge.py
index 4f7eb79..63d793d 100644
--- a/bridge.py
+++ b/bridge.py
@@ -57,25 +57,24 @@ class Bridge:
def for_each_frame(self):
self.stress = 0
joint = self.world.world.GetJointList()
- going = True
- while going:
- if joint.GetType() == 1:
- if joint.asRevoluteJoint().IsMotorEnabled() == False:
- force = joint.GetReactionForce().Length()
+ for j in joint:
+ try:
+ if j.IsMotorEnabled() == False:
+ force = j.GetReactionForce(30).Length()
self.stress += force
if force > 500:
print "destroy joint!"
- self.world.world.DestroyJoint(joint)
+ self.world.world.DestroyJoint(j)
self.capacity -= 500
else:
- vec = joint.GetAnchor1()
- coord = int(self.world.meter_to_screen(vec.x)),int(780 - self.world.meter_to_screen(vec.y))
- pygame.draw.circle(self.screen, (int(force/2),255-int(force/2),0), coord, 4)
- if joint.GetNext():
- joint = joint.GetNext()
- else:
- going = False
+ vec = j.GetAnchor1()
+ coord = int(self.world.meter_to_screen(vec.x)), \
+ int(780 - self.world.meter_to_screen(vec.y))
+ pygame.draw.circle(self.screen, (int(force/2),
+ 255-int(force/2),0), coord, 4)
+ except AttributeError:
+ print "*** hit an AttributeError", j
pos = self.first_train.GetPosition()
if pos.x > 14.0:
if not self.level_completed: