Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # -*- coding: utf-8 -*-
- """
- Created on Wed Jun 7 14:24:04 2023
- @author: Utilisateur
- """
- 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("\n")
- def main():
- while True:
- choix = menu() # affichage du menu principal
- if choix == '1':
- break # lancement d'une partie
- if choix == '2':
- afficher_regles()
- main()
- if choix == '3':
- afficher_credits()
- main()
- elif choix == '4':
- print(Style.BRIGHT + Fore.GREEN +"Au revoir!\n")
- print(Style.RESET_ALL)
- def menu():
- print(Style.NORMAL + Fore.BLUE +"\n MENU \n")
- print(Style.BRIGHT + Fore.YELLOW +"1 ― Lancer une partie ")
- print(Style.NORMAL + Fore.RED +"2 ― Règles du jeu")
- print(Style.BRIGHT + Fore.WHITE + "3 - Crédits")
- print(Style.BRIGHT + Fore.GREEN +"4 ― Quitter")
- print(Style.RESET_ALL)
- choix = input("Entrez le numéro de votre choix : ")
- return choix
- def afficher_regles():
- print(Style.NORMAL + Fore.YELLOW +"\n REGLES \n")
- print(Style.RESET_ALL)
- print("Le pacman doit manger les pac-gommes pour gagner des points tout en évitant de se faire manger par les fantomes")
- 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.")
- 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 ")
- def afficher_credits():
- print(Style.BRIGHT + Fore.RED +"\n CREDITS \n")
- print(Style.RESET_ALL)
- print("Développé par Paul Reffay et Antoine Amiot")
- main()
- def affich(tab):
- from colorama import Style, Fore
- joueur = input(Style.BRIGHT + Fore.RED + "Nom du joueur : ")
- print(Style.RESET_ALL)
- print (joueur)
- for i in range (10):
- for j in range (10):
- print ("\t", tab[i][j],end='')
- print()
- 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
- bg [8][8] = 4
- bg [6][6] = 4
- score = 0
- is_ended = False
- affichage(bg)
- while (not is_ended):
- 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)):
- print("Déplacement possible...")
- bg[position[0]][position[1]] = 0
- position[1] = position[1]-1
- bg[position[0]][position[1]] = 3
- print(position)
- elif ((command == '8')
- and (bg[position[0]-1][position[1]] != 1)):
- print("Déplacement possible...")
- bg[position[0]][position[1]] = 0
- position[0] = position[0] -1
- bg[position[0]][position[1]] = 3
- print(position)
- elif ((command == '2')
- and (bg[position[0]+1][ position[1]] != 1)):
- print("Déplacement possible...")
- bg[position[0]][position[1]] = 0
- position[0] = position[0] +1
- bg[position[0]][position[1]] = 3
- print(position)
- elif ((command == '6')
- and (bg[position[0]][position[1] + 1] != 1)):
- print("Déplacement possible...")
- bg[position[0]][position[1]] = 0
- position[1] = position[1] +1
- bg[position[0]][position[1]] = 3
- print(position)
- else :
- print ("deplacement impossible")
- if ((command == '4')
- and (bg[position[0]][position[1] - 1] == 2)):
- bg[position[0]][position[1]] = 0
- position[1] = position[1]-1
- bg[position[0]][position[1]] = 3
- score = score +1
- elif ((command == '8')
- and (bg[position[0]-1][position[1]] == 2)):
- bg[position[0]][position[1]] = 0
- position[0] = position[0] -1
- bg[position[0]][position[1]] = 3
- score = score +1
- elif ((command == '2')
- and (bg[position[0]+1][ position[1]] == 2)):
- bg[position[0]][position[1]] = 0
- position[0] = position[0] +1
- bg[position[0]][position[1]] = 3
- score = score +1
- elif ((command == '6')
- and (bg[position[0]][position[1] + 1] == 2)):
- bg[position[0]][position[1]] = 0
- position[1] = position[1] +1
- bg[position[0]][position[1]] = 3
- score = score +1
- if ((command == '4')
- and (bg[position[0]][position[1] - 1] == 4)):
- bg[position[0]][position[1]] = 0
- position[1] = position[1]-1
- bg[position[0]][position[1]] = 4
- affichage(bg)
- print ("tu as perdu")
- is_ended = True
- elif ((command == '8')
- and (bg[position[0]-1][position[1]] == 4)):
- bg[position[0]][position[1]] = 0
- position[0] = position[0] -1
- bg[position[0]][position[1]] = 4
- affichage(bg)
- print ("tu as perdu")
- is_ended = True
- elif ((command == '2')
- and (bg[position[0]+1][ position[1]] == 4)):
- bg[position[0]][position[1]] = 0
- position[0] = position[0] +1
- bg[position[0]][position[1]] = 4
- affichage(bg)
- print ("tu as perdu")
- is_ended = True
- elif ((command == '6')
- and (bg[position[0]][position[1] + 1] == 4)):
- bg[position[0]][position[1]] = 0
- position[1] = position[1] +1
- bg[position[0]][position[1]] = 4
- affichage(bg)
- print ("tu as perdu")
- is_ended = True
- affichage(bg)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement