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.py46
1 files changed, 24 insertions, 22 deletions
diff --git a/physics.py b/physics.py
index bf95a93..3dd5060 100644
--- a/physics.py
+++ b/physics.py
@@ -78,32 +78,34 @@ class PhysicsGame:
self.show_fake_cursor = True
def run(self):
+ self.in_focus = True
while True:
for event in pygame.event.get():
self.currentTool.handleEvents(event)
- # Drive motors
- if self.world.run_physics:
- for body in self.world.world.GetBodyList():
- if type(body.userData) == type({}):
- if body.userData.has_key('rollMotor'):
- diff = body.userData['rollMotor']['targetVelocity'] - body.GetAngularVelocity()
- body.ApplyTorque(body.userData['rollMotor']['strength'] * diff * body.getMassData().I)
-
- # Update & Draw World
- self.world.update()
- self.screen.fill((255, 255, 255)) # 255 for white
- self.world.draw()
-
- # Draw output from tools
- self.currentTool.draw()
-
- # Show Sugar like cursor for UI consistancy
- if self.show_fake_cursor:
- self.screen.blit(self.cursor_picture, pygame.mouse.get_pos())
-
- # Flip Display
- pygame.display.flip()
+ if self.in_focus:
+ # Drive motors
+ if self.world.run_physics:
+ for body in self.world.world.GetBodyList():
+ if type(body.userData) == type({}):
+ if body.userData.has_key('rollMotor'):
+ diff = body.userData['rollMotor']['targetVelocity'] - body.GetAngularVelocity()
+ body.ApplyTorque(body.userData['rollMotor']['strength'] * diff * body.getMassData().I)
+
+ # Update & Draw World
+ self.world.update()
+ self.screen.fill((255, 255, 255)) # 255 for white
+ self.world.draw()
+
+ # Draw output from tools
+ self.currentTool.draw()
+
+ # Show Sugar like cursor for UI consistancy
+ if self.show_fake_cursor:
+ self.screen.blit(self.cursor_picture, pygame.mouse.get_pos())
+
+ # Flip Display
+ pygame.display.flip()
# Stay under 30 FPS to help keep the rest of the platform responsive
self.clock.tick(30) # Originally 50