Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/physics.py
diff options
context:
space:
mode:
authorDaniel Francis <francis@sugarlabs.org>2012-12-21 01:53:07 (GMT)
committer Daniel Francis <francis@sugarlabs.org>2012-12-21 01:53:07 (GMT)
commite447f92baa4727b9fa246f2282f68803ee0e0c69 (patch)
treeaec2811a16712613702aca82e2b4e597a132eecd /physics.py
parentbcf8fc6694df68e0d44b8060dff14878549ae1f4 (diff)
All the files
Signed-off-by: Daniel Francis <francis@sugarlabs.org>
Diffstat (limited to 'physics.py')
-rw-r--r--physics.py42
1 files changed, 19 insertions, 23 deletions
diff --git a/physics.py b/physics.py
index 47eb464..9298e11 100644
--- a/physics.py
+++ b/physics.py
@@ -30,11 +30,12 @@ import math
import pygame
from pygame.locals import *
from pygame.color import *
-import olpcgames
+import sugargame
sys.path.append("lib/")
import pkg_resources
-sys.path.append("lib/Elements-0.13-py2.5.egg")
-sys.path.append("lib/Box2D-2.0.2b1-py2.5-linux-i686.egg")
+# 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")
+#sys.path.append("lib/Box2D-2.0.2b1-py2.5-linux-i686.egg")
import Box2D as box2d
import elements
import tools
@@ -42,11 +43,10 @@ from helpers import *
import gtk
class PhysicsGame:
- def __init__(self, screen):
- self.screen = screen
+ def __init__(self, activity):
# Get everything set up
self.clock = pygame.time.Clock()
- self.canvas = olpcgames.ACTIVITY.canvas
+ self.canvas = activity.canvas
self.in_focus = True
# Create the name --> instance map for components
self.toolList = {}
@@ -55,6 +55,16 @@ class PhysicsGame:
self.currentTool = self.toolList[tools.allTools[0].name]
# Set up the world (instance of Elements)
self.box2d = box2d
+
+ def switch_off_fake_pygame_cursor_cb(self, panel, event):
+ self.show_fake_cursor = False
+
+ def switch_on_fake_pygame_cursor_cb(self, panel, event):
+ self.show_fake_cursor = True
+
+ def run(self):
+ self.screen = pygame.display.get_surface()
+ pygame.display.init()
self.world = elements.Elements(self.screen.get_size())
self.world.renderer.set_surface(self.screen)
@@ -74,13 +84,6 @@ class PhysicsGame:
self.canvas.add_events(gtk.gdk.ENTER_NOTIFY_MASK
| gtk.gdk.LEAVE_NOTIFY_MASK)
- def switch_off_fake_pygame_cursor_cb(self, panel, event):
- self.show_fake_cursor = False
-
- def switch_on_fake_pygame_cursor_cb(self, panel, event):
- self.show_fake_cursor = True
-
- def run(self):
while True:
for event in pygame.event.get():
self.currentTool.handleEvents(event)
@@ -121,16 +124,9 @@ class PhysicsGame:
self.currentTool.cancel()
self.currentTool = self.toolList[tool]
-def main():
- toolbarheight = 75
- tabheight = 45
- pygame.display.init()
- video_info = pygame.display.Info()
- x = video_info.current_w
- y = video_info.current_h
- screen = pygame.display.set_mode((x, y - toolbarheight - tabheight))
- game = PhysicsGame(screen)
- game.run()
+def main(activity):
+ game = PhysicsGame(activity)
+ return game
# Make sure that main get's called
if __name__ == '__main__':