elhacker.net cabecera Bienvenido(a), Visitante. Por favor Ingresar o Registrarse
¿Perdiste tu email de activación?.

 

 


Tema destacado: (TUTORIAL) Aprende a emular Sentinel Dongle By Yapis


+  Foro de elhacker.net
|-+  Programación
| |-+  Scripting
| | |-+  [Python-Pygame] Cruel Hangman 0.2
0 Usuarios y 1 Visitante están viendo este tema.
Páginas: [1] Ir Abajo Respuesta Imprimir
Autor Tema: [Python-Pygame] Cruel Hangman 0.2  (Leído 1,890 veces)
BigBear


Desconectado Desconectado

Mensajes: 545



Ver Perfil
[Python-Pygame] Cruel Hangman 0.2
« en: 19 Diciembre 2014, 15:02 pm »

Un simple ahorcado que hice en python usando Pygame , el juego es una  parodia del capitulo llamado "Chef se volvio loco" de South Park , es solo una parodia de ese capitulo no se lo vayan a tomar en serio.

Una imagen :



El codigo :

Código
  1. #!usr/bin/python
  2. #Cruel Hangman 0.2
  3. #(C) Doddy Hackman 2014
  4.  
  5. import pygame,sys,time,random
  6. from pygame.locals import *
  7.  
  8. test1 = ""
  9. test2 = ""
  10. test3 = ""
  11. test4 = ""
  12. test5 = ""
  13.  
  14. des1 = "0"
  15. des2 = "0"
  16. des3 = "0"
  17. des4 = "0"
  18. des5 = "0"
  19.  
  20. gane = "0"
  21. perdi = "0"
  22.  
  23. repetido = []
  24.  
  25. oportunidades = 7
  26.  
  27. def escribir_fuente(texto,x,y):
  28. cargando_fuente = pygame.font.SysFont(None, 40)
  29. tipo_fuente = cargando_fuente.render(texto, True, (255, 0, 0))
  30. posicion = tipo_fuente.get_rect()
  31. posicion.centerx = x
  32. posicion.centery = y
  33. screen.blit(tipo_fuente,posicion)
  34.  
  35. def actualizar(letra,letra1,letra2,letra3,letra4,letra5):
  36.  
  37.  global oportunidades
  38.  
  39.  if letra=="inicio":
  40.  
  41.   test1 = ""
  42.   test2 = ""
  43.   test3 = ""
  44.   test4 = ""
  45.   test5 = ""
  46.  
  47.   des1 = "0"
  48.   des2 = "0"
  49.   des3 = "0"
  50.   des4 = "0"
  51.   des5 = "0"
  52.  
  53.   gane = "0"
  54.   perdi = "0"
  55.  
  56.   oportunidades = 7
  57.  
  58.   global repetido
  59.  
  60.   repetido = []
  61.  
  62.   over = pygame.image.load("Data/Images/logoinicio.png")
  63.   screen.blit(over,(0,0))
  64.  
  65.   escribir_fuente("_",300,570)
  66.   escribir_fuente("_",350,570)
  67.   escribir_fuente("_",400,570)
  68.   escribir_fuente("_",450,570)
  69.   escribir_fuente("_",500,570)
  70.  
  71.   escribir_fuente("",300,560)
  72.   escribir_fuente("",350,560)
  73.   escribir_fuente("",400,560)
  74.   escribir_fuente("",450,560)
  75.   escribir_fuente("",500,560)
  76.  
  77.   pygame.display.update()
  78.  
  79.  else:
  80.  
  81.  
  82.   if oportunidades==7:
  83.    over = pygame.image.load("Data/Images/logoinicio.png")
  84.    screen.blit(over,(0,0))
  85.  
  86.   global test1
  87.   global test2
  88.   global test3
  89.   global test4
  90.   global test5
  91.  
  92.   global des1
  93.   global des2
  94.   global des3
  95.   global des4
  96.   global des5
  97.  
  98.   global gane
  99.   global perdi
  100.  
  101.   control = 0
  102.  
  103.   if letra==letra1:
  104.    test1 = letra
  105.    if des1 == "0":
  106.     des1 = "1"
  107.     control = 1
  108.  
  109.   if letra==letra2:
  110.    test2 = letra
  111.    if des2 == "0":
  112. des2 = "1"
  113. control = 1
  114.  
  115.   if letra==letra3:
  116.    test3 = letra
  117.    if des3 == "0":
  118. des3 = "1"
  119. control = 1
  120.  
  121.   if letra==letra4:
  122.    test4 = letra
  123.    if des4 == "0":
  124. des4 = "1"
  125. control = 1
  126.  
  127.   if letra==letra5:
  128.    test5 = letra
  129.    if des5 == "0":
  130. des5 = "1"
  131. control = 1
  132.  
  133.   if des1=="1" and des2=="1" and des3=="1" and des4=="1" and des5=="1":
  134. oportunidades = 7
  135. pygame.mixer.Sound("Data/Sounds/ohh.ogg").play()
  136. escribir_fuente("You Win",680,50)
  137. escribir_fuente("Press Enter to continue",680,90)
  138. gane = "1"
  139. pygame.display.update()
  140.  
  141.   if control==1:
  142.    repetido.append(letra)
  143.    pygame.mixer.Sound("Data/Sounds/bien.ogg").play()
  144.   else:
  145. if not letra in repetido:
  146. oportunidades = oportunidades - 1  
  147. pygame.mixer.Sound("Data/Sounds/mal.ogg").play()
  148.  
  149.   if oportunidades==6:
  150.    over = pygame.image.load("Data/Images/logocabeza.png")
  151.    screen.blit(over,(0,0))
  152.  
  153.   if oportunidades==5:
  154.    over = pygame.image.load("Data/Images/logopalo.png")
  155.    screen.blit(over,(0,0))
  156.  
  157.   if oportunidades==4:
  158.    over = pygame.image.load("Data/Images/logobrazo1.png")
  159.    screen.blit(over,(0,0))    
  160.  
  161.   if oportunidades==3:
  162.    over = pygame.image.load("Data/Images/logobrazo2.png")
  163.    screen.blit(over,(0,0))
  164.  
  165.   if oportunidades==2:
  166.    over = pygame.image.load("Data/Images/logopierna1.png")
  167.    screen.blit(over,(0,0))
  168.  
  169.   if oportunidades==1:
  170.    over = pygame.image.load("Data/Images/final.png")
  171.    screen.blit(over,(0,0))
  172.    pygame.mixer.Sound("Data/Sounds/festejo.ogg").play()
  173.    escribir_fuente("You Lost",680,50)
  174.    escribir_fuente("Press Enter to continue",680,90)
  175.    perdi = "1"
  176.    test1 = letra1
  177.    test2 = letra2
  178.    test3 = letra3
  179.    test4 = letra4
  180.    test5 = letra5
  181.  
  182.   escribir_fuente("_",300,570)
  183.   escribir_fuente("_",350,570)
  184.   escribir_fuente("_",400,570)
  185.   escribir_fuente("_",450,570)
  186.   escribir_fuente("_",500,570)
  187.  
  188.   escribir_fuente(test1,300,560)
  189.   escribir_fuente(test2,350,560)
  190.   escribir_fuente(test3,400,560)
  191.   escribir_fuente(test4,450,560)
  192.   escribir_fuente(test5,500,560)
  193.  
  194.   pygame.display.update()
  195.  
  196.  
  197. screen = pygame.display.set_mode((860,640),0,32)
  198.  
  199. icono = pygame.image.load("Data/Images/icono.png").convert_alpha()      
  200. pygame.display.set_icon(icono)
  201. pygame.display.set_caption("Cruel Hangman 0.2 (C) Doddy Hackman 2014")
  202.  
  203. pygame.init()
  204.  
  205. pygame.mixer.Sound("Data/Sounds/menu.wav").play()
  206. men = pygame.image.load("Data/Images/logohangman.png")
  207. screen.blit(men,(0,0))
  208. pygame.display.update()
  209. time.sleep(9)
  210.  
  211. def game():
  212.  
  213. #palabras = ["pizza","agrio"]
  214. palabras =
  215.  
  216. ["andar","banco","cazar","clave","etapa","oasis","parte","saber","socio","u
  217.  
  218. sado","ronca","boxeo","pizza","groso","fallo","acera","acoso","agrio","ansi
  219.  
  220. a","gnomo","gordo","pieza"]
  221.  
  222. palabra = random.choice(palabras)
  223.  
  224. letra1 = palabra[0]
  225. letra2 = palabra[1]
  226. letra3 = palabra[2]
  227. letra4 = palabra[3]
  228. letra5 = palabra[4]
  229.  
  230. actualizar("inicio",letra1,letra2,letra3,letra4,letra5)
  231.  
  232. pygame.mixer.init()
  233. pygame.mixer.music.load("Data/Sounds/theme.mp3")
  234. pygame.mixer.music.play()
  235.  
  236.  
  237. while True:
  238.  for eventos in pygame.event.get():
  239.   if eventos.type == QUIT:
  240.    sys.exit(0)
  241.  
  242.  
  243.   if (eventos.type == pygame.KEYDOWN) and (eventos.key ==
  244.  
  245. pygame.K_RETURN):
  246.   if gane=="1" or perdi=="1":
  247.   game()
  248.  
  249.   if eventos.type==KEYDOWN :
  250.    if eventos.unicode.lower() in ("abcdefghijklmnopqrstuvwxyz"):
  251.     actualizar(eventos.unicode,letra1,letra2,letra3,letra4,letra5)
  252.  
  253. game()
  254.  
  255. # The End ?
  256.  
  257.  

Si quieren bajar el juego lo pueden hacer de

aca.


En línea

Páginas: [1] Ir Arriba Respuesta Imprimir 

Ir a:  

Mensajes similares
Asunto Iniciado por Respuestas Vistas Último mensaje
pygame(python)
Scripting
desnight 0 2,350 Último mensaje 29 Febrero 2008, 15:25 pm
por desnight
[Python] Ayuda con pygame
Scripting
zZznewbiezZz 2 2,990 Último mensaje 16 Noviembre 2010, 12:53 pm
por Gabriela
[python] algún tutorial pygame?
Scripting
zZznewbiezZz 6 5,773 Último mensaje 4 Marzo 2012, 23:22 pm
por UnboundDarkness
[python] menu pygame aporte
Scripting
daryo 0 3,744 Último mensaje 2 Mayo 2013, 02:45 am
por daryo
[DUDA]Funciona Pygame en Python 3.4.1
Scripting
Proxmond 3 3,073 Último mensaje 11 Julio 2014, 18:44 pm
por Yidu
WAP2 - Aviso Legal - Powered by SMF 1.1.21 | SMF © 2006-2008, Simple Machines