From c9e6791dcb3cdbfc8aa26ae018ec3908b1b1391b Mon Sep 17 00:00:00 2001 From: Toaster Date: Sun, 08 Jul 2012 06:23:34 +0000 Subject: Preliminary work to get the activity running on 0.96 --- diff --git a/activity.py b/activity.py index 38389da..9d01613 100644 --- a/activity.py +++ b/activity.py @@ -22,7 +22,7 @@ License: GPLv3 http://gplv3.fsf.org/ import tools # provides all of the code to implement a game activity -import olpcgames +import olpcgamesbridge as olpcgames import pygame # provides the classes from sugar @@ -56,7 +56,8 @@ class BridgeActivity(olpcgames.PyGameActivity): game_title = 'Bridge' game_size = None # olpcgame will choose size - def __init__(self): + def __init__(self, handle): + super(BridgeActivity, self).__init__(handle) self.blocklist = [] self.radiolist = {} diff --git a/activity/activity.info b/activity/activity.info index 5657ba7..e77ad5a 100755 --- a/activity/activity.info +++ b/activity/activity.info @@ -28,3 +28,6 @@ activity_version = 3 # The following line indicates whether to show the launcher icon # in the Sugar main icon display show_launcher = yes + +exec = sugar-activity activity.BridgeActivity + diff --git a/physics.py b/physics.py index a3be7ef..0c60371 100644 --- a/physics.py +++ b/physics.py @@ -26,15 +26,16 @@ License: GPLv3 http://gplv3.fsf.org/ import pygame from pygame.locals import * from pygame.color import * -import olpcgames +import olpcgamesbridge as olpcgames -import elements +import elementsbridge as elements #from elements import Elements import tools from bridge import Bridge #from helpers import * from gettext import gettext as _ +import gtk class PhysicsGame: """ @@ -51,7 +52,13 @@ class PhysicsGame: # get everything set up self.clock = pygame.time.Clock() self.font = pygame.font.Font(None, 24) # font object - self.canvas = olpcgames.ACTIVITY.canvas # canvas object + try: + self.canvas = olpcgames.ACTIVITY.canvas # canvas object + except: + from olpcgamesbridge.canvas import PygameCanvas + xsize, ysize = pygame.display.list_modes()[0] + self.canvas = PygameCanvas(xsize, ysize-45-75) + self.joystickobject = None # TODO Figure out why this exists self.debug = True # TODO Figure out what this does @@ -86,7 +93,7 @@ class PhysicsGame: for event in pygame.event.get(): # Handles events like button clicks - self.currenttool.handleEvents(event) + self.currenttool.handleevents(event) # Clear Display self.screen.fill((80, 160, 240)) #255 for white diff --git a/tools.py b/tools.py index b44ce28..0b3aad2 100644 --- a/tools.py +++ b/tools.py @@ -20,7 +20,7 @@ License: GPLv3 http://gplv3.fsf.org/ """ import pygame -from elements import box2d +from elementsbridge import box2d from pygame.locals import * from helpers import * from inspect import getmro @@ -50,9 +50,9 @@ class Tool(object): name = "Tool" icon = "icon" toolTip = "Tool Tip" - def __init__(self, gameinstance): - self.game = gameinstance - self.name = "Tool" + #def __init__(self, gameinstance): + # self.game = gameinstance + # self.name = "Tool" def handleevents(self, event): """Default method of Handling events @@ -120,6 +120,7 @@ class CircleTool(Tool): def __init__(self, gameinstance): Tool.__init__(gameinstance) + self.game = gameinstance self.name = "Circle" self.pt1 = None self.radius = None @@ -128,7 +129,7 @@ class CircleTool(Tool): """ # look for default events, and if none are handled then # try the custom events - if not super(CircleTool, self).handleEvents(event): + if not super(CircleTool, self).handleevents(event): if event.type == MOUSEBUTTONDOWN: if event.button == 1: self.pt1 = pygame.mouse.get_pos() @@ -167,6 +168,7 @@ class GirderTool(Tool): def __init__(self, gameinstance): Tool.__init__(gameinstance) + self.game = gameinstance self.name = "Girder" # TODO was "box", why? self.pt1 = None self.pt2 = None @@ -184,7 +186,7 @@ class GirderTool(Tool): """ # look for default events, and if none are handled then # try the custom events - if not super(GirderTool, self).handleEvents(event): + if not super(GirderTool, self).handleevents(event): if event.type == MOUSEBUTTONDOWN: if event.button == 1: self.pt1 = pygame.mouse.get_pos() @@ -241,6 +243,7 @@ class GrabTool(Tool): def __init__(self, gameinstance): Tool.__init__(gameinstance) + self.game = gameinstance self.name = "Grab" def handleevents(self, event): @@ -248,7 +251,7 @@ class GrabTool(Tool): """ # look for default events, and if none are handled then # try the custom events - if not super(GrabTool, self).handleEvents(event): + if not super(GrabTool, self).handleevents(event): if event.type == MOUSEBUTTONDOWN: if event.button == 1: # grab the first object at the mouse pointer @@ -281,6 +284,7 @@ class DestroyTool(Tool): def __init__(self, gameinstance): Tool.__init__(gameinstance) + self.game = gameinstance self.name = "Destroy" self.vertices = None def handleevents(self, event): @@ -289,7 +293,7 @@ class DestroyTool(Tool): """ # look for default events, and if none are handled then try # the custom events - if not super(DestroyTool, self).handleEvents(event): + if not super(DestroyTool, self).handleevents(event): if pygame.mouse.get_pressed()[0]: if not self.vertices: self.vertices = [] @@ -332,6 +336,7 @@ class BridgeJointTool(Tool): def __init__(self, gameinstance): Tool.__init__(gameinstance) + self.game = gameinstance self.name = "Bridge Joint" self.jb1 = self.jb2 = self.jb1pos = self.jb2pos = None @@ -341,7 +346,7 @@ class BridgeJointTool(Tool): """ # look for default events, and if none are handled then try # the custom events - if super(BridgeJointTool, self).handleEvents(event): + if super(BridgeJointTool, self).handleevents(event): return if event.type != MOUSEBUTTONUP or event.button != 1: return -- cgit v0.9.1