diff options
Diffstat (limited to 'activity.py')
-rwxr-xr-x | activity.py | 34 |
1 files changed, 21 insertions, 13 deletions
diff --git a/activity.py b/activity.py index 8fc96df..95ff1da 100755 --- a/activity.py +++ b/activity.py @@ -1,12 +1,13 @@ # -*- coding: utf-8 -*- - +import gi import logging -import olpcgames +import sugargame +import sugargame.canvas import pygame from gi.repository import Gtk -from olpcgames import mesh -from olpcgames import util +from sugargame import mesh +from sugargame import util from sugar3.activity.widgets import ActivityToolbarButton from sugar3.activity.widgets import StopButton @@ -15,15 +16,22 @@ from sugar3.graphics.toolbutton import ToolButton from gettext import gettext as _ -class MazeActivity(olpcgames.PyGameActivity): +class MazeActivity(activity.Activity): game_name = 'game' game_title = _('Maze') - game_size = None # Let olpcgames pick a nice size for us + game_size = None # Let sugargame pick a nice size for us def __init__(self, handle): super(MazeActivity, self).__init__(handle) - - # This code was copied from olpcgames.activity.PyGameActivity + # Build the Pygame canvas. + self._canvas = sugargame.canvas.PygameCanvas(self) + self.game = maze.main(self) + self.build_toolbar() + self.set_canvas(self._canvas) + # Start the game running. + self._canvas.run_pygame(self.game.run) + + # This code was copied from sugargame.activity.PyGameActivity def shared_cb(*args, **kwargs): logging.info('shared: %s, %s', args, kwargs) try: @@ -95,9 +103,9 @@ class MazeActivity(olpcgames.PyGameActivity): return toolbar_box def _easier_button_cb(self, button): - pygame.event.post(olpcgames.eventwrap.Event( - pygame.USEREVENT, action='easier_button')) - + pygame.event.post(pygame.event.Event(pygame.USEREVENT, + action="easier_button")) + def _harder_button_cb(self, button): - pygame.event.post(olpcgames.eventwrap.Event( - pygame.USEREVENT, action='harder_button')) + pygame.event.post(pygame.event.Event(pygame.USEREVENT, + action="harder_button")) |