Advertisement
KreeZe

d

Nov 13th, 2019
307
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 7.39 KB | None | 0 0
  1. #bibliothèque
  2. import pygame
  3. from random import*
  4.  
  5. #initialisation pygame+fenetre+utilitaire
  6. pygame.display.set_caption("Cluedo par Yamis")
  7. pygame.init()
  8. blank_color = (255, 255 ,255)
  9. black_color = (0, 0, 0)
  10. resolution = (1366, 768)
  11. fenetre = pygame.display.set_mode(resolution)
  12. font=pygame.font.Font(None, 24)
  13. fenetre.fill(blank_color)
  14.  
  15. #liste
  16. indice=["Poignard","Revolver","Chandelier","Corde","Clé anglaise","Matraque"]
  17. action=["vous avez avancé","vous avez été à gauche","vous avez reculé","vous avez été a droite","erreur","Au revoir"]
  18. piece=["l'Entrée","le Salon","la Salle à manger","la Salle de jeu","la Salle de reception","la Cuisine","la Chambre"]
  19. piece_2=["l'Entrée","le Salon","la Salle à manger","la Salle de jeu","la Salle de reception","la Cuisine","la Chambre"]
  20.  
  21. #fermer la fenetre
  22. def fin():
  23. launched = True
  24. while launched:
  25. for event in pygame.event.get():
  26. if event.type == pygame.QUIT:
  27. launched = False
  28.  
  29. if event.type == pygame.QUIT :
  30. pygame.quit()
  31.  
  32. #afficher un text
  33. def text1(word,x,y):
  34. text = font.render(word,1,black_color)
  35. fenetre.blit(text, (x, y))
  36. pygame.display.flip()
  37.  
  38. #afficher image
  39. def image(p):
  40. p = pygame.image.load(p)
  41. p.convert()
  42.  
  43. fenetre.fill(blank_color)
  44. fenetre.blit(p, [150, 100])
  45. pygame.display.flip()
  46.  
  47. #fonction entrée salle
  48. def entree_salle(liste_salle):
  49. temp="vous êtes entrée dans "
  50. temp_2=piece[liste_salle]
  51. temp_3=temp+temp_2
  52. return temp_3
  53.  
  54. #fonction principale(jeu)
  55. def main():
  56.  
  57. position=piece[0]
  58. continuer = 0
  59. touche=0
  60. while continuer == 0:
  61. #detection touche
  62. for event in pygame.event.get():
  63. if event.type == pygame.KEYDOWN:
  64. if event.key == pygame.K_ESCAPE:
  65. continuer = 1
  66. text1("Vous pouver fermer",1200,0)
  67. text1("Au revoir et A bientot",1000,0)
  68. if event.key == pygame.K_w:
  69. touche="z"
  70. if event.key == pygame.K_a:
  71. touche="q"
  72. if event.key == pygame.K_s:
  73. touche="s"
  74. if event.key == pygame.K_d:
  75. touche="d"
  76.  
  77. #mecanisme du jeu
  78. if touche==0:
  79. text1("bienvenu dans cluedo",500,0)
  80. image("cluedo.png")
  81. elif touche=="z" and position==piece[0]:
  82. fenetre.fill(blank_color)
  83. image("salon.png")
  84. text1(entree_salle(1),1000,400)
  85. position=piece[1]
  86. touche=""
  87. elif (touche=="q" or touche=="s" or touche=="d") and position==piece[0]:
  88. fenetre.fill(blank_color)
  89. image("entree.png")
  90. text1("vous ne pouver aller par là",1000,400)
  91. position=piece[0]
  92. touche=""
  93. elif touche=="q" and position==piece[1]:
  94. fenetre.fill(blank_color)
  95. image("salle a manger.png")
  96. text1(entree_salle(2),1000,400)
  97. position=piece[2]
  98. touche=""
  99. elif touche=="z" and position==piece[1]:
  100. fenetre.fill(blank_color)
  101. image("reception.png")
  102. text1(entree_salle(4),1000,400)
  103. position=piece[4]
  104. touche=""
  105. elif touche=="d" and position==piece[1]:
  106. fenetre.fill(blank_color)
  107. image("salle de jeu.png")
  108. text1(entree_salle(3),1000,400)
  109. position=piece[3]
  110. touche=""
  111. elif touche=="s" and position==piece[1]:
  112. fenetre.fill(blank_color)
  113. image("entree.png")
  114. text1(entree_salle(0),1000,400)
  115. position=piece[0]
  116. touche=""
  117. elif touche=="z" and position==piece[2]:
  118. fenetre.fill(blank_color)
  119. image("cuisine.png")
  120. text1(entree_salle(5),1000,400)
  121. position=piece[5]
  122. touche=""
  123. elif (touche=="q" or touche=="s" )and position==piece[2]:
  124. fenetre.fill(blank_color)
  125. image("salle a manger.png")
  126. text1("vous ne pouver aller par là",1000,400)
  127. position=piece[2]
  128. touche=""
  129. elif touche=="d" and position==piece[2]:
  130. fenetre.fill(blank_color)
  131. image("salon.png")
  132. text1(entree_salle(1),1000,400)
  133. position=piece[1]
  134. touche=""
  135. elif touche=="q" and position==piece[3]:
  136. fenetre.fill(blank_color)
  137. image("salon.png")
  138. text1(entree_salle(1),1000,400)
  139. position=piece[1]
  140. touche=""
  141. elif touche=="z" and position==piece[3]:
  142. fenetre.fill(blank_color)
  143. image("chambre.png")
  144. text1(entree_salle(6),1000,400)
  145. position=piece[6]
  146. touche=""
  147. elif (touche=="s" or touche=="d") and position==piece[3]:
  148. fenetre.fill(blank_color)
  149. image("salle de jeu.png")
  150. text1("vous ne pouver aller par là",1000,400)
  151. position=piece[3]
  152. touche=""
  153. elif touche=="z" and position==piece[4]:
  154. fenetre.fill(blank_color)
  155. image("reception.png")
  156. text1("vous ne pouver aller par là",1000,400)
  157. position=piece[4]
  158. touche=""
  159. elif touche=="q" and position==piece[4]:
  160. fenetre.fill(blank_color)
  161. image("cuisine.png")
  162. text1(entree_salle(5),1000,400)
  163. position=piece[5]
  164. touche=""
  165. elif touche=="s" and position==piece[4]:
  166. fenetre.fill(blank_color)
  167. image("salon.png")
  168. text1(entree_salle(1),1000,400)
  169. position=piece[1]
  170. touche=""
  171. elif touche=="d" and position==piece[4]:
  172. fenetre.fill(blank_color)
  173. image("chambre.png")
  174. text1(entree_salle(6),1000,400)
  175. position=piece[6]
  176. touche=""
  177. elif (touche=="z" or touche=="q") and position==piece[5]:
  178. fenetre.fill(blank_color)
  179. image("cuisine.png")
  180. text1("vous ne pouver aller par là",1000,400)
  181. position=piece[5]
  182. touche=""
  183. elif touche=="s" and position==piece[5]:
  184. fenetre.fill(blank_color)
  185. image("salle a manger.png")
  186. text1(entree_salle(2),1000,400)
  187. position=piece[2]
  188. touche=""
  189. elif touche=="d" and position==piece[5]:
  190. fenetre.fill(blank_color)
  191. image("reception.png")
  192. text1(entree_salle(4),1000,400)
  193. position=piece[4]
  194. touche=""
  195. elif (touche=="z" or touche=="d") and position==piece[6]:
  196. fenetre.fill(blank_color)
  197. image("chambre.png")
  198. text1("vous ne pouver aller par là",1000,400)
  199. position=piece[6]
  200. touche=""
  201. elif touche=="s" and position==piece[6]:
  202. fenetre.fill(blank_color)
  203. image("salle de jeu.png")
  204. text1(entree_salle(3),1000,400)
  205. position=piece[3]
  206. touche=""
  207. elif touche=="q" and position==piece[6]:
  208. fenetre.fill(blank_color)
  209. image("reception.png")
  210. text1(entree_salle(4),1000,400)
  211. position=piece[4]
  212. touche=""
  213.  
  214. main()
  215. fin()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement