diff options
Diffstat (limited to 'physics.py')
-rw-r--r-- | physics.py | 21 |
1 files changed, 21 insertions, 0 deletions
@@ -66,6 +66,9 @@ class PhysicsGame: self.loop = True self.pygame_started = False + self.full_pos_list = [] + self.tracked_bodies = [] + def switch_off_fake_pygame_cursor_cb(self, panel, event): self.show_fake_cursor = False @@ -131,6 +134,24 @@ class PhysicsGame: if self.world.run_physics: for body in self.world.world.GetBodyList(): if type(body.userData) == type({}): + if body.userData.has_key('track_index'): + trackdex = body.userData['track_index'] + + def round_to_3(n): + return math.ceil(n * 1000) / 1000.0 + + roundx = round_to_3(body.position.x) + roundy = round_to_3(body.position.y) + tupled_pos = (roundx, roundy) + posx = tupled_pos[0] + posy = tupled_pos[1] + try: + self.full_pos_list[trackdex].append(posx) + self.full_pos_list[trackdex].append(posy) + except: + self.full_pos_list.append([posx, posy]) + + if type(body.userData) == type({}): if body.userData.has_key('rollMotor'): diff = body.userData['rollMotor'] \ ['targetVelocity'] \ |