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("\n")
- print("\n")
- 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 aux 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':
- # grid()
- break
- 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)
- return fin()
- def grid():
- 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
- return bg
- bg = grid()
- 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
- score = 0
- def le_mouvement_est_valide(direction, position, grid):
- if (direction == "gauche" and grid[position[0]][position[1] - 1] != 1):
- return True
- elif (direction == "droite" and grid[position[0]][position[1] + 1] != 1):
- return True
- elif (direction == "bas" and grid[position[0]+1][ position[1]] != 1):
- return True
- elif (direction == "haut" and grid[position[0]-1][position[1]] != 1):
- return True
- # def mouvement_fantome :
- # def fantome_en_face(direction, position, grid):
- # if (direction == "gauche" and grid[position[0]][position[1] - 1] == 4):
- # return True
- # elif (direction == "droite" and grid[position[0]][position[1] + 1] == 4):
- # return True
- # elif (direction == "bas" and grid[position[0]+1][ position[1]] == 4):
- # return True
- # elif (direction == "haut" and grid[position[0]-1][position[1]] == 4):
- # return True
- # def super_en_face (direction, position,grid):
- # if (direction == "gauche" and grid[position[0]][position[1] - 1] == 2):
- # return True
- # elif (direction == "droite" and grid[position[0]][position[1] + 1] == 2):
- # return True
- # elif (direction == "bas" and grid[position[0]+1][ position[1]] == 2):
- # return True
- # elif (direction == "haut" and grid[position[0]-1][position[1]] == 2):
- # return True
- def goTo(direction, position):
- nouvelle_position = position
- if (direction == "bas"):
- nouvelle_position[0] += 1
- elif (direction == "haut"):
- nouvelle_position[0] -= 1
- elif (direction == "gauche"):
- nouvelle_position[1] -= 1
- elif (direction == "droite"):
- nouvelle_position[1] += 1
- return nouvelle_position
- # def gotoftm
- is_ended = False
- while (not is_ended):
- # main()
- affichage(bg)
- command = input("Entrez votre déplacement :\nGauche : 4 ; Droite : 6 ; Haut : 8 ; Bas : 2\n")
- """
- Gestion des touches pour les directions
- """
- if (command == "4"):
- direction = "gauche"
- elif (command == "6"):
- direction = "droite"
- elif (command == "8"):
- direction = "haut"
- elif (command == "2"):
- direction = "bas"
- if (le_mouvement_est_valide(direction, position, bg)): # Si le déplacement est valide / possible
- print("Déplacement possible...")
- bg[position[0]][position[1]] = 0 # Le pacman n'est plus à l'ancienne position
- position = goTo(direction, position) # J'actualise la position
- bg[position[0]][position[1]] = 3 # Je mets à jour la grid
- print("La nouvelle position est", position)
- else :
- print("Déplacement impossible...")
- # if (fantome_en_face(direction, position, grid)):
- # print("Tu as perdu")
- # bg[position[0]][position[1]] = 0
- # position = goTo(direction, position)
- # bg[position[0]][position[1]] = 4
- # fin()
- # if (super_en_face(direction, position, grid)):
- # bg[position[0]][position[1]] = 0
- # position = goTo(direction, position)
- # bg[position[0]][position[1]] = 3
- # score = score + 1
- # 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