From ade073bbfbba5e8ffc26a175b6d1a80d40a6ccf0 Mon Sep 17 00:00:00 2001 From: Alan Aguiar Date: Mon, 12 Aug 2013 22:43:59 +0000 Subject: fixes for sugar activity --- diff --git a/.gitignore b/.gitignore index bc4c0af..fece0f5 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,7 @@ *.pyc *.py~ *.pyo +*.xo .project .pydevproject .settings diff --git a/EdSexual.activity/Main.py b/EdSexual.activity/Main.py new file mode 120000 index 0000000..0c2c64d --- /dev/null +++ b/EdSexual.activity/Main.py @@ -0,0 +1 @@ +../src/Main.py \ No newline at end of file diff --git a/EdSexual.activity/activity.py b/EdSexual.activity/activity.py new file mode 100755 index 0000000..2217c52 --- /dev/null +++ b/EdSexual.activity/activity.py @@ -0,0 +1,28 @@ +#! /usr/bin/env python +# -*- coding: utf-8 -*- + +import sugargame +import sugargame.canvas +from sugar.activity import activity + +import Main + +class Activity(activity.Activity): + + def __init__(self, handle): + activity.Activity.__init__(self, handle) + + self.max_participants = 1 + self.actividad = Main.EdSexualGame() + self._pygamecanvas = sugargame.canvas.PygameCanvas(self) + self.set_canvas(self._pygamecanvas) + self._pygamecanvas.grab_focus() + self._pygamecanvas.run_pygame(self.actividad.main) + print 'saliendo' + + def read_file(self, file_path): + pass + + def write_file(self, file_path): + pass + diff --git a/EdSexual.activity/activity/activity.info b/EdSexual.activity/activity/activity.info new file mode 100644 index 0000000..db31fa6 --- /dev/null +++ b/EdSexual.activity/activity/activity.info @@ -0,0 +1,8 @@ +[Activity] +name = Educacion Sexual +activity_version = 1 +bundle_id = org.ceibaljam.edsexual +icon = edsexual +exec = sugar-activity activity.Activity +license = GPLv3 +summary = Game about Sexual Education diff --git a/EdSexual.activity/activity/edsexual.svg b/EdSexual.activity/activity/edsexual.svg new file mode 100644 index 0000000..1bbdbe7 --- /dev/null +++ b/EdSexual.activity/activity/edsexual.svg @@ -0,0 +1,93 @@ + + + + + + + + + + + + + image/svg+xml + + + + + + + + + + diff --git a/EdSexual.activity/api b/EdSexual.activity/api new file mode 120000 index 0000000..e839c85 --- /dev/null +++ b/EdSexual.activity/api @@ -0,0 +1 @@ +../src/api \ No newline at end of file diff --git a/EdSexual.activity/assets b/EdSexual.activity/assets new file mode 120000 index 0000000..2121391 --- /dev/null +++ b/EdSexual.activity/assets @@ -0,0 +1 @@ +../src/assets/ \ No newline at end of file diff --git a/EdSexual.activity/game b/EdSexual.activity/game new file mode 120000 index 0000000..71d12c9 --- /dev/null +++ b/EdSexual.activity/game @@ -0,0 +1 @@ +../src/game/ \ No newline at end of file diff --git a/EdSexual.activity/setup.py b/EdSexual.activity/setup.py new file mode 100755 index 0000000..da6bc28 --- /dev/null +++ b/EdSexual.activity/setup.py @@ -0,0 +1,6 @@ +#! /usr/bin/env python +# -*- coding: utf-8 -*- + +from sugar.activity import bundlebuilder +if __name__ == "__main__": + bundlebuilder.start() diff --git a/src/sugargame/__init__.py b/EdSexual.activity/sugargame/__init__.py index 439eb0c..439eb0c 100755 --- a/src/sugargame/__init__.py +++ b/EdSexual.activity/sugargame/__init__.py diff --git a/src/sugargame/canvas.py b/EdSexual.activity/sugargame/canvas.py index 980cb73..980cb73 100755 --- a/src/sugargame/canvas.py +++ b/EdSexual.activity/sugargame/canvas.py diff --git a/src/sugargame/event.py b/EdSexual.activity/sugargame/event.py index 4cc3be8..4cc3be8 100755 --- a/src/sugargame/event.py +++ b/EdSexual.activity/sugargame/event.py diff --git a/build.sh b/build.sh new file mode 100755 index 0000000..6c3f530 --- /dev/null +++ b/build.sh @@ -0,0 +1,21 @@ +#!/bin/bash + +CURRDIR=`pwd` + +rm -rf /tmp/staging +rm -rf *.xo +mkdir /tmp/staging + +cp -Lr EdSexual.activity -t /tmp/staging + +cd /tmp/staging/EdSexual.activity +rm -rf locale +git init +git add * +git commit -m 'all files' +python setup.py build +python setup.py dist_xo + +cd $CURRDIR +mv /tmp/staging/EdSexual.activity/dist/*.xo . + diff --git a/src/Main.py b/src/Main.py index 51d45b3..c069b64 100755 --- a/src/Main.py +++ b/src/Main.py @@ -7,15 +7,21 @@ from game.MenuState import CMenuState import api.Game from api.Game import CGame -def main(): +class EdSexualGame(): - g = CGame() + def __init__(self): + pass - ms = CMenuState() - g.setState(ms) - - g.gameLoop() - g.destroy() + def main(self): + + g = CGame() + + ms = CMenuState() + g.setState(ms) + + g.gameLoop() + g.destroy() if __name__ == "__main__": - main() \ No newline at end of file + j = EdSexualGame() + j.main() \ No newline at end of file diff --git a/src/api/Button.py b/src/api/Button.py index c16855f..2bf33a5 100755 --- a/src/api/Button.py +++ b/src/api/Button.py @@ -38,7 +38,7 @@ class CButton(CLabel): #check for mouse input self.mclicked = False - + if CMouse().firstPress(): if self.rect.collidepoint(CMouse().getPos()): print("first press in button") diff --git a/src/api/Game.py b/src/api/Game.py index 071edb7..d3f181c 100755 --- a/src/api/Game.py +++ b/src/api/Game.py @@ -73,17 +73,19 @@ class CGame(object): def init(self): print "init pygame..." pygame.init() + #pygame.display.init() #pygame.font.init() - #screen = pygame.display.set_mode((1200, 900), FULLSCREEN) - self.mScreen = pygame.display.set_mode((1200, 900)) + self.mScreen = pygame.display.get_surface() + if not(self.mScreen): + self.mScreen = pygame.display.set_mode((1200, 900)) pygame.display.set_caption(_('Game')) self.mBackground = pygame.Surface(self.mScreen.get_size()) self.mBackground.fill((255, 0, 0)) # Sound system initialization. - pygame.mixer.init() + #pygame.mixer.init() #self.mAllSprites = pygame.sprite.Group() Sprites = [] @@ -103,9 +105,6 @@ class CGame(object): print "start game loop here" while not self.mQuit: - self.mClock.tick(30) - #print ("FPS: %.0f" % self.mClock.get_fps()) - while gtk.events_pending(): gtk.main_iteration() @@ -120,7 +119,7 @@ class CGame(object): self.mMouse.update() self.mMousePointerSprite.setXY(self.mMouse.getX(), self.mMouse.getY()) - + #self.mState.preUpdate() self.mState.update() @@ -136,6 +135,8 @@ class CGame(object): #self.mState.postUpdate() pygame.display.flip() + self.mClock.tick(30) + #print ("FPS: %.0f" % self.mClock.get_fps()) def doEvents(self, event): """ overwrite this method to add your own events. diff --git a/src/api/Mouse.py b/src/api/Mouse.py index bf0e0c8..ba34eb6 100755 --- a/src/api/Mouse.py +++ b/src/api/Mouse.py @@ -43,10 +43,10 @@ class CMouse(object): return self.mPressed def firstPress(self): - return self.pressed() and not self.mPrevPressed + return (self.mPressed and not self.mPrevPressed) def release(self): - return not self.pressed() and self.mPrevPressed + return (not(self.mPressed) and self.mPrevPressed) def update(self): #print("mouse update") @@ -54,7 +54,8 @@ class CMouse(object): #print("y=" + str(self.getY())) self.mPrevPressed = self.mPressed; - self.mPressed = (pygame.mouse.get_pressed() == (1, 0, 0)) + pp = pygame.mouse.get_pressed() + self.mPressed = (pp[0] == 1 and pp[1] == 0 and pp[2] == 0) def destroy(self): self.mInstance = None -- cgit v0.9.1