Advertisement
KreeZe

Untitled

Nov 13th, 2019
138
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 8.26 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.SysFont("Arial", 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 choix random (sortie indice_I/II/III et presence_I/II/III)
  48. indice_1=randint(0,5)
  49. indice_I=indice[indice_1]
  50. del indice[indice_1]
  51. indice_2=randint(0,5-1)
  52. indice_II=indice[indice_2]
  53. del indice[indice_2]
  54. indice_3=randint(0,5-2)
  55. indice_III=indice[indice_3]
  56. del indice[indice_3]
  57.  
  58. presence_1=randint(1,5)
  59. presence_I=piece_2[presence_1]
  60. del piece_2[presence_1]
  61. presence_2=randint(1,5-1)
  62. presence_II=piece_2[presence_2]
  63. del piece_2[presence_2]
  64. presence_3=randint(1,5-2)
  65. presence_III=piece_2[presence_3]
  66. del piece_2[presence_3]
  67.  
  68. #fonction entrée salle
  69. def entree_salle(liste_salle):
  70. temp="vous êtes entrée dans "
  71. temp_2=piece[liste_salle]
  72. temp_3=temp+temp_2
  73. return temp_3
  74.  
  75. #fonction principale(jeu)
  76. def main():
  77. position=piece[0]
  78. continuer = 0
  79. touche=0
  80. while continuer == 0:
  81. #detection touche
  82. for event in pygame.event.get():
  83. if event.type == pygame.KEYDOWN:
  84. if event.key == pygame.K_ESCAPE:
  85. continuer = 1
  86. text1("Vous pouvez fermer",1130,0)
  87. text1("Au revoir et A bientot",800,0)
  88. if event.key == pygame.K_w:
  89. touche="z"
  90. if event.key == pygame.K_a:
  91. touche="q"
  92. if event.key == pygame.K_s:
  93. touche="s"
  94. if event.key == pygame.K_d:
  95. touche="d"
  96.  
  97. #mecanisme du jeu
  98. if touche==0:
  99. text1("bienvenu dans cluedo",500,0)
  100. image("cluedo.png")
  101. elif touche=="z" and position==piece[0]:
  102. fenetre.fill(blank_color)
  103. image("salon.png")
  104. text1(entree_salle(1),900,400)
  105. position=piece[1]
  106. touche=""
  107. elif (touche=="q" or touche=="s" or touche=="d") and position==piece[0]:
  108. fenetre.fill(blank_color)
  109. image("entree.png")
  110. text1("vous ne pouver aller par là",900,400)
  111. position=piece[0]
  112. touche=""
  113. elif touche=="q" and position==piece[1]:
  114. fenetre.fill(blank_color)
  115. image("salle a manger.png")
  116. text1(entree_salle(2),900,400)
  117. position=piece[2]
  118. touche=""
  119. elif touche=="z" and position==piece[1]:
  120. fenetre.fill(blank_color)
  121. image("reception.png")
  122. text1(entree_salle(4),900,400)
  123. position=piece[4]
  124. touche=""
  125. elif touche=="d" and position==piece[1]:
  126. fenetre.fill(blank_color)
  127. image("salle de jeu.png")
  128. text1(entree_salle(3),900,400)
  129. position=piece[3]
  130. touche=""
  131. elif touche=="s" and position==piece[1]:
  132. fenetre.fill(blank_color)
  133. image("entree.png")
  134. text1(entree_salle(0),900,400)
  135. position=piece[0]
  136. touche=""
  137. elif touche=="z" and position==piece[2]:
  138. fenetre.fill(blank_color)
  139. image("cuisine.png")
  140. text1(entree_salle(5),900,400)
  141. position=piece[5]
  142. touche=""
  143. elif (touche=="q" or touche=="s" )and position==piece[2]:
  144. fenetre.fill(blank_color)
  145. image("salle a manger.png")
  146. text1("vous ne pouver aller par là",900,400)
  147. position=piece[2]
  148. touche=""
  149. elif touche=="d" and position==piece[2]:
  150. fenetre.fill(blank_color)
  151. image("salon.png")
  152. text1(entree_salle(1),900,400)
  153. position=piece[1]
  154. touche=""
  155. elif touche=="q" and position==piece[3]:
  156. fenetre.fill(blank_color)
  157. image("salon.png")
  158. text1(entree_salle(1),900,400)
  159. position=piece[1]
  160. touche=""
  161. elif touche=="z" and position==piece[3]:
  162. fenetre.fill(blank_color)
  163. image("chambre.png")
  164. text1(entree_salle(6),900,400)
  165. position=piece[6]
  166. touche=""
  167. elif (touche=="s" or touche=="d") and position==piece[3]:
  168. fenetre.fill(blank_color)
  169. image("salle de jeu.png")
  170. text1("vous ne pouver aller par là",900,400)
  171. position=piece[3]
  172. touche=""
  173. elif touche=="z" and position==piece[4]:
  174. fenetre.fill(blank_color)
  175. image("reception.png")
  176. text1("vous ne pouver aller par là",900,400)
  177. position=piece[4]
  178. touche=""
  179. elif touche=="q" and position==piece[4]:
  180. fenetre.fill(blank_color)
  181. image("cuisine.png")
  182. text1(entree_salle(5),900,400)
  183. position=piece[5]
  184. touche=""
  185. elif touche=="s" and position==piece[4]:
  186. fenetre.fill(blank_color)
  187. image("salon.png")
  188. text1(entree_salle(1),900,400)
  189. position=piece[1]
  190. touche=""
  191. elif touche=="d" and position==piece[4]:
  192. fenetre.fill(blank_color)
  193. image("chambre.png")
  194. text1(entree_salle(6),900,400)
  195. position=piece[6]
  196. touche=""
  197. elif (touche=="z" or touche=="q") and position==piece[5]:
  198. fenetre.fill(blank_color)
  199. image("cuisine.png")
  200. text1("vous ne pouver aller par là",900,400)
  201. position=piece[5]
  202. touche=""
  203. elif touche=="s" and position==piece[5]:
  204. fenetre.fill(blank_color)
  205. image("salle a manger.png")
  206. text1(entree_salle(2),900,400)
  207. position=piece[2]
  208. touche=""
  209. elif touche=="d" and position==piece[5]:
  210. fenetre.fill(blank_color)
  211. image("reception.png")
  212. text1(entree_salle(4),900,400)
  213. position=piece[4]
  214. touche=""
  215. elif (touche=="z" or touche=="d") and position==piece[6]:
  216. fenetre.fill(blank_color)
  217. image("chambre.png")
  218. text1("vous ne pouver aller par là",900,400)
  219. position=piece[6]
  220. touche=""
  221. elif touche=="s" and position==piece[6]:
  222. fenetre.fill(blank_color)
  223. image("salle de jeu.png")
  224. text1(entree_salle(3),900,400)
  225. position=piece[3]
  226. touche=""
  227. elif touche=="q" and position==piece[6]:
  228. fenetre.fill(blank_color)
  229. image("reception.png")
  230. text1(entree_salle(4),900,400)
  231. position=piece[4]
  232. touche=""
  233.  
  234. #detection decouverte indice
  235. if position==presence_I:
  236. text1("vous avez trouvé un indice : "+indice_I,900,450)
  237. elif position==presence_II:
  238. text1("vous avez trouvé un indice : "+indice_II,900,450)
  239. elif position==presence_III:
  240. text1("vous avez trouvé un indice : "+indice_III,900,450)
  241.  
  242. main()
  243. fin()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement