[Python-Pygame] Cruel Hangman 0.2

Iniciado por BigBear, Diciembre 19, 2014, 10:57:14 AM

Tema anterior - Siguiente tema

0 Miembros y 1 Visitante están viendo este tema.

Diciembre 19, 2014, 10:57:14 AM Ultima modificación: Diciembre 19, 2014, 11:03:06 AM por Doddy
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: python

#!usr/bin/python
#Cruel Hangman 0.2
#(C) Doddy Hackman 2014

import pygame,sys,time,random
from pygame.locals import *

test1 = ""
test2 = ""
test3 = ""
test4 = ""
test5 = ""

des1 = "0"
des2 = "0"
des3 = "0"
des4 = "0"
des5 = "0"

gane = "0"
perdi = "0"

repetido = []

oportunidades = 7

def escribir_fuente(texto,x,y):
cargando_fuente = pygame.font.SysFont(None, 40)
tipo_fuente = cargando_fuente.render(texto, True, (255, 0, 0))
posicion = tipo_fuente.get_rect()
posicion.centerx = x
posicion.centery = y
screen.blit(tipo_fuente,posicion)

def actualizar(letra,letra1,letra2,letra3,letra4,letra5):

  global oportunidades
 
  if letra=="inicio":

   test1 = ""
   test2 = ""
   test3 = ""
   test4 = ""
   test5 = ""

   des1 = "0"
   des2 = "0"
   des3 = "0"
   des4 = "0"
   des5 = "0"

   gane = "0"
   perdi = "0"
   
   oportunidades = 7
   
   global repetido
   
   repetido = []
     
   over = pygame.image.load("Data/Images/logoinicio.png")
   screen.blit(over,(0,0))
   
   escribir_fuente("_",300,570)
   escribir_fuente("_",350,570)
   escribir_fuente("_",400,570)
   escribir_fuente("_",450,570)
   escribir_fuente("_",500,570)
   
   escribir_fuente("",300,560)
   escribir_fuente("",350,560)
   escribir_fuente("",400,560)
   escribir_fuente("",450,560)
   escribir_fuente("",500,560)
     
   pygame.display.update()
   
  else:


   if oportunidades==7:
    over = pygame.image.load("Data/Images/logoinicio.png")
    screen.blit(over,(0,0))
       
   global test1
   global test2
   global test3
   global test4
   global test5
   
   global des1
   global des2
   global des3
   global des4
   global des5
   
   global gane
   global perdi
   
   control = 0
   
   if letra==letra1:
    test1 = letra
    if des1 == "0":
     des1 = "1"
     control = 1

   if letra==letra2:
    test2 = letra
    if des2 == "0":
des2 = "1"
control = 1
   
   if letra==letra3:
    test3 = letra
    if des3 == "0":
des3 = "1"
control = 1
   
   if letra==letra4:
    test4 = letra
    if des4 == "0":
des4 = "1"
control = 1
   
   if letra==letra5:
    test5 = letra
    if des5 == "0":
des5 = "1"
control = 1

   if des1=="1" and des2=="1" and des3=="1" and des4=="1" and des5=="1":
oportunidades = 7
pygame.mixer.Sound("Data/Sounds/ohh.ogg").play()
escribir_fuente("You Win",680,50)
escribir_fuente("Press Enter to continue",680,90)
gane = "1"
pygame.display.update()

   if control==1:
    repetido.append(letra)
    pygame.mixer.Sound("Data/Sounds/bien.ogg").play()
   else:
if not letra in repetido:
oportunidades = oportunidades - 1 
pygame.mixer.Sound("Data/Sounds/mal.ogg").play()

   if oportunidades==6:
    over = pygame.image.load("Data/Images/logocabeza.png")
    screen.blit(over,(0,0))

   if oportunidades==5:
    over = pygame.image.load("Data/Images/logopalo.png")
    screen.blit(over,(0,0))
   
   if oportunidades==4:
    over = pygame.image.load("Data/Images/logobrazo1.png")
    screen.blit(over,(0,0))   
     
   if oportunidades==3:
    over = pygame.image.load("Data/Images/logobrazo2.png")
    screen.blit(over,(0,0))
     
   if oportunidades==2:
    over = pygame.image.load("Data/Images/logopierna1.png")
    screen.blit(over,(0,0))
   
   if oportunidades==1:
    over = pygame.image.load("Data/Images/final.png")
    screen.blit(over,(0,0))
    pygame.mixer.Sound("Data/Sounds/festejo.ogg").play()
    escribir_fuente("You Lost",680,50)
    escribir_fuente("Press Enter to continue",680,90)
    perdi = "1"
    test1 = letra1
    test2 = letra2
    test3 = letra3
    test4 = letra4
    test5 = letra5
       
   escribir_fuente("_",300,570)
   escribir_fuente("_",350,570)
   escribir_fuente("_",400,570)
   escribir_fuente("_",450,570)
   escribir_fuente("_",500,570)
   
   escribir_fuente(test1,300,560)
   escribir_fuente(test2,350,560)
   escribir_fuente(test3,400,560)
   escribir_fuente(test4,450,560)
   escribir_fuente(test5,500,560)
   
   pygame.display.update()
   

screen = pygame.display.set_mode((860,640),0,32)

icono = pygame.image.load("Data/Images/icono.png").convert_alpha()       
pygame.display.set_icon(icono)
pygame.display.set_caption("Cruel Hangman 0.2 (C) Doddy Hackman 2014")

pygame.init()

pygame.mixer.Sound("Data/Sounds/menu.wav").play()
men = pygame.image.load("Data/Images/logohangman.png")
screen.blit(men,(0,0))
pygame.display.update()
time.sleep(9)

def game():

#palabras = ["pizza","agrio"]
palabras =

["andar","banco","cazar","clave","etapa","oasis","parte","saber","socio","u

sado","ronca","boxeo","pizza","groso","fallo","acera","acoso","agrio","ansi

a","gnomo","gordo","pieza"]

palabra = random.choice(palabras)

letra1 = palabra[0]
letra2 = palabra[1]
letra3 = palabra[2]
letra4 = palabra[3]
letra5 = palabra[4]

actualizar("inicio",letra1,letra2,letra3,letra4,letra5)

pygame.mixer.init()
pygame.mixer.music.load("Data/Sounds/theme.mp3")
pygame.mixer.music.play()


while True:
  for eventos in pygame.event.get():
   if eventos.type == QUIT:
    sys.exit(0)


   if (eventos.type == pygame.KEYDOWN) and (eventos.key ==

pygame.K_RETURN):
    if gane=="1" or perdi=="1":
    game()

   if eventos.type==KEYDOWN :
    if eventos.unicode.lower() in ("abcdefghijklmnopqrstuvwxyz"):
     actualizar(eventos.unicode,letra1,letra2,letra3,letra4,letra5)
   
game()

# The End ?



Si quieren bajar el juego lo pueden hacer de

No tienes permitido ver los links. Registrarse o Entrar a mi cuenta.