Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #bibliothèque
- import pygame
- from random import*
- #initialisation pygame+fenetre+utilitaire
- pygame.display.set_caption("Cluedo par Yamis")
- pygame.init()
- blank_color = (255, 255 ,255)
- black_color = (0, 0, 0)
- resolution = (1366, 768)
- fenetre = pygame.display.set_mode(resolution)
- font=pygame.font.Font(None, 24)
- fenetre.fill(blank_color)
- #liste
- indice=["Poignard","Revolver","Chandelier","Corde","Clé anglaise","Matraque"]
- 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 à manger","la Salle de jeu","la Salle de reception","la Cuisine","la Chambre"]
- piece_2=["l'Entrée","le Salon","la Salle à 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))
- pygame.display.flip()
- #afficher image
- def image(p):
- p = pygame.image.load(p)
- p.convert()
- fenetre.fill(blank_color)
- fenetre.blit(p, [150, 100])
- pygame.display.flip()
- #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
- #fonction principale(jeu)
- def main():
- 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
- text1("Vous pouver fermer",1200,0)
- text1("Au revoir et A bientot",1000,0)
- 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"
- #mecanisme du jeu
- if touche==0:
- text1("bienvenu dans cluedo",500,0)
- image("cluedo.png")
- elif touche=="z" and position==piece[0]:
- fenetre.fill(blank_color)
- image("salon.png")
- text1(entree_salle(1),1000,400)
- position=piece[1]
- touche=""
- elif (touche=="q" or touche=="s" or touche=="d") and position==piece[0]:
- fenetre.fill(blank_color)
- image("entree.png")
- text1("vous ne pouver aller par là",1000,400)
- position=piece[0]
- touche=""
- elif touche=="q" and position==piece[1]:
- fenetre.fill(blank_color)
- image("salle a manger.png")
- text1(entree_salle(2),1000,400)
- position=piece[2]
- touche=""
- elif touche=="z" and position==piece[1]:
- fenetre.fill(blank_color)
- image("reception.png")
- text1(entree_salle(4),1000,400)
- position=piece[4]
- touche=""
- elif touche=="d" and position==piece[1]:
- fenetre.fill(blank_color)
- image("salle de jeu.png")
- text1(entree_salle(3),1000,400)
- position=piece[3]
- touche=""
- elif touche=="s" and position==piece[1]:
- fenetre.fill(blank_color)
- image("entree.png")
- text1(entree_salle(0),1000,400)
- position=piece[0]
- touche=""
- elif touche=="z" and position==piece[2]:
- fenetre.fill(blank_color)
- image("cuisine.png")
- text1(entree_salle(5),1000,400)
- position=piece[5]
- touche=""
- elif (touche=="q" or touche=="s" )and position==piece[2]:
- fenetre.fill(blank_color)
- image("salle a manger.png")
- text1("vous ne pouver aller par là",1000,400)
- position=piece[2]
- touche=""
- elif touche=="d" and position==piece[2]:
- fenetre.fill(blank_color)
- image("salon.png")
- text1(entree_salle(1),1000,400)
- position=piece[1]
- touche=""
- elif touche=="q" and position==piece[3]:
- fenetre.fill(blank_color)
- image("salon.png")
- text1(entree_salle(1),1000,400)
- position=piece[1]
- touche=""
- elif touche=="z" and position==piece[3]:
- fenetre.fill(blank_color)
- image("chambre.png")
- text1(entree_salle(6),1000,400)
- position=piece[6]
- touche=""
- elif (touche=="s" or touche=="d") and position==piece[3]:
- fenetre.fill(blank_color)
- image("salle de jeu.png")
- text1("vous ne pouver aller par là",1000,400)
- position=piece[3]
- touche=""
- elif touche=="z" and position==piece[4]:
- fenetre.fill(blank_color)
- image("reception.png")
- text1("vous ne pouver aller par là",1000,400)
- position=piece[4]
- touche=""
- elif touche=="q" and position==piece[4]:
- fenetre.fill(blank_color)
- image("cuisine.png")
- text1(entree_salle(5),1000,400)
- position=piece[5]
- touche=""
- elif touche=="s" and position==piece[4]:
- fenetre.fill(blank_color)
- image("salon.png")
- text1(entree_salle(1),1000,400)
- position=piece[1]
- touche=""
- elif touche=="d" and position==piece[4]:
- fenetre.fill(blank_color)
- image("chambre.png")
- text1(entree_salle(6),1000,400)
- position=piece[6]
- touche=""
- elif (touche=="z" or touche=="q") and position==piece[5]:
- fenetre.fill(blank_color)
- image("cuisine.png")
- text1("vous ne pouver aller par là",1000,400)
- position=piece[5]
- touche=""
- elif touche=="s" and position==piece[5]:
- fenetre.fill(blank_color)
- image("salle a manger.png")
- text1(entree_salle(2),1000,400)
- position=piece[2]
- touche=""
- elif touche=="d" and position==piece[5]:
- fenetre.fill(blank_color)
- image("reception.png")
- text1(entree_salle(4),1000,400)
- position=piece[4]
- touche=""
- elif (touche=="z" or touche=="d") and position==piece[6]:
- fenetre.fill(blank_color)
- image("chambre.png")
- text1("vous ne pouver aller par là",1000,400)
- position=piece[6]
- touche=""
- elif touche=="s" and position==piece[6]:
- fenetre.fill(blank_color)
- image("salle de jeu.png")
- text1(entree_salle(3),1000,400)
- position=piece[3]
- touche=""
- elif touche=="q" and position==piece[6]:
- fenetre.fill(blank_color)
- image("reception.png")
- text1(entree_salle(4),1000,400)
- position=piece[4]
- touche=""
- main()
- fin()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement