Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/physics.py
diff options
context:
space:
mode:
Diffstat (limited to 'physics.py')
-rw-r--r--physics.py25
1 files changed, 16 insertions, 9 deletions
diff --git a/physics.py b/physics.py
index 64e4ae1..f7ef867 100644
--- a/physics.py
+++ b/physics.py
@@ -40,7 +40,8 @@ sys.path.append("lib/")
import pkg_resources
# If your architecture is different, comment these lines and install
# the modules in your system.
-sys.path.append("lib/Elements-0.13-py2.5.egg")
+# Elements is now inside the source itself. No need for the egg.
+# sys.path.append("lib/Elements-0.13-py2.5.egg")
sys.path.append("lib/Box2D-2.0.2b1-py2.5-linux-i686.egg")
import Box2D as box2d
import elements
@@ -136,19 +137,25 @@ class PhysicsGame:
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)
+
+ def to_screen(pos):
+ px = self.world.meter_to_screen(
+ pos[0])
+ py = self.world.meter_to_screen(
+ pos[1])
+ py = self.world.renderer.get_surface() \
+ .get_height() - py
+ return (px, py)
+
+ x = body.position.x
+ y = body.position.y
+ tupled_pos = to_screen((x, y))
posx = tupled_pos[0]
posy = tupled_pos[1]
try:
self.full_pos_list[trackdex].append(posx)
self.full_pos_list[trackdex].append(posy)
- except:
+ except IndexError:
self.full_pos_list.append([posx, posy])
if type(body.userData) == type({}):