Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- """
- Jeu Réalisé Par KreeZe
- """
- #bibliothèque
- import pygame
- from random import*
- #initialisation pygame+fenetre+utilitaire
- pygame.display.set_caption("Cluedo par Yamis")
- pygame.init()
- rouge_blanc_color = (255, 245 ,243)
- blank_color = (255, 255 ,255)
- black_color = (0, 0, 0)
- resolution = (1368, 768)
- fenetre = pygame.display.set_mode(resolution)
- font = pygame.font.SysFont(None, 24)
- fenetre.fill(blank_color)
- #liste
- main_indice=["Couteau","Chandelier","Clé anglaise","Matraque"]
- sec_indice=["Revolver","Corde","Montre", "Appareil Photo","Ecouteur","Pendentifs"]
- action=["vous avez avancé","vous avez été à gauche","vous avez reculé","vous avez été a droite","erreur","Au revoir"]
- piece=["l'Entrée","le Salon","la Salle a manger","la Salle de jeu","la Salle de reception","la Cuisine","la Chambre"]
- piece_2=["l'Entrée","le Salon","la Salle a manger","la Salle de jeu","la Salle de reception","la Cuisine","la Chambre"]
- #fermer la fenetre
- def fin():
- launched = True
- while launched:
- for event in pygame.event.get():
- if event.type == pygame.QUIT:
- launched = False
- if event.type == pygame.QUIT :
- pygame.quit()
- #afficher un text
- def text1(word,x,y):
- text = font.render(word,1,black_color)
- fenetre.blit(text, (x, y))
- #2e fonction text car pas envie de modifier tous
- def text2(word,x,y,size):
- font = pygame.font.SysFont(None, size)
- text = font.render(word,1,black_color)
- fenetre.blit(text, (x, y))
- #afficher image
- def image(p,x,y,fill):
- p = pygame.image.load(p)
- p.convert()
- if fill == True and p!= "GG.png":
- fenetre.fill(blank_color)
- fenetre.blit(p, [x, y])
- else:
- fenetre.blit(p, [x, y])
- #fonction image avec width en + car flemem de tous changer
- def image2(p,x,y,fill):
- p = pygame.image.load(p)
- p = pygame.transform.scale(p, (300, 300))
- p.convert()
- if fill == True:
- fenetre.fill(blank_color)
- fenetre.blit(p, [x, y])
- else:
- fenetre.blit(p, [x, y])
- #fonction inutile mais flemme je reorganiserai a la fin
- def touche_entree():
- for event in pygame.event.get():
- if event.type == pygame.KEYDOWN:
- if event.key == pygame.K_ENTER:
- return 1
- #fonction choix random (sortie indice_I/II/III et presence_I/II/III)
- indice_1=randint(0,2)
- indice_I=main_indice[indice_1]
- indice_2=randint(0,5)
- indice_II=sec_indice[indice_2]
- del sec_indice[indice_2]
- indice_3=randint(0,5-1)
- indice_III=sec_indice[indice_3]
- del sec_indice[indice_3]
- presence_1=randint(1,5)
- presence_I=piece_2[presence_1]
- del piece_2[presence_1]
- presence_2=randint(1,5-1)
- presence_II=piece_2[presence_2]
- del piece_2[presence_2]
- presence_3=randint(1,5-2)
- presence_III=piece_2[presence_3]
- del piece_2[presence_3]
- #fonction entrée salle
- def entree_salle(liste_salle):
- temp="vous êtes entrée dans "
- temp_2=piece[liste_salle]
- temp_3=temp+temp_2
- return temp_3
- def tueur():
- text1("Vous avez trouvez tous les indice : "+indice_I+", "+indice_II+", "+indice_III,400,0)
- text1("Trouver le meurtier !",550,20)
- text1("le major-d'home",150,450)
- image("Chandelier.png",100,100,False)
- text1("le policier",450,450)
- image("Matraque.png",400,100,False)
- text1("le cuisinier",750,450)
- image("Couteau.png",700,100,False)
- text1("le mécano",1050,450)
- image("clef.png",1000,100,False)
- #fonction principale(jeu)
- def main():
- ecran_fin = 0
- clic = 0
- points_1=0
- points_2=0
- points_3=0
- quiter=0
- suite=0
- position=piece[0]
- continuer = 0
- touche = 0
- while continuer == 0:
- #detection touche
- for event in pygame.event.get():
- if event.type == pygame.KEYDOWN:
- if event.key == pygame.K_ESCAPE:
- continuer = 1
- quiter=1
- suite=1
- ecran_fin = 1
- if event.key == pygame.K_w:
- touche="z"
- if event.key == pygame.K_a:
- touche="q"
- if event.key == pygame.K_s:
- touche="s"
- if event.key == pygame.K_d:
- touche="d"
- if event.key == pygame.K_RETURN:
- touche = "entrer"
- #mecanisme du jeu
- if touche == 0:
- image("cluedo.png",150,100,True)
- text2("bienvenu dans cluedo",370,30,70)
- text1("apuyer sur entrer pour commencer",500 , 0)
- text1("Déplacement :",300,620)
- text1("z pour allez ver l'avant",300,660)
- text1("q pour allez à gauche",600,660)
- text1("s pour allez ver l'arrière",300,680)
- text1("d pour allez à droite",600,680)
- image("echap.png",1100,0,False)
- position = -1
- elif touche == "entrer" and position== -1:
- fenetre.fill(blank_color)
- image("l'Entree.png",150,100,True)
- text1("vous êtes dans l'entrée",900,400)
- position=piece[0]
- touche=""
- image2("carte 0.png",950,80,False)
- elif touche=="z" and position==piece[0]:
- fenetre.fill(blank_color)
- image("le Salon.png",150,100,True)
- text1(entree_salle(1),900,400)
- position=piece[1]
- touche=""
- image2("carte 1.png",950,80,False)
- elif (touche=="q" or touche=="s" or touche=="d") and position==piece[0]:
- fenetre.fill(blank_color)
- image("l'Entree.png",150,100,True)
- text1("vous ne pouver aller par là",900,400)
- position=piece[0]
- touche=""
- image2("carte 0.png",950,80,False)
- elif touche=="q" and position==piece[1]:
- fenetre.fill(blank_color)
- image("la Salle a manger.png",150,100,True)
- text1(entree_salle(2),900,400)
- position=piece[2]
- touche=""
- image2("carte 2.png",950,80,False)
- elif touche=="z" and position==piece[1]:
- fenetre.fill(blank_color)
- image("la Salle de reception.png",150,100,True)
- text1(entree_salle(4),900,400)
- position=piece[4]
- touche=""
- image2("carte 4.png",950,80,False)
- elif touche=="d" and position==piece[1]:
- fenetre.fill(blank_color)
- image("la Salle de jeu.png",150,100,True)
- text1(entree_salle(3),900,400)
- position=piece[3]
- touche=""
- image2("carte 3.png",950,80,False)
- elif touche=="s" and position==piece[1]:
- fenetre.fill(blank_color)
- image("l'Entree.png",150,100,True)
- text1(entree_salle(0),900,400)
- position=piece[0]
- touche=""
- image2("carte 0.png",950,80,False)
- elif touche=="z" and position==piece[2]:
- fenetre.fill(blank_color)
- image("la Cuisine.png",150,100,True)
- text1(entree_salle(5),900,400)
- position=piece[5]
- touche=""
- image2("carte 5.png",950,80,False)
- elif (touche=="q" or touche=="s" )and position==piece[2]:
- fenetre.fill(blank_color)
- image("la Salle a manger.png",150,100,True)
- text1("vous ne pouver aller par là",900,400)
- position=piece[2]
- touche=""
- image2("carte 2.png",950,80,False)
- elif touche=="d" and position==piece[2]:
- fenetre.fill(blank_color)
- image("le Salon.png",150,100,True)
- text1(entree_salle(1),900,400)
- position=piece[1]
- touche=""
- image2("carte 1.png",950,80,False)
- elif touche=="q" and position==piece[3]:
- fenetre.fill(blank_color)
- image("le Salon.png",150,100,True)
- text1(entree_salle(1),900,400)
- position=piece[1]
- touche=""
- image2("carte 1.png",950,80,False)
- elif touche=="z" and position==piece[3]:
- fenetre.fill(blank_color)
- image("la Chambre.png",150 ,100,True)
- text1(entree_salle(6),900,400)
- position=piece[6]
- touche=""
- image2("carte 6.png",950,80,False)
- elif (touche=="s" or touche=="d") and position==piece[3]:
- fenetre.fill(blank_color)
- image("la Salle de jeu.png",150,100,True)
- text1("vous ne pouver aller par là",900,400)
- position=piece[3]
- touche=""
- image2("carte 3.png",950,80,False)
- elif touche=="z" and position==piece[4]:
- fenetre.fill(blank_color)
- image("la Salle de reception.png",150,100,True)
- text1("vous ne pouver aller par là",900,400)
- position=piece[4]
- touche=""
- image2("carte 4.png",950,80,False)
- elif touche=="q" and position==piece[4]:
- fenetre.fill(blank_color)
- image("la Cuisine.png",150,100,True)
- text1(entree_salle(5),900,400)
- position=piece[5]
- touche=""
- image2("carte 5.png",950,80,False)
- elif touche=="s" and position==piece[4]:
- fenetre.fill(blank_color)
- image("le Salon.png",150,100,True)
- text1(entree_salle(1),950,400)
- position=piece[1]
- touche=""
- image2("carte 1.png",950,80,False)
- elif touche=="d" and position==piece[4]:
- fenetre.fill(blank_color)
- image("la Chambre.png",150 ,100,True)
- text1(entree_salle(6),900,400)
- position=piece[6]
- touche=""
- image2("carte 6.png",950,80,False)
- elif (touche=="z" or touche=="q") and position==piece[5]:
- fenetre.fill(blank_color)
- image("la Cuisine.png",150,100,True)
- text1("vous ne pouver aller par là",900,400)
- position=piece[5]
- touche=""
- image2("carte 5.png",950,80,False)
- elif touche=="s" and position==piece[5]:
- fenetre.fill(blank_color)
- image("la Salle a manger.png",150,100,True)
- text1(entree_salle(2),900,400)
- position=piece[2]
- touche=""
- image2("carte 2.png",950,80,False)
- elif touche=="d" and position==piece[5]:
- fenetre.fill(blank_color)
- image("la Salle de reception.png",150,100,True)
- text1(entree_salle(4),900,400)
- position=piece[4]
- touche=""
- image2("carte 4.png",950,80,False)
- elif (touche=="z" or touche=="d") and position==piece[6]:
- fenetre.fill(blank_color)
- image("la Chambre.png",150 ,100,True)
- text1("vous ne pouver aller par là",900,400)
- position=piece[6]
- touche=""
- image2("carte 6.png",950,80,False)
- elif touche=="s" and position==piece[6]:
- fenetre.fill(blank_color)
- image("la Salle de jeu.png",150,100,True)
- text1(entree_salle(3),900,400)
- position=piece[3]
- touche=""
- image2("carte 3.png",950,80,False)
- elif touche=="q" and position==piece[6]:
- fenetre.fill(blank_color)
- image("la Salle de reception.png",150,100,True)
- text1(entree_salle(4),900,400)
- position=piece[4]
- touche=""
- image2("carte 4.png",950,80,False)
- #detection decouverte indice
- if position==presence_I:
- image(position+".png",150 ,100,True)
- text1("vous êtes entrée dans "+position,900,400)
- text1("vous avez trouvé un indice : "+indice_I,900,450)
- numero = int(piece.index(position))
- image2("carte "+str(numero)+".png",950,80,False)
- image("echap.png",1100,0,False)
- points_1=1
- elif position==presence_II:
- image(position+".png",150 ,100,True)
- text1("vous êtes entrée dans "+position,900,400)
- text1("vous avez trouvé un indice : "+indice_II,900,450)
- numero = int(piece.index(position))
- image2("carte "+str(numero)+".png",950,80,False)
- image("echap.png",1100,0,False)
- points_2=1
- elif position==presence_III:
- image(position+".png",150 ,100,True)
- text1("vous êtes entrée dans "+position,900,400)
- text1("vous avez trouvé un indice : "+indice_III,900,450)
- numero = int(piece.index(position))
- image2("carte "+str(numero)+".png",950,80,False)
- image("echap.png",1100,0,False)
- points_3=1
- pygame.display.flip()
- #afficher "Vous pouvez fermer" et "Au revoir et A bientot"
- if quiter == 1:
- text1("Vous pouvez fermer",1130,0)
- text1("Au revoir et A bientot",800,0)
- pygame.display.flip()
- #fin de la 1ère étape apres avoir trouvé tous les indices
- if (points_1+points_2+points_3) == 3:
- continuer=1
- image("echap.png",1100,0,False)
- pygame.time.delay(500)
- pygame.time.delay(1000)
- fenetre.fill(blank_color)
- premiere_zone = pygame.Rect((100, 100), (250, 300))
- rect_surf_1 = pygame.Surface(premiere_zone.size)
- rect_surf_1.set_alpha(0)
- deuxieme_zone = pygame.Rect((400, 100), (250, 300))
- rect_surf_2 = pygame.Surface(deuxieme_zone.size)
- rect_surf_2.set_alpha(0)
- troisieme_zone = pygame.Rect((700, 100), (250, 300))
- rect_surf_3 = pygame.Surface(troisieme_zone.size)
- rect_surf_3.set_alpha(0)
- quatrieme_zone = pygame.Rect((1000, 100), (250, 300))
- rect_surf_4 = pygame.Surface(quatrieme_zone.size)
- rect_surf_4.set_alpha(0)
- fenetre.blit(rect_surf_1, premiere_zone)
- fenetre.blit(rect_surf_2, deuxieme_zone)
- fenetre.blit(rect_surf_3, troisieme_zone)
- fenetre.blit(rect_surf_4, quatrieme_zone)
- pygame.display.flip()
- while suite == 0:
- perdu = 0
- fenetre.fill(blank_color)
- #detection touche
- for event in pygame.event.get():
- if event.type == pygame.KEYDOWN:
- if event.key == pygame.K_ESCAPE:
- text1("Vous pouvez fermer",1130,0)
- text1("Au revoir et A bientot",1130,20)
- suite=1
- ecran_fin = 1
- if event.type == pygame.MOUSEBUTTONDOWN: # quand je relache le bouton
- if event.button == 1: # 1= clique gauche
- if premiere_zone.collidepoint(event.pos) and meutrier == 2:
- suite = 1
- elif premiere_zone.collidepoint(event.pos) and meutrier != 2:
- perdu = 1
- elif deuxieme_zone.collidepoint(event.pos) and meutrier == 1:
- suite = 1
- elif deuxieme_zone.collidepoint(event.pos) and meutrier != 1:
- perdu = 1
- elif troisieme_zone.collidepoint(event.pos) and meutrier == 0:
- suite = 1
- elif troisieme_zone.collidepoint(event.pos) and meutrier != 0:
- perdu = 1
- elif quatrieme_zone.collidepoint(event.pos) and meutrier == 3:
- suite = 1
- elif quatrieme_zone.collidepoint(event.pos) and meutrier != 3:
- perdu = 1
- text1("Vous avez trouvez tous les indice : "+indice_I+", "+indice_II+", "+indice_III,400,0)
- text1("Trouver le meurtier !",550,20)
- text2("Utiliser la souris pour cliquer sur le tueur présumé",400,600,40)
- #detection du tueur
- if indice_I == "Couteau" or indice_II == "Couteau" or indice_III == "Couteau":
- meutrier = 0
- elif indice_I == "Matraque" or indice_II == "Matraque" or indice_III == "Matraque":
- meutrier = 1
- elif indice_I == "Chandelier" or indice_II == "Chandelier" or indice_III == "Chandelier":
- meutrier = 2
- elif indice_I == "Clé anglaise" or indice_II == "Clé anglaise" or indice_III == "Clé anglaise":
- meutrier = 3
- tueur()
- if perdu == 1:
- text1("Vous avez Perdu ",600,500)
- text1("Ce n'est pas le tueur ",590,530)
- text1("Recommencer",610,560)
- image("echap.png",1100,0,False)
- pygame.display.flip()
- pygame.time.delay(1000)
- image("echap.png",1100,0,False)
- pygame.display.flip()
- while ecran_fin == 0:
- image("GG.png",400 ,100,True)
- image("echap.png",1100,0,False)
- text2("Bien joué vous avez trouvé le teur",350,50,60)
- text1("Jeu réalisé pas KreeZe",1150,740)
- pygame.display.flip()
- for event in pygame.event.get():
- if event.type == pygame.KEYDOWN:
- if event.key == pygame.K_ESCAPE:
- text1("Vous pouvez fermer",1130,0)
- text1("Au revoir et A bientot",1130,20)
- ecran_fin = 1
- pygame.quit()
- main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement