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.py19
1 files changed, 19 insertions, 0 deletions
diff --git a/physics.py b/physics.py
index 5788ff9..86a9809 100644
--- a/physics.py
+++ b/physics.py
@@ -34,6 +34,9 @@ class PhysicsGame:
def __init__(self,screen):
self.screen = screen
# get everything set up
+ self.trace_screen = pygame.Surface(self.screen.get_size())
+ self.trace_screen.fill((255,255,255))
+
self.clock = pygame.time.Clock()
self.font = pygame.font.Font(None, 24) # font object
self.canvas = olpcgames.ACTIVITY.canvas
@@ -73,6 +76,9 @@ class PhysicsGame:
self.currentTool.handleEvents(event)
# Clear Display
self.screen.fill((255,255,255)) #255 for white
+ self.screen.blit(self.trace_screen, (0,0)) #blit on the traces
+
+ #Loop trough objects to apply impulses
if self.world.run_physics:
for body in self.world.world.GetBodyList():
if type(body.userData) == type({}):
@@ -83,6 +89,19 @@ class PhysicsGame:
# Update & Draw World
self.world.update()
self.world.draw()
+
+ #Loop trough objects to draw extra stuff
+ if self.world.run_physics:
+ for body in self.world.world.GetBodyList():
+ if type(body.userData) == type({}):
+ if body.userData.has_key('paint'):
+ color = body.userData['paint']['color']
+ rel_pos = body.GetWorldVector(body.userData['paint']['pos']).tuple()
+ x = (body.GetPosition().tuple()[0]+rel_pos[0])*self.world.ppm
+ y = (body.GetPosition().tuple()[1]+rel_pos[1])*self.world.ppm
+ pos = self.world.to_screen((x,y))
+ pygame.draw.circle(self.trace_screen, color, pos, 2, 0)
+ pygame.draw.circle(self.screen, (255,208,0), pos, 2, 0)
# draw output from tools
self.currentTool.draw()