Ver Mensaje Individual
  #2 (permalink)  
Antiguo 20/05/2010, 12:56
Avatar de pato12
pato12
 
Fecha de Ingreso: septiembre-2007
Ubicación: Salta
Mensajes: 1.620
Antigüedad: 16 años, 6 meses
Puntos: 101
Respuesta: [APORTE] Un juego

Código Python:
Ver original
  1. ####################################
  2.           _key_move=''
  3.                  
  4.                  
  5.           pintar_fondo_default()
  6.           screen.blit(barra_datos,(0,520))
  7.          
  8.           _vida_x=800
  9.          
  10.           for vt in range(0,_vidas):
  11.               _vida_x=_vida_x-15
  12.               screen.blit(vida_srf,(_vida_x,550))
  13.          
  14.           #######################################
  15.           _ladrillo_x=0
  16.           _ladrillo_y=0
  17.           __color_l=_ladrillo1
  18.           _ladrillost_totales=0
  19.           for i1 in range(0,100/10):
  20.              for i2 in range(0,10):
  21.                 if mapas[_nivel_game-1][(10*i1)+i2] != 0:
  22.                    _ladrillost_totales=_ladrillost_totales+1
  23.                    _ladrillo_x=i1*80
  24.                    _ladrillo_y=i2*20
  25.                    __color_l=mascaras_ladrrillos[mapas[_nivel_game-1][(10*i1)+i2]]
  26.                    if _y_b > _ladrillo_y and _y_b < (_ladrillo_y+20):
  27.                       if _x_b > _ladrillo_x and _x_b < (_ladrillo_x+80):
  28.                          mapas[_nivel_game-1][(10*i1)+i2]=0
  29.                          if _y_b < (_ladrillo_y+10) and _y_b > _ladrillo_y:
  30.                             _bola_sube=True
  31.                          else:
  32.                             _bola_sube=False
  33.                          _puntos_game=_puntos_game+30
  34.  
  35.                    screen.blit(__color_l,(_ladrillo_x,_ladrillo_y))
  36.           #######################################
  37.          
  38.           if _ladrillost_totales == 0:
  39.              _nivel_game=_nivel_game+1
  40.              _empezo_game_mover=False
  41.              _y_b=485
  42.              _x_b=450
  43.              __x=352
  44.              __angulo=0
  45.              _bola_sube=True
  46.              if _nivel_game > len(mapas):
  47.                 _game=0
  48.                 ganar_juego_completo(_puntos_game)
  49.          
  50.          
  51.           escribir_game('Puntos: '+str(_puntos_game),20,(0,0,0),10,530)
  52.          
  53.           escribir_game('Nivel: '+str(_nivel_game)+' de '+str(len(mapas)),20,(0,0,0),10,555)
  54.          
  55.          
  56.           escribir_game("Presione \"m\" para volver al menu principal.",15,(100,100,100),250,560)
  57.          
  58.          
  59.           screen.blit(bola_srf, (_x_b, _y_b))
  60.           screen.blit(barra_srf, ( __x, 500))
  61.           if _pausa:
  62.              escribir_game("PAUSA",30,(255,255,0),400,200)
  63.          
  64.  
  65.                
  66.           pygame.display.flip()
  67.  
  68.  
  69.  
  70.  
  71. ####################################################
  72. def main_game_over(puntos):
  73.     _bluce_principal=1
  74.     titulo_img = load_image('img/titulo.png',-1)
  75.     SpriteSheet_titulos = SpriteSheet('img/titulos.png')
  76.     cartel_perdiste = SpriteSheet_titulos.imgat((0,0,330,35),-1)
  77.  
  78.     pintar_fondo_default()  
  79.     screen.blit(titulo_img, (30,50))
  80.     screen.blit(cartel_perdiste, (450,75) )
  81.          
  82.     escribir_game('Perdiste, hiciste '+str(puntos)+' puntos en total.',30,(255,255,255),30,150)
  83.          
  84.     __n_numeros=0
  85.     _nombre=''
  86.     escribir_game('Ahora escribe tu nombre: ',30,(255,255,255),30,210)
  87.          
  88.     pygame.display.flip()
  89.          
  90.     _si=False
  91.     while not _si:
  92.           for event in pygame.event.get():
  93.               for ast in event.dict:
  94.                   if ast == 'unicode':
  95.                      __n_numeros=__n_numeros+1
  96.                      _nombre=_nombre+str(event.unicode)
  97.                      escribir_game(str(event.unicode),30,(255,255,255),380+(__n_numeros*15),210)
  98.                      if __n_numeros>=4:
  99.                         _si=True
  100.                         break
  101.                      pygame.display.flip()
  102.    
  103.     _si=True
  104.    
  105.     cursor = coneccion.cursor()
  106.     cursor.execute('insert into puntaje (nombre,puntos) values ("'+str(_nombre)+'",'+str(puntos)+')')
  107.     coneccion.commit()
  108.     cursor.close()
  109.    
  110.     escribir_game('Precione "m" para volver al menu principal.',15,(255,255,0),0,583)
  111.  
  112.          
  113.     pygame.display.flip()
  114.     while _bluce_principal:
  115.           for event in pygame.event.get():
  116.               if event.type == QUIT:
  117.                  _bluce_principal=0
  118.                  salir_confirmar()
  119.                  return
  120.           if pygame.key.get_pressed()[K_m]:
  121.              _bluce_principal=0
  122.              main_menu_game()
  123.              return
  124.  
  125.  
  126.  
  127. def ganar_juego_completo(puntos):
  128.     _bluce_principal=1
  129.     titulo_img = load_image('img/titulo.png',-1)
  130.     SpriteSheet_titulos = SpriteSheet('img/titulos.png')
  131.     cartel_ganaste = SpriteSheet_titulos.imgat((0,44,330,35),-1)
  132.  
  133.     pintar_fondo_default()  
  134.     screen.blit(titulo_img, (30,50))
  135.     screen.blit(cartel_ganaste, (450,75) )
  136.          
  137.     escribir_game('Ganaste, hiciste '+str(puntos)+' puntos en total.',30,(255,255,255),30,150)
  138.          
  139.     __n_numeros=0
  140.     _nombre=''
  141.     escribir_game('Ahora escribe tu nombre: ',30,(255,255,255),30,210)
  142.          
  143.     pygame.display.flip()
  144.          
  145.     _si=False
  146.     while not _si:
  147.           for event in pygame.event.get():
  148.               for ast in event.dict:
  149.                   if ast == 'unicode':
  150.                      __n_numeros=__n_numeros+1
  151.                      _nombre=_nombre+str(event.unicode)
  152.                      escribir_game(str(event.unicode),30,(255,255,255),380+(__n_numeros*15),210)
  153.                      if __n_numeros>=4:
  154.                         _si=True
  155.                         break
  156.                      pygame.display.flip()
  157.    
  158.     _si=True
  159.    
  160.     cursor = coneccion.cursor()
  161.     cursor.execute('insert into puntaje (nombre,puntos) values ("'+str(_nombre)+'",'+str(puntos)+')')
  162.     coneccion.commit()
  163.     cursor.close()
  164.    
  165.     escribir_game('Precione "m" para volver al menu principal.',15,(255,255,0),0,583)
  166.          
  167.     pygame.display.flip()
  168.     while _bluce_principal:
  169.           for event in pygame.event.get():
  170.               if event.type == QUIT:
  171.                  _bluce_principal=0
  172.                  salir_confirmar()
  173.                  return
  174.           if pygame.key.get_pressed()[K_m]:
  175.              _bluce_principal=0
  176.              main_menu_game()
  177.              return
  178.  
  179. def puntajes_mostrar():
  180.     _bluce_principal=1
  181.     titulo_img = load_image('img/titulo.png',-1)
  182.     SpriteSheet_puntaje = SpriteSheet('img/formas.png')
  183.    
  184.     barra_datos = SpriteSheet_puntaje.imgat((0,0,800,37))
  185.     barra_antes = SpriteSheet_puntaje.imgat((0,66,800,15))
  186.     barra_espacio = SpriteSheet_puntaje.imgat((0,80,800,30))
  187.    
  188.     while _bluce_principal:
  189.           for event in pygame.event.get():
  190.               if event.type == QUIT:
  191.                  _bluce_principal=0
  192.                  salir_confirmar()
  193.                  return
  194.           if pygame.key.get_pressed()[K_m]:
  195.              _bluce_principal=0
  196.              main_menu_game()
  197.              return
  198.              
  199.           pintar_fondo_default()      
  200.           screen.blit(titulo_img, (30,50))
  201.           screen.blit(barra_datos, (0,150))      
  202.           screen.blit(barra_antes, (0,185))
  203.          
  204.           ###############
  205.          
  206.           cursor = coneccion.cursor()
  207.           sqs_totales=0
  208.           cursor.execute('select * from puntaje order by puntos desc limit 0,10')
  209.           for row in cursor:
  210.               screen.blit(barra_espacio, (0,190+(sqs_totales*30)))
  211.               escribir_game(str(sqs_totales+1),15,(50,50,50),80,190+(sqs_totales*30))
  212.               escribir_game(str(row[1]),15,(50,50,50),280,190+(sqs_totales*30))
  213.               escribir_game(str(row[2]),15,(50,50,50),580,190+(sqs_totales*30))
  214.               sqs_totales = sqs_totales+1
  215.              
  216.          
  217.           if sqs_totales == 0:
  218.              screen.blit(barra_espacio, (0,190))
  219.              escribir_game('Nadie a jugado al juego aun, por eso no hay puntajes.',15,(100,100,100),10,193)
  220.          
  221.           escribir_game('Precione "m" para volver al menu principal.',15,(255,255,0),0,583)
  222.          
  223.           pygame.display.flip()
  224. def salir_confirmar():
  225.     titulo_img = load_image('img/titulo.png',-1)  
  226.     _bluce_principal=1
  227.     _opcion_elejida=1
  228.     SpriteSheet_salir = SpriteSheet('img/salir.png')
  229.    
  230.     opciones={"desactivado":
  231.                         {
  232.                         "si":SpriteSheet_salir.imgat((32,95,55,45),-1),
  233.                         "no":SpriteSheet_salir.imgat((32,145,55,45),-1)
  234.                         },
  235.               "activado":
  236.                         {
  237.                         "si":SpriteSheet_salir.imgat((180,95,55,45),-1),
  238.                         "no":SpriteSheet_salir.imgat((180,145,55,45),-1)
  239.                         }          
  240.              }
  241.    
  242.     pregunta=SpriteSheet_salir.imgat((32,0,280,70),-1)
  243.    
  244.     while _bluce_principal:
  245.           for event in pygame.event.get():
  246.               if event.type == QUIT:
  247.                  _bluce_principal=0
  248.                  salir_confirmar()
  249.                  return
Continua...
__________________
Half Music - www.halfmusic.com