import pygame import gtk import os import imp from gettext import gettext as _ import time import sys #constantes EVENTORESPUESTA = pygame.USEREVENT+1 EVENTODESPEGUE = EVENTORESPUESTA+1 EVENTOREFRESCO = EVENTODESPEGUE+1 TIEMPOREFRESCO = 250 CAMINORECURSOS = "recursos" CAMINOCOMUN = "comun" CAMINOIMAGENES = "imagenes" CAMINODATOS = "datos" CAMINOFUENTES = "fuentes" clock = pygame.time.Clock() def wait_events(): """ Funcion para esperar por eventos de pygame sin consumir CPU """ global clock clock.tick(20) return pygame.event.get() class YoButia(): def __init__(self): pass def principal(self): print "Clase principal" #Aca va el loop principal del juego. global scale, shift_x, shift_y pygame.time.set_timer(EVENTOREFRESCO,TIEMPOREFRESCO) self.loadAll() self.loadCommons() self.presentacion() time.sleep(2) #Main principal del juego while 1: self.pantallaInicial() time.sleep(2) def presentacion(self): self.pantalla.fill((0,0,0)) self.pantalla.blit(self.fondo1, (int(75*scale+shift_x),int(75*scale+shift_y))) self.mostrarTexto(_("Presione una tecla para continuar"), self.fuente32, (int(600*scale+shift_x),int(800*scale+shift_y)), (255,155,155)) pygame.display.flip() def mostrarTexto(self,texto,fuente,posicion,color): """Muestra texto en una determinada posicion""" text = fuente.render(texto, 1, color) textrect = text.get_rect() textrect.center = posicion self.pantalla.blit(text, textrect) def loadAll(self): #Metodo que carga las imagenes y sonidos global scale, shift_x, shift_y, xo_resolution pygame.init() pygame.display.init() # crear pantalla self.anchoPantalla = gtk.gdk.screen_width() self.altoPantalla = gtk.gdk.screen_height() self.pantalla = pygame.display.get_surface() if not(self.pantalla): # prevent hide zones self.anchoPantalla = self.anchoPantalla - 50 self.altoPantalla = self.altoPantalla - 100 self.pantalla = pygame.display.set_mode((self.anchoPantalla, self.altoPantalla)) pygame.display.flip() if self.anchoPantalla==1200 and self.altoPantalla==900: xo_resolution = True scale = 1 shift_x = 0 shift_y = 0 else: xo_resolution = False if self.anchoPantalla/1200.0