diff options
author | Seth Woodworth <seth@isforinsects.com> | 2010-02-17 20:23:33 (GMT) |
---|---|---|
committer | Seth Woodworth <seth@isforinsects.com> | 2010-02-17 20:23:33 (GMT) |
commit | 0b53b220363b1ce59f9b5e6af16aa5a0ea58afb0 (patch) | |
tree | 399b497728f0c3dbda6ce5dbeacc6cf0b3765aa3 /physics.py | |
parent | eaa86109dfa899534e354fac7f517caad539ec2f (diff) | |
parent | dd62508faa74fce1de8302f3bfe3d33358628b7a (diff) |
Conflicts:
physics.py
Diffstat (limited to 'physics.py')
-rw-r--r-- | physics.py | 26 |
1 files changed, 25 insertions, 1 deletions
@@ -30,7 +30,15 @@ from helpers import * import gtk class PhysicsGame: - def __init__(self): + 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 # create the name --> instance map for components self.toolList = {} for c in tools.allTools: @@ -82,6 +90,9 @@ class PhysicsGame: # 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({}): @@ -92,6 +103,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() |