-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
268 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
Flavio Danesse [email protected] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,14 @@ | ||
Copyright (C) <Año> <Autor> | ||
|
||
This program is free software; you can redistribute it and/or | ||
modify it under the terms of the GNU General Public License | ||
as published by the Free Software Foundation; either version 2 | ||
of the License, or (at your option) any later version. | ||
This program is free software: you can redistribute it and/or modify | ||
it under the terms of the GNU General Public License as published by | ||
the Free Software Foundation, either version 3 of the License, or | ||
(at your option) any later version. | ||
|
||
This program is distributed in the hope that it will be useful, | ||
but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
GNU General Public License for more details. | ||
|
||
You should have received a copy of the GNU General Public License | ||
along with this program; if not, write to the Free Software | ||
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | ||
along with this program. If not, see <http://www.gnu.org/licenses/>. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,176 @@ | ||
#!/usr/bin/env python | ||
# -*- coding: utf-8 -*- | ||
|
||
# SugarBichos.py por: | ||
# Flavio Danesse <[email protected]> | ||
# Uruguay | ||
|
||
import os | ||
import sys | ||
import gtk | ||
import gobject | ||
|
||
from sugar.activity.activity import Activity | ||
|
||
from EventTraductor.EventTraductor import KeyPressTraduce | ||
from EventTraductor.EventTraductor import KeyReleaseTraduce | ||
|
||
from Intro.Intro import Intro | ||
from Widgets import Escenario | ||
from CantaBichos.CantaBichos import CantaBichos | ||
from CucaraSims.CucaraSims import CucaraSimsWidget | ||
from CucaraSims.Juego import CucaraSims | ||
from OjosCompuestos.OjosCompuestos import OjosCompuestos | ||
|
||
|
||
class Bichos(Activity): | ||
|
||
def __init__(self, handle): | ||
|
||
Activity.__init__(self, handle) | ||
|
||
self.set_title("Bichos") | ||
self.modify_bg(gtk.STATE_NORMAL, gtk.gdk.color_parse("#000000")) | ||
#self.set_icon_from_file(os.path.join(BASE, "Iconos", "bichos.svg")) | ||
self.set_resizable(True) | ||
self.set_size_request(640, 480) | ||
self.set_position(gtk.WIN_POS_CENTER) | ||
|
||
self.juego = False | ||
self.widgetjuego = False | ||
|
||
self.connect("key-press-event", self.__key_press_even) | ||
self.connect("key-release-event", self.__key_release_even) | ||
|
||
self.connect("delete-event", self.__salir) | ||
self.connect("realize", self.__do_realize) | ||
|
||
self.show_all() | ||
|
||
def __key_press_even(self, widget, event): | ||
if self.juego: | ||
KeyPressTraduce(event) | ||
else: | ||
if gtk.gdk.keyval_name(event.keyval) == "Escape": | ||
self.widgetjuego.salir() | ||
self.switch(False, 1) | ||
return False | ||
|
||
def __key_release_even(self, widget, event): | ||
if self.juego: | ||
KeyReleaseTraduce(event) | ||
return False | ||
|
||
def __do_realize(self, widget): | ||
self.switch(False, 1) | ||
|
||
def __salir(self, widget=None, event=None): | ||
sys.exit(0) | ||
|
||
def __redraw(self, widget, size): | ||
if self.juego: | ||
self.juego.escalar(size) | ||
|
||
def __run_intro(self, escenario): | ||
xid = escenario.get_property('window').xid | ||
os.putenv('SDL_WINDOWID', str(xid)) | ||
self.juego = Intro() | ||
self.juego.connect("exit", self.__salir) | ||
self.juego.connect("go", self.__run_games) | ||
self.juego.config() | ||
self.juego.run() | ||
return False | ||
|
||
def __run_cucarasims(self, escenario): | ||
xid = escenario.get_property('window').xid | ||
os.putenv('SDL_WINDOWID', str(xid)) | ||
self.juego = CucaraSims() | ||
self.widgetjuego.connect("set-cursor", self.juego.set_cursor) | ||
self.widgetjuego.connect("exit", self.__dialog_exit_game, "CucaraSims") | ||
self.widgetjuego.connect("volumen", self.juego.set_volumen) | ||
self.juego.connect("exit", self.__dialog_exit_game, "CucaraSims") | ||
self.juego.connect("lectura", self.widgetjuego.run_lectura) | ||
self.juego.connect("clear-cursor-gtk", self.widgetjuego.clear_cursor) | ||
self.juego.connect("update", self.widgetjuego.update) | ||
self.juego.connect("puntos", self.widgetjuego.puntos) | ||
self.juego.config() | ||
self.juego.run() | ||
return False | ||
|
||
def __dialog_exit_game(self, widget, juego_name): | ||
self.juego.pause() | ||
dialog = gtk.Dialog(parent=self, | ||
buttons=("Salir", gtk.RESPONSE_ACCEPT, | ||
"Cancelar", gtk.RESPONSE_CANCEL)) | ||
dialog.modify_bg(gtk.STATE_NORMAL, gtk.gdk.color_parse("#ffffff")) | ||
label = gtk.Label("Salir de %s" % juego_name) | ||
label.show() | ||
dialog.set_border_width(10) | ||
dialog.vbox.pack_start(label, True, True, 0) | ||
resp = dialog.run() | ||
dialog.destroy() | ||
if resp == gtk.RESPONSE_ACCEPT: | ||
self.__run_games(False, "menu") | ||
return | ||
self.juego.unpause() | ||
|
||
def __mouse_enter(self, widget, valor): | ||
""" | ||
Cuando el mouse entra o sale del drawing donde dibuja pygame, setea | ||
el cursor para que no siga en pantalla en pygame si el mouse está fuera | ||
""" | ||
if self.juego and not valor: | ||
self.juego.set_cursor(False, False) | ||
elif self.juego and valor: | ||
self.juego.set_cursor(False, self.widgetjuego.cursor_tipo) | ||
|
||
def __run_games(self, intro, game): | ||
if self.juego: | ||
self.juego.salir() | ||
del(self.juego) | ||
self.juego = False | ||
self.queue_draw() | ||
if game == "menu": | ||
self.switch(False, 1) | ||
elif game == "cucarasims": | ||
self.switch(False, 2) | ||
elif game == "cantores": | ||
self.switch(False, 3) | ||
elif game == "ojos": | ||
self.switch(False, 4) | ||
|
||
def switch(self, widget, valor): | ||
for child in self.get_children(): | ||
self.remove(child) | ||
child.destroy() | ||
self.modify_bg(gtk.STATE_NORMAL, gtk.gdk.color_parse("#000000")) | ||
|
||
if valor == 1: | ||
self.widgetjuego = Escenario() | ||
self.widgetjuego.connect("new-size", self.__redraw) | ||
self.set_canvas(self.widgetjuego) | ||
gobject.idle_add(self.__run_intro, self.widgetjuego) | ||
|
||
elif valor == 2: | ||
self.modify_bg(gtk.STATE_NORMAL, gtk.gdk.color_parse("#ffffff")) | ||
escenario = Escenario() | ||
escenario.modify_bg( | ||
gtk.STATE_NORMAL, gtk.gdk.color_parse("#000000")) | ||
escenario.connect("new-size", self.__redraw) | ||
escenario.connect("mouse-enter", self.__mouse_enter) | ||
self.widgetjuego = CucaraSimsWidget(escenario) | ||
self.set_canvas(self.widgetjuego) | ||
gobject.idle_add(self.__run_cucarasims, escenario) | ||
|
||
elif valor == 3: | ||
self.modify_bg(gtk.STATE_NORMAL, gtk.gdk.color_parse("#ffffff")) | ||
self.widgetjuego = CantaBichos() | ||
self.set_canvas(self.widgetjuego) | ||
|
||
elif valor == 4: | ||
self.modify_bg(gtk.STATE_NORMAL, gtk.gdk.color_parse("#ffffff")) | ||
escenario = Escenario() | ||
escenario.modify_bg( | ||
gtk.STATE_NORMAL, gtk.gdk.color_parse("#000000")) | ||
self.widgetjuego = OjosCompuestos(escenario) | ||
self.set_canvas(self.widgetjuego) |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
[Activity] | ||
name = Bichos | ||
bundle_id = org.laptop.Bichos | ||
exec = sugar-activity SugarBichos.Bichos | ||
icon = Bichos | ||
activity_version = 1 | ||
show_launcher = yes |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,17 @@ | ||
{ | ||
"autores":[ | ||
[ | ||
"", | ||
"" | ||
"Flavio Danesse", | ||
"[email protected]" | ||
] | ||
], | ||
"categoria":"", | ||
"descripcion":"", | ||
"licencia":"GPL2", | ||
"licencia":"GPL3", | ||
"main":"Main.py", | ||
"mimetypes":"", | ||
"nombre":"Bichos", | ||
"path":"/home/flavio/BatovideWorkSpace/Bichos", | ||
"url":"", | ||
"version":"0.0.1" | ||
"version":"1.0.0" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
#!/usr/bin/python | ||
# -*- coding: utf-8 -*- | ||
|
||
from sugar.activity import bundlebuilder | ||
bundlebuilder.start() |