 
gracias a cierto usario de losersjuegos.com.ar, pude desarrollar "mi primer" script con pygame. el script intro.py es una presentacion minimalistica" (esta bien escrito?) del logo (o marca) de mi "empresa" (xD me da verguenza escribir eso! :p) Dreams to Games que funciona a la perfeccion (intro.py), pero yo pensaba desde un principio hacerla una clase para usarla luego en todos mis juegos que pusiera a disposicion del publico.
el problemita es que lo hice (esta en dreams_to_games.py) pero parece no funcionar (la pantalla queda en negro, de seguro hice algo mal (como buen principiante que soy) pero no se que fue con exactitud o de que manera puedo resolver el problema de mostrar una marca al inicio de un juego haciendo de esta una clase...
en fin, ese es mi problema!
descarga el codigo fuente de aqui d2g.tar.gz (si lo deseas ver trabajando!)
gracias de antemano!
 
  
p.s:
el logo fue hecho en Gimp (que ya venia con mi Ubuntu 9.4
 ) con unas fonts que traia el sistema
) con unas fonts que traia el sistema
(como puedo conseguir mas fonts para ubuntu?)
- Código: Seleccionar todo
- #!/usr/bin/env python
 #
 # dreams_to_games.py (este no trabaja!)
 #
 # Copyright 2009 zboy <zweetboy>
 #
 # 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 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.
 import pygame
 from pygame.locals import *
 class DreamsToGames:
 def __init__(self, pantalla):
 self.titulo = "Dreams to Games Studios"
 #cargamos las imagenes:
 self.logo_minimalistic = pygame.image.load("intro.png").convert()
 self.favicon = pygame.image.load("favicon.png").convert()
 #guardemos una referencia del tamano original de la ventana
 self.dimension_vieja = pantalla.get_size()
 #un reloj para usar el tick()
 self.reloj = pygame.time.Clock()
 
 def screen_setup(self, pantalla):
 if pantalla.get_size() != (800, 600):
 pantalla = pygame.display.set_mode((800, 600))
 pygame.display.set_caption(self.titulo)
 pygame.display.set_icon(self.favicon)
 else:
 pygame.display.set_caption(titulo)
 pygame.display.set_icon(self.favicon)
 
 def show_intro(self, pantalla):
 #iniciamos algunas variables...
 alpha = 0
 maximo = False
 pausa = True
 fin = False
 fillme = pantalla.fill
 #hacemos que la imagen no se vea
 self.logo_minimalistic.set_alpha(alpha)
 
 #ahora iniciamos el bucle while con la parte divertida
 while not fin:
 self.reloj.tick(40)
 key = pygame.key.get_pressed()
 
 for evento in pygame.event.get():
 if evento.type == QUIT:
 pygame.display.set_mode()
 pygame.quit()
 exit()
 if key[K_ESCAPE]:
 #si presiona la tecla <Esc> lo sacara de la intro y
 #le dara el pase al juego para que inicie (aun no hay
 #juego! xD).
 #devolvemos las dimensiones originales a la pantalla
 pygame.display.set_mode(self.dimension_vieja)
 #salgamos del bucle!
 fin = True
 
 fillme((0, 0, 0, 255))
 pantalla.blit(logo_minimalistic, (0,0))
 pygame.display.flip()
 if alpha != 255 and not maximo:
 alpha += 5
 self.logo_minimalistic.set_alpha(alpha)
 else:
 #como ya llego al maximo entonces maximo es True
 maximo = True
 if pausa:
 pygame.time.wait(3000) # con 3 segundos estara bien
 pausa = False # solo una vez por favor ;)
 if maximo:
 if alpha != 0:
 alpha -= 5
 self.logo_minimalistic.set_alpha(alpha)
 else:
 #la presentacion ya termino!
 pygame.time.wait(1500)
 #devolvemos las dimensiones originales a la pantalla
 pygame.display.set_mode(self.dimension_vieja)
 #salgamos del bucle!
 fin = True
 pygame.time.wait(10)
 def main():
 
 import pygame
 from pygame.locals import *
 
 pygame.init()
 #creamos una pantalla con dimension de prueba
 mi_pantalla = pygame.display.set_mode((1024, 768))
 
 # hacemos una instancia de mi clase
 # solo para probar que tal esta mi clase
 d2g = DreamsToGames(mi_pantalla)
 #configuramos la pantalla
 d2g.screen_setup(mi_pantalla)
 #hacemos mostrar el logo de mi compania ficticia
 d2g.show_intro(mi_pantalla)
 if __name__ == '__main__': main()
- Código: Seleccionar todo
- #!/usr/bin/env python
 #
 # intro.py (este si!, pero no es una clase :( )
 #
 # Copyright 2009 zboy <zweetboy>
 #
 # 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 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.
 def main():
 
 import pygame
 from pygame.locals import *
 
 pygame.init()
 pantalla = pygame.display.set_mode((800, 600))
 logo = pygame.image.load("intro.png").convert()
 reloj = pygame.time.Clock()
 alpha = 0
 logo.set_alpha(alpha)
 minimo_a_maximo = False #cuando alpha alcanse 255, comiensa una regresion hasta 0
 pausa = True # una little pausa para que se vea el logo
 
 while True:
 reloj.tick(40)
 key = pygame.key.get_pressed()
 
 for evento in pygame.event.get():
 if evento.type == QUIT:
 pygame.display.set_mode()
 pygame.quit()
 exit()
 if key[K_ESCAPE]:
 pygame.display.set_mode()
 pygame.quit()
 exit()
 if key[K_r]:
 minimo_a_maximo = False
 alpha = 0
 pause = True
 logo.set_alpha(alpha)
 pantalla.fill((0, 0, 0, 255))
 pygame.display.flip()
 pygame.time.wait(2000)
 
 
 pantalla.fill((0, 0, 0, 255))
 pantalla.blit(logo, (0,0))
 pygame.display.flip()
 if alpha != 255 and not minimo_a_maximo:
 alpha += 5
 logo.set_alpha(alpha)
 print "sumando alpha: {0}".format(alpha)
 else:
 minimo_a_maximo = True
 if pausa:
 print "pausa! :D"
 pygame.time.wait(2000) # con cuatro segundos estara bien
 pausa = False # solo una vez por favor ;)
 if minimo_a_maximo:
 if alpha != 0:
 alpha -= 5
 logo.set_alpha(alpha)
 print "restando alpha: {0}".format(alpha)
 else:
 pygame.time.wait(2500)
 pygame.display.set_mode()
 pygame.quit()
 exit()
 pygame.time.wait(10)
 
 if __name__ == '__main__': main()




 . dejame probar a ver que tal...
. dejame probar a ver que tal...
