diff options
author | asaf <asafpm@gmail.com> | 2009-08-30 05:03:40 (GMT) |
---|---|---|
committer | asaf <asafpm@gmail.com> | 2009-08-30 05:03:40 (GMT) |
commit | dd62508faa74fce1de8302f3bfe3d33358628b7a (patch) | |
tree | c8705cc8d31f650bd2943ac0e8ef53d1550e7ba2 /physics.py | |
parent | 966c461dea92f4899f3020f41d05deb170e5676d (diff) |
Added Paint Tool
Diffstat (limited to 'physics.py')
-rw-r--r-- | physics.py | 19 |
1 files changed, 19 insertions, 0 deletions
@@ -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() |