Advertisement
Black_Albatros

v2

Jun 7th, 2023
19
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.73 KB | None | 0 0
  1. # -*- coding: utf-8 -*-
  2. """
  3. Created on Wed Jun 7 14:24:04 2023
  4.  
  5. @author: Utilisateur
  6. """
  7.  
  8. from colorama import Style, Fore
  9.  
  10. def affichage(tab):
  11. for i in range(0,10):
  12. for j in range(0,10):
  13. if tab[i][j] == 1:
  14. print("\t",'■', end = '')
  15. elif tab[i][j] == 0:
  16. print("\t",'.', end = '')
  17. elif tab[i][j] == 3:
  18. print("\t",'ᗧ', end = '')
  19. elif tab[i][j] == 2:
  20. print("\t",'●', end = '')
  21. elif tab[i][j] == 4:
  22. print("\t",'👻', end = '')
  23.  
  24. print("\n")
  25.  
  26. def main():
  27. while True:
  28. choix = menu() # affichage du menu principal
  29. if choix == '1':
  30. break # lancement d'une partie
  31. if choix == '2':
  32. afficher_regles()
  33. main()
  34. if choix == '3':
  35. afficher_credits()
  36. main()
  37. elif choix == '4':
  38. print(Style.BRIGHT + Fore.GREEN +"Au revoir!\n")
  39. print(Style.RESET_ALL)
  40.  
  41.  
  42.  
  43. def menu():
  44. print(Style.NORMAL + Fore.BLUE +"\n MENU \n")
  45. print(Style.BRIGHT + Fore.YELLOW +"1 ― Lancer une partie ")
  46. print(Style.NORMAL + Fore.RED +"2 ― Règles du jeu")
  47. print(Style.BRIGHT + Fore.WHITE + "3 - Crédits")
  48. print(Style.BRIGHT + Fore.GREEN +"4 ― Quitter")
  49. print(Style.RESET_ALL)
  50. choix = input("Entrez le numéro de votre choix : ")
  51. return choix
  52.  
  53. def afficher_regles():
  54. print(Style.NORMAL + Fore.YELLOW +"\n REGLES \n")
  55. print(Style.RESET_ALL)
  56. print("Le pacman doit manger les pac-gommes pour gagner des points tout en évitant de se faire manger par les fantomes")
  57. print("Lorsque que le pacman mange un pac-gomme il gagne 1 point. Dans ce cas il a la posibilité de manger des fantomes pendant 5 tours.")
  58. print("Lorque qu'il mange un fantome il gagne 5 points.La partie s'arrête quand le joueur n'a plus de vie ou qu'il a mangé tous les fantomes et pac-gommes ")
  59.  
  60. def afficher_credits():
  61. print(Style.BRIGHT + Fore.RED +"\n CREDITS \n")
  62. print(Style.RESET_ALL)
  63. print("Développé par Paul Reffay et Antoine Amiot")
  64.  
  65.  
  66. main()
  67.  
  68.  
  69. def affich(tab):
  70. from colorama import Style, Fore
  71. joueur = input(Style.BRIGHT + Fore.RED + "Nom du joueur : ")
  72. print(Style.RESET_ALL)
  73. print (joueur)
  74. for i in range (10):
  75. for j in range (10):
  76. print ("\t", tab[i][j],end='')
  77. print()
  78.  
  79. bg =[]
  80. bg_size=[10,10]
  81. for i in range(bg_size[0]):
  82. line =[]
  83. for j in range(bg_size[1]):
  84. line.append('0')
  85. bg.append(line)
  86.  
  87. for i in range(bg_size[0]):
  88. for j in range(bg_size[1]):
  89. if (i == 0 or i == 9 or j == 0 or j == 9):
  90. bg[i][j] = 1
  91. else:
  92. bg[i][j] = 0
  93.  
  94.  
  95.  
  96. bg [2][2] = 1
  97. bg [2][3] = 1
  98. bg [3][2] = 1
  99. bg [4][2] = 1
  100. bg [5][2] = 1
  101. bg [2][5] = 1
  102. bg [2][6] = 1
  103. bg [2][7] = 1
  104. bg [2][8] = 1
  105. bg [4][4] = 1
  106. bg [4][6] = 1
  107. bg [4][7] = 1
  108. bg [5][7] = 1
  109. bg [7][2] = 1
  110. bg [7][3] = 1
  111. bg [7][4] = 1
  112. bg [7][5] = 1
  113. bg [7][7] = 1
  114. bg [6][4] = 1
  115. bg [6][5] = 1
  116.  
  117. #pac gomme
  118. bg [1][8] = 2
  119. bg [8][2] = 2
  120. bg [3][3] = 2
  121.  
  122. #pac man
  123. position = [3, 1]
  124. bg [position[0]][position[1]] = 3
  125.  
  126.  
  127. #fantomes
  128. bg [8][8] = 4
  129. bg [6][6] = 4
  130.  
  131. score = 0
  132.  
  133. is_ended = False
  134. affichage(bg)
  135.  
  136. while (not is_ended):
  137.  
  138.  
  139.  
  140. command = input("Entrez votre déplacement :\nGauche : 4 ; Droite : 6 ; Haut : 8 ; Bas : 2\n")
  141.  
  142. if ((command == '4')
  143. and (bg[position[0]][position[1] - 1] != 1)):
  144. print("Déplacement possible...")
  145. bg[position[0]][position[1]] = 0
  146. position[1] = position[1]-1
  147. bg[position[0]][position[1]] = 3
  148. print(position)
  149.  
  150. elif ((command == '8')
  151. and (bg[position[0]-1][position[1]] != 1)):
  152. print("Déplacement possible...")
  153. bg[position[0]][position[1]] = 0
  154. position[0] = position[0] -1
  155. bg[position[0]][position[1]] = 3
  156. print(position)
  157.  
  158. elif ((command == '2')
  159. and (bg[position[0]+1][ position[1]] != 1)):
  160. print("Déplacement possible...")
  161. bg[position[0]][position[1]] = 0
  162. position[0] = position[0] +1
  163. bg[position[0]][position[1]] = 3
  164. print(position)
  165.  
  166. elif ((command == '6')
  167. and (bg[position[0]][position[1] + 1] != 1)):
  168. print("Déplacement possible...")
  169. bg[position[0]][position[1]] = 0
  170. position[1] = position[1] +1
  171. bg[position[0]][position[1]] = 3
  172. print(position)
  173. else :
  174. print ("deplacement impossible")
  175.  
  176.  
  177.  
  178. if ((command == '4')
  179. and (bg[position[0]][position[1] - 1] == 2)):
  180. bg[position[0]][position[1]] = 0
  181. position[1] = position[1]-1
  182. bg[position[0]][position[1]] = 3
  183. score = score +1
  184.  
  185. elif ((command == '8')
  186. and (bg[position[0]-1][position[1]] == 2)):
  187. bg[position[0]][position[1]] = 0
  188. position[0] = position[0] -1
  189. bg[position[0]][position[1]] = 3
  190. score = score +1
  191.  
  192. elif ((command == '2')
  193. and (bg[position[0]+1][ position[1]] == 2)):
  194. bg[position[0]][position[1]] = 0
  195. position[0] = position[0] +1
  196. bg[position[0]][position[1]] = 3
  197. score = score +1
  198.  
  199. elif ((command == '6')
  200. and (bg[position[0]][position[1] + 1] == 2)):
  201. bg[position[0]][position[1]] = 0
  202. position[1] = position[1] +1
  203. bg[position[0]][position[1]] = 3
  204. score = score +1
  205.  
  206.  
  207.  
  208.  
  209. if ((command == '4')
  210. and (bg[position[0]][position[1] - 1] == 4)):
  211.  
  212. bg[position[0]][position[1]] = 0
  213. position[1] = position[1]-1
  214. bg[position[0]][position[1]] = 4
  215. affichage(bg)
  216. print ("tu as perdu")
  217. is_ended = True
  218.  
  219. elif ((command == '8')
  220. and (bg[position[0]-1][position[1]] == 4)):
  221. bg[position[0]][position[1]] = 0
  222. position[0] = position[0] -1
  223. bg[position[0]][position[1]] = 4
  224. affichage(bg)
  225. print ("tu as perdu")
  226. is_ended = True
  227. elif ((command == '2')
  228. and (bg[position[0]+1][ position[1]] == 4)):
  229. bg[position[0]][position[1]] = 0
  230. position[0] = position[0] +1
  231. bg[position[0]][position[1]] = 4
  232. affichage(bg)
  233. print ("tu as perdu")
  234. is_ended = True
  235. elif ((command == '6')
  236. and (bg[position[0]][position[1] + 1] == 4)):
  237. bg[position[0]][position[1]] = 0
  238. position[1] = position[1] +1
  239. bg[position[0]][position[1]] = 4
  240. affichage(bg)
  241. print ("tu as perdu")
  242. is_ended = True
  243.  
  244.  
  245.  
  246. affichage(bg)
  247.  
  248.  
  249.  
  250.  
  251.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement