Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from colorama import Style, Fore
- def affichage(tab):
- for i in range(0,10):
- for j in range(0,10):
- if tab[i][j] == 1:
- print("\t",'■', end = '')
- elif tab[i][j] == 0:
- print("\t",'.', end = '')
- elif tab[i][j] == 3:
- print("\t",'ᗧ', end = '')
- elif tab[i][j] == 2:
- print("\t",'●', end = '')
- elif tab[i][j] == 4:
- print("\t",'👻', end = '')
- print()
- def affich(tab):
- for i in range (10):
- for j in range (10):
- print ("\t", tab[i][j],end='')
- print()
- def fin ():
- print("~ PARTIE TERMINEE ~/n Voulez vous rejouer ? ")
- def menu ():
- print(Style.NORMAL + Fore.GREEN +"\n――――――― MENU ―――――――\n")
- print(Style.BRIGHT + Fore.MAGENTA +"1 ― Lancer une partie ")
- print(Style.BRIGHT + Fore.CYAN +"2 ― Afficher les règles")
- print((Style.BRIGHT + Fore.BLUE) +"3 ― Afficher les crédits")
- print(Style.BRIGHT + Fore.GREEN +"4 ― Quitter\n")
- print(Style.RESET_ALL)
- choix = input("Entrez le numéro de votre choix : ")
- return choix
- def rules():
- print(Style.NORMAL + Fore.CYAN +"\n―――――――――――――――――――― REGLES ――――――――――――――――――――\n")
- print(Style.RESET_ALL)
- print("Le Pac-man est un jeu où il faut accumuler des points pour gagner")
- print("Vous êtes le Pac-man, pour gagner vous devez collecter des super gommes.")
- print("Ces dernieres vous immunisent au fantomes et vous permet de les manger. ")
- print("Attention si un fantome vous touche sans que vous soyer sous super vous perdez 1 vie ")
- print("Vous disposer d'un total de 3 vies")
- print("Bonne chance !!.")
- def crédits():
- print(Style.BRIGHT + Fore.BLUE +"\n――――――――――――――――― CREDITS ―――――――――――――――――\n")
- print(Style.RESET_ALL)
- print("Développé par AMIOT Antoine et REFFAY Paul")
- def main():
- while True:
- choix = menu() # affichage du menu principal et récupération du choix de l'utilisateur
- if choix == '1':
- jeu() # lancement d'une partie de puissance 4
- main()
- if choix == '2':
- rules()
- main()
- if choix == '3':
- crédits()
- main()
- elif choix == '4':
- print(Style.BRIGHT + Fore.GREEN +"Au revoir!\n")
- print(Style.RESET_ALL)
- break
- def jeu():
- bg =[]
- bg_size=[10,10]
- for i in range(bg_size[0]):
- line =[]
- for j in range(bg_size[1]):
- line.append('0')
- bg.append(line)
- for i in range(bg_size[0]):
- for j in range(bg_size[1]):
- if (i == 0 or i == 9 or j == 0 or j == 9):
- bg[i][j] = 1
- else:
- bg[i][j] = 0
- bg [2][2] = 1
- bg [2][3] = 1
- bg [3][2] = 1
- bg [4][2] = 1
- bg [5][2] = 1
- bg [2][5] = 1
- bg [2][6] = 1
- bg [2][7] = 1
- bg [2][8] = 1
- bg [4][4] = 1
- bg [4][6] = 1
- bg [4][7] = 1
- bg [5][7] = 1
- bg [7][2] = 1
- bg [7][3] = 1
- bg [7][4] = 1
- bg [7][5] = 1
- bg [7][7] = 1
- bg [6][4] = 1
- bg [6][5] = 1
- #pac gomme
- bg [1][8] = 2
- bg [8][2] = 2
- bg [3][3] = 2
- #pac man
- position = [3, 1]
- bg [position[0]][position[1]] = 3
- #fantomes
- ft1 = [8,8]
- ft2 = [6,6]
- bg [ft1[0]][ft1[1]] = 4
- bg [ft2[0]][ft2[1]] = 4
- affich(bg)
- affichage(bg)
- def droite():
- print("Déplacement possible...")
- bg[position[0]][position[1]] = 0
- position[1] = position[1]-1
- bg[position[0]][position[1]] = 3
- print(position)
- def haut():
- print("Déplacement possible...")
- bg[position[0]][position[1]] = 0
- position[0] = position[0] -1
- bg[position[0]][position[1]] = 3
- print(position)
- def bas():
- print("Déplacement possible...")
- bg[position[0]][position[1]] = 0
- position[0] = position[0] +1
- bg[position[0]][position[1]] = 3
- print(position)
- def gauche():
- print("Déplacement possible...")
- bg[position[0]][position[1]] = 0
- position[1] = position[1] +1
- bg[position[0]][position[1]] = 3
- print(position)
- jeu()
- is_ended = False
- while (not is_ended):
- jeu()
- command = input("Entrez votre déplacement :\nGauche : 4 ; Droite : 6 ; Haut : 8 ; Bas : 2\n")
- if ((command == '4')
- and (bg[position[0]][position[1] - 1] != 1)):
- gauche()
- elif ((command == '8')
- and (bg[position[0]-1][position[1]] != 1)):
- haut()
- elif ((command == '2')
- and (bg[position[0]+1][ position[1]] != 1)):
- bas()
- elif ((command == '6')
- and (bg[position[0]][position[1] + 1] != 1)):
- droite()
- else :
- print ("deplacement impossible")
- if ((command == '4')
- and (bg[position[0]][position[1] - 1] == 4)):
- gauche()
- print ("tu as perdu")
- bg[position[0]][position[1]] = 4
- is_ended = True
- fin ()
- elif ((command == '8')
- and (bg[position[0]-1][position[1]] == 4)):
- haut()
- print ("tu as perdu")
- bg[position[0]][position[1]] = 4
- is_ended = True
- fin ()
- elif ((command == '2')
- and (bg[position[0]+1][ position[1]] == 4)):
- bas()
- print ("tu as perdu")
- bg[position[0]][position[1]] = 4
- is_ended = True
- fin ()
- elif ((command == '6')
- and (bg[position[0]][position[1] + 1] == 4)):
- droite()
- print ("tu as perdu")
- bg[position[0]][position[1]] = 4
- is_ended = True
- fin ()
- main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement