Advertisement
ertale

jeu

May 8th, 2019
317
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 59.03 KB | None | 0 0
  1. #!/usr/bin/python3
  2. # -*- coding: Utf-8 -*
  3.  
  4. """
  5.  
  6. Project de BAC ISN, Alexandre REPPERT, Saina MARQUET, Raphael CAMUS
  7. Capture de drapeau
  8.  
  9. Script Python
  10. Fichiers : pjetfinal.py, classes.py, constantes.py, images, sons, n0, n1, n2, n3, n4, n5, n6, n8, n9, niveau surprise
  11.  
  12. """
  13.  
  14. import pygame
  15. from pygame.locals import *
  16. from classes import *
  17. from constantes import *
  18. from fonction import *
  19. import random
  20. import time
  21.  
  22. pygame.init()
  23.  
  24. ###---Ouverture fenetre---###
  25. fenetre = pygame.display.set_mode((cote_fenetre, cote_fenetre), pygame.RESIZABLE)
  26.  
  27. ###---Icone---###
  28. icone = pygame.image.load(image_icone)
  29. pygame.display.set_icon(icone)
  30.  
  31. ###---Titre---###
  32. pygame.display.set_caption(titre_fenetre)
  33.  
  34. ###---Variable qu'il ne faut charger qu'a l'ouverture du jeu---###
  35. DPG = 10
  36. pdb = 2
  37. tpsf = 60
  38. vol = 1 #-volume au maximum ( d'ou le 1 )-#
  39.  
  40. ###---Sons---###
  41. son_tir = pygame.mixer.Sound(son_tir)
  42. son_gain = pygame.mixer.Sound(son_fin)
  43. son_mouton = pygame.mixer.Sound(son_mouton)
  44. pygame.mixer.music.load(son_menu)
  45. barre_son = pygame.image.load(image_barre_son_1).convert_alpha()
  46. pygame.mixer.music.play()
  47.  
  48. ###---BOUCLE PRINCIPALE---###
  49. continuer = 1
  50. while continuer:
  51.         accueil = pygame.image.load(image_accueil).convert()
  52.         fenetre.blit(accueil, (0,0))
  53.  
  54. ###---Lecture du son d'accueil---###
  55.        
  56. ###---Rafraichissement---###
  57.         pygame.display.flip()
  58.  
  59. ###---variable mis a jour a chaque retour a la boucle principale---###
  60.         Munition_Joueur1 = 8
  61.         Munition_Joueur2 = 8
  62.         munition_Grenade_Item_Joueur1 = 3
  63.         Score_Joueur1 = 0
  64.         DEM_Joueur1 = 0
  65.         DEM_Joueur2 = 0
  66.         Score_Joueur2 = 0
  67.         stl = 1
  68.         drapeau_spawn = 0
  69.         t = time.time()
  70.         recharge_tireJoueur1 = t - t
  71.         recharge_tireJoueur2 = t - t
  72.         Joueur1_Vole_DP = t - t
  73.         Joueur2_Vole_DP = t - t
  74.         Temps_Explo_Grenade = t - t
  75.         Temps_Sup_Explo = t - t
  76.         Temps_Spawn_Drapeau = t - t + 10
  77.         ##--variable des boucle--##
  78.         continuer_jeu = 1
  79.         continuer_accueil = 1
  80.         continuer_option = 1
  81.         continuer_credit = 1
  82.         continuer_commande = 1
  83.         continuer_choix_niveau = 1
  84.         continuer_choix_son_jeu = 1
  85.         continuer_parametre = 1
  86.         continuer_ChoixJoueur = 1
  87.         continuer_Victoire_Joueur1 = 1
  88.         continuer_Victoire_Joueur2 = 1
  89.         ##--Liste--##
  90.         GRENADEJoueur1 = [] #liste contenant les coordonnées de la grenade du joueur 1
  91.         GRENADEJoueur2 = [] #liste contenant les coordonnées de la grenade du joueur 2
  92.         EXPLOJoueur1 = [] #liste contenant les coordonnées des explosions de la grenade du joueur 1
  93.         EXPLOJoueur2 = [] #liste contenant les coordonnées des explosions de la grenade du joueur 2
  94.  
  95. ########################################
  96. ##########---Boucle Accueil---##########
  97. ########################################
  98.  
  99.         while continuer_accueil:
  100.                 pygame.time.Clock().tick(30)
  101.                
  102.                 for event in pygame.event.get():
  103.                         if event.type == QUIT or event.type == KEYDOWN and event.key == K_ESCAPE:
  104.                                 pygame.quit()
  105.  
  106.                         elif event.type == pygame.MOUSEBUTTONUP:
  107.                                 x, y = event.pos
  108.                         ###---choix du menu---###
  109.                                 #-Jouer-#
  110.                                 if x >= 356 and x <= 550 and y >= 217 and y <= 321 :
  111.                                         continuer_accueil = 0
  112.                                         continuer_commande = 0
  113.                                         continuer_parametre = 0
  114.                                         continuer_option = 0
  115.                                         continuer_credit = 0
  116.                                        
  117.  
  118.                                 #-Option-#
  119.                                 elif x >= 345 and x <= 561 and y >= 394 and y <= 502 :
  120.                                         continuer_accueil = 0
  121.                                         continuer_commande = 0
  122.                                         continuer_parametre = 0
  123.                                         continuer_option = 1
  124.                                        
  125.                                 #-Commande-#
  126.                                 elif x >= 290 and x <= 614 and y >= 540 and y <= 626 :
  127.                                         continuer_accueil = 0
  128.                                         continuer_commande = 1
  129.                                         continuer_parametre = 0
  130.                                         continuer_option = 0
  131.                                         continuer_credit = 0
  132.                                        
  133.                                 #-Quitter-#
  134.                                 elif x >= 340 and x <= 563 and y >= 680 and y <= 745 :
  135.                                         pygame.quit()
  136.  
  137.                                 #-Credit-#
  138.                                 elif x >= 675 and x <= 891 and y >= 810 and y <= 894 :
  139.                                         pass
  140.  
  141.                                 elif 6 <= x <= 376 and 827 <= y <= 888 :
  142.                                         continuer_accueil = 0
  143.                                         continuer_parametre = 1
  144.                                         print(continuer_accueil)
  145.                                         print(continuer_parametre)
  146.  
  147. ########################################
  148. ##########---Boucle parametre---########
  149. ########################################
  150.                                        
  151.         while continuer_parametre:
  152.                 pygame.time.Clock().tick(30)
  153.                 parametre = pygame.image.load(image_parametre).convert()
  154.                 fenetre.blit(parametre, (0,0))
  155.                 pygame.display.flip()
  156.                 for event in pygame.event.get():
  157.                         if event.type == QUIT:
  158.                                 pygame.quit()
  159.                                
  160.                 ###---Pour les touches cliquable---###
  161.                         elif event.type == KEYDOWN:
  162.                                 if event.key == K_ESCAPE:
  163.                                         continuer_credit = 0
  164.                                         continuer_parametre = 0
  165.                                         continuer_option = 0
  166.                                         continuer_commande = 0
  167.                                         continuer_jeu = 0
  168.                                         continuer_choix_niveau = 0
  169.                                         continuer_choix_son_jeu = 0
  170.                                         choix = 0
  171.                                         continuer_ChoixJoueur = 0
  172.                                         continuer_accueil = 1
  173.                                         continuer_Victoire_Joueur1 = 0
  174.                                         continuer_Victoire_Joueur2 = 0
  175.  
  176.                         elif event.type == pygame.MOUSEBUTTONUP:
  177.                                 x, y = event.pos
  178.                                
  179.                         ##--Drapeau pour gagner--##
  180.                                 if 89 <= x <= 144 and 122 <= y <= 210 :
  181.                                         DPG = 5
  182.                                        
  183.                                 elif 240 <= x <= 331 and 122 <= y <= 210 :
  184.                                         DPG = 10
  185.                                        
  186.                                 elif 422 <= x <= 512 and 122 <= y <= 210 :
  187.                                         DPG = 15
  188.                                        
  189.                                 elif 592 <= x <= 824 and 124 <= y <= 210 :
  190.                                         DPG = 1000
  191.                                        
  192.                         ##--Portée de la bombe--##
  193.                                 elif 322 <= x <= 364 and 698 <= y <= 787 :
  194.                                         pdb = 1
  195.                                        
  196.                                 elif 539 <= x <= 600 and 698 <= y <= 787 :
  197.                                         pdb = 2
  198.                                        
  199.                         ##--Temps Maximum--##
  200.                                 elif 234 <= x <= 277 and 438 <= y <= 525:
  201.                                         tpsf = 15
  202.  
  203.                                 elif 423 <= x <= 483 and 438 <= y <= 525:
  204.                                         tpsf = 120
  205.  
  206.                                 elif 600 <= x <= 667 and 438 <= y <= 525:
  207.                                         tpsf = 180
  208.                                        
  209. ########################################
  210. ###########---Boucle option---##########
  211. ########################################
  212.  
  213.         while continuer_option:
  214.                 pygame.time.Clock().tick(30)
  215.                 menu_option = pygame.image.load(image_menu_option).convert()
  216.                 fenetre.blit(menu_option, (0,0))
  217.                 fenetre.blit(barre_son, (198, 70))         #########a remettre correctement
  218.                 for event in pygame.event.get():
  219.                         if event.type == QUIT:
  220.                                 pygame.quit()
  221.                                
  222.                         elif event.type == KEYDOWN :
  223.                                 if event.key == K_ESCAPE:
  224.                                         continuer_option = 0
  225.                                         continuer_commande = 0
  226.                                         continuer_credit = 0
  227.                                         continuer_parametre = 0
  228.                                         continuer_jeu = 0
  229.                                         continuer_choix_niveau = 0
  230.                                         choix = 0
  231.                                         continuer_ChoixJoueur = 0
  232.                                         continuer_choix_son_jeu = 0
  233.                                         continuer_accueil = 1
  234.                                         continuer_Victoire_Joueur1 = 0
  235.                                         continuer_Victoire_Joueur2 = 0
  236.  
  237.                         ###---Pour gerer le son---###
  238.                                 elif event.key == K_9 and vol == 1 :
  239.                                         pygame.mixer.music.set_volume(0.5) #-Met le volume à 0.5-#
  240.                                         vol = 0.5
  241.                                         print("volume a 0.5 de son max")
  242.                                         barre_son = pygame.image.load(image_barre_son_0_5).convert_alpha()
  243.                                        
  244.                                 elif event.key == K_9 and vol == 0.5 :
  245.                                         pygame.mixer.music.set_volume(0.25) #-Met le volume à 0.25-#
  246.                                         vol= 0.25
  247.                                         print("volume a 0.25 de son max")
  248.                                         barre_son = pygame.image.load(image_barre_son_0_25).convert_alpha()
  249.                                        
  250.                                 elif event.key == K_0 and vol == 0.25 :
  251.                                         pygame.mixer.music.set_volume(0.5) #-Met le volume à 0.5-#
  252.                                         vol = 0.5
  253.                                         print("volume a 0.5 de son max")
  254.                                         barre_son = pygame.image.load(image_barre_son_0_5).convert_alpha()
  255.                                        
  256.                                 elif event.key == K_0 and vol == 0.5 :
  257.                                         pygame.mixer.music.set_volume(1) #-Met le volume à son max-#
  258.                                         vol = 1
  259.                                         print("volume a son max")
  260.                                         barre_son = pygame.image.load(image_barre_son_1).convert_alpha()
  261.  
  262.                         elif event.type == pygame.MOUSEBUTTONUP :
  263.                                 x, y = event.pos
  264.                                 if 190 <= x <= 262 and 439 <= y <= 574 :
  265.                                         pygame.mixer.music.stop()
  266.                                         pygame.mixer.music.load(son_menu)
  267.                                         pygame.mixer.music.play()
  268.                                        
  269.                                 elif 402 <= x <= 485 and 439 <= y <= 574 :
  270.                                         pygame.mixer.music.stop()
  271.                                         pygame.mixer.music.load(son_menu2)
  272.                                         pygame.mixer.music.play()
  273.  
  274.                                 elif 602 <= x <= 673 and 439 <= y <= 574 :
  275.                                         pygame.mixer.music.stop()
  276.                                         pygame.mixer.music.load(son_menu3)
  277.                                         pygame.mixer.music.play()
  278.  
  279.  
  280.                                 elif 188 <= x <= 271 and 92 <= y <= 175 and vol == 1 :
  281.                                         pygame.mixer.music.set_volume(0.5) #-Met le volume à 0.5-#
  282.                                         vol = 0.5
  283.                                         print("volume a 0.5 de son max")
  284.                                         barre_son = pygame.image.load(image_barre_son_0_5).convert_alpha()
  285.  
  286.                                 elif 188 <= x <= 271 and 92 <= y <= 175 and vol == 0.5 :
  287.                                         pygame.mixer.music.set_volume(0.25) #-Met le volume à 0.25-#
  288.                                         vol= 0.25
  289.                                         print("volume a 0.25 de son max")
  290.                                         barre_son = pygame.image.load(image_barre_son_0_25).convert_alpha()
  291.                                        
  292.                                 elif 450 <= x <= 533 and 92 <= y <= 175 and vol == 0.25 :
  293.                                         pygame.mixer.music.set_volume(0.5) #-Met le volume à 0.5-#
  294.                                         vol = 0.5
  295.                                         print("volume a 0.5 de son max")
  296.                                         barre_son = pygame.image.load(image_barre_son_0_5).convert_alpha()
  297.  
  298.                                 elif 450 <= x <= 533 and 92 <= y <= 175 and vol == 0.50 :
  299.                                         pygame.mixer.music.set_volume(1) #-Met le volume à son max-#
  300.                                         vol = 1
  301.                                         print("volume a son max")
  302.                                         barre_son = pygame.image.load(image_barre_son_1).convert_alpha()
  303.                                        
  304.                 pygame.display.flip()
  305.  
  306. ########################################
  307. ##########---Boucle commande---#########
  308. ########################################
  309.                                        
  310.         while continuer_commande:
  311.                 pygame.time.Clock().tick(30)
  312.                 commande = pygame.image.load(image_commande).convert()
  313.                 fenetre.blit(commande, (0,0))
  314.                 pygame.display.flip()
  315.                 for event in pygame.event.get():
  316.                         if event.type == QUIT:
  317.                                 pygame.quit()
  318.                                
  319.                         elif event.type == KEYDOWN:
  320.                                 if event.key == K_ESCAPE:
  321.                                         continuer_credit = 0
  322.                                         continuer_jeu = 0
  323.                                         continuer_choix_niveau = 0
  324.                                         continuer_commande = 0
  325.                                         choix = 0
  326.                                         continuer_ChoixJoueur = 0
  327.                                         continuer_parametre = 0
  328.                                         continuer_accueil = 1
  329.                                         continuer_Victoire_Joueur1 = 0
  330.                                         continuer_Victoire_Joueur2 = 0
  331.                                         continuer_choix_son_jeu = 0
  332.  
  333. ########################################
  334. ##########---Boucle credit---###########
  335. ########################################
  336.  
  337.         while continuer_credit:
  338.                 pass                                    ####################### a faire
  339.  
  340. ########################################
  341. ######---Boucle choix du niveau---######
  342. ########################################
  343.  
  344.         while continuer_choix_niveau:
  345.        
  346.         ###---Limitation de vitesse de la boucle---###
  347.                 pygame.time.Clock().tick(30)
  348.                 choix_niveau = pygame.image.load(image_choix_niveau).convert()
  349.                 fenetre.blit(choix_niveau, (0,0))
  350.                 pygame.display.flip()
  351.                
  352.                 for event in pygame.event.get():
  353.                        
  354.                         if event.type == QUIT:
  355.                                 pygame.quit()
  356.                                
  357.                         elif event.type == KEYDOWN:
  358.                                
  359.                         ##--Retour au premier menu--##
  360.                                 if event.key == K_ESCAPE:
  361.                                         continuer_choix_niveau = 0
  362.                                         choix = 0
  363.                                         continuer_jeu = 0
  364.                                         continuer_Victoire_Joueur1 = 0
  365.                                         continuer_Victoire_Joueur2 = 0
  366.                                         continuer_parametre = 0
  367.                                         continuer_choix_son_jeu = 0
  368.                                         continuer_ChoixJoueur = 0
  369.                                         continuer_accueil = 1
  370.                                        
  371.                         ##--Lancement du niveau 1--##
  372.                                 elif event.key == K_F1:
  373.                                         continuer_choix_niveau = 0
  374.                                         choix = 'n0'
  375.                                        
  376.                                 elif event.key == K_F2:
  377.                                         continuer_choix_niveau = 0
  378.                                         choix = 'n1'
  379.                                        
  380.                                 elif event.key == K_F3:
  381.                                         continuer_choix_niveau = 0
  382.                                         choix = 'n2'
  383.                                        
  384.                                 elif event.key == K_F4:
  385.                                         continuer_choix_niveau = 0
  386.                                         choix = 'n3'                                             #niveau vide
  387.                                         son_jeu.play(-1)
  388.                                        
  389.                                 elif event.key == K_F5:
  390.                                         continuer_choix_niveau = 0
  391.                                         choix = 'n4'
  392.                                        
  393.                                 elif event.key == K_F6:
  394.                                         continuer_choix_niveau = 0
  395.                                         choix = 'n5'
  396.  
  397.                                 elif event.key == K_F7:
  398.                                         continuer_choix_niveau = 0
  399.                                         choix = 'n6'
  400.  
  401.                                 elif event.key == K_F8:
  402.                                         continuer_choix_niveau = 0
  403.                                         choix = 'n7'                                             #niveau labyrinthe
  404.                                         son_jeu.play(-1)
  405.  
  406.                                 elif event.key == K_F9:
  407.                                         continuer_choix_niveau = 0
  408.                                         choix = 'n8'
  409.  
  410.                                 elif event.key == K_F10:
  411.                                         continuer_choix_niveau = 0
  412.                                         choix = 'n9'
  413.  
  414.                                 elif event.key == K_F11:
  415.                                         continuer_choix_niveau = 0
  416.                                         a = 1
  417.                                         i = 1
  418.                                         d = 1
  419.                                         fichier=open('niveau_surprise','w')                      #ouverture ou creation du niveau surprise
  420.                                         fichier.write('mmmmmmmmmmmaaaaaaaammmmmmmmmmm\n')        #la premiere ligne est un mur
  421.                                         while a<29:
  422.                                                 fichier.write('m')                               # on commence le ligne par un mur
  423.                                                 while i<29:                                      #Tant que l'on a pas rempli la ligne
  424.                                                         aleatoire = random.randint(1,50)         #on génère une variable aléatoire entre 1 et 10
  425.                                                         if aleatoire == 4 or aleatoire == 12 or aleatoire == 22 or aleatoire == 34 or aleatoire == 46:                       #si elle vaut 4 on crée un mur dans le niveau
  426.                                                                 fichier.write('m')
  427.                                                         elif aleatoire == 5:                     # si elle vaut cinq et qu'il y a 1 ou 0 drapeau
  428.                                                                 if d <= 15:
  429.                                                                         fichier.write('i')       # on en ajoute 1
  430.                                                                         d+=1
  431.                                                                 elif d >= 15:               # sinon on ne met rien
  432.                                                                         fichier.write('0')
  433.                                                         elif aleatoire != 4 and aleatoire != 5:
  434.                                                                 fichier.write('0')
  435.                                                         i+=1
  436.                                                 fichier.write('m\n')                             # au bout de la ligne on ajoute un mur
  437.                                                 i=1
  438.                                                 a+=1
  439.                                         fichier.write('mmmmmmmmmmmbbbbbbbbmmmmmmmmmmm')          #la derniere ligne est un mur
  440.                                         fichier.close()                                          # fermeture du fichier
  441.                                         choix = 'niveau_surprise'                                #niveau aleatoire
  442.                                 d=1
  443.                                 a=1
  444.                                                                        
  445.                                
  446.         if choix != 0:
  447.         ###---Chargement du fond---###
  448.                 fond = pygame.image.load(image_fond).convert()
  449.  
  450.         ###---Génération d'un niveau à partir d'un fichier---###
  451.                 niveau = Niveau(choix)
  452.                 niveau.generer()
  453.                 niveau.afficher(fenetre)
  454.  
  455.         ###---Création des personnages---###
  456.                 Joueur1 = Perso("images/perso_one_droite.png", "images/perso_one_gauche.png",
  457.                 "images/perso_one_haut.png", "images/perso_one_bas.png", niveau)
  458.                 Joueur2 = Perso("images/perso2_droite.png","images/perso2_gauche.png",
  459.                 "images/perso2_haut.png","images/perso2_bas.png", niveau)
  460.                 Joueur1_drapeau = Perso("images/perso_one_droite_drapeau.png", "images/perso_one_gauche_drapeau.png",
  461.                 "images/perso_one_haut_drapeau.png", "images/perso_one_bas_drapeau.png", niveau)
  462.                 Joueur2_drapeau = Perso("images/perso2_droite_drapeau.png","images/perso2_gauche_drapeau.png",
  463.                 "images/perso2_haut_drapeau.png","images/perso2_bas_drapeau.png", niveau)
  464.  
  465.         ###---Création des IA---###
  466.                 Mouton1 = IA_Passive("images/IA/mouton/mouton_droite.png", "images/IA/mouton/mouton_gauche.png",
  467.                 "images/IA/mouton/mouton_haut.png", "images/IA/mouton/mouton_bas.png", niveau)
  468.  
  469.         ###---Création des projectiles---###
  470.                 p1 = Projectile(image_fleche,image_fleche,image_fleche,image_fleche,niveau, Joueur1)
  471.                 p2 = Projectile(image_fleche,image_fleche,image_fleche,image_fleche,niveau, Joueur2)
  472.  
  473.         ###---Creation de la tourelle---###
  474.                 tourelle = Tour("images/tourelle/tourelle_droite.png","images/tourelle/tourelle_gauche.png",
  475.                 "images/tourelle/tourelle_haut.png","images/tourelle/tourelle_bas.png", niveau)
  476.                 tourelle2 = Tour2("images/tourelle/tourelle_droite.png","images/tourelle/tourelle_gauche.png",
  477.                 "images/tourelle/tourelle_haut.png","images/tourelle/tourelle_bas.png", niveau)
  478.  
  479.         ###---Creation de la grenade---###
  480.                 Grenade_Item_Joueur1 = Grenade(image_grenade, image_grenade, image_grenade, image_grenade, niveau, Joueur1)
  481.  
  482.  
  483. ########################################
  484. ########---Boucle choix perso---########
  485. ########################################
  486.  
  487.         while continuer_ChoixJoueur:
  488.                 ChoixJoueur = pygame.image.load(image_ChoixJoueur).convert()
  489.                 fenetre.blit(ChoixJoueur, (0,0))
  490.                 pygame.display.flip()
  491.                 for event in pygame.event.get():
  492.                         if event.type == pygame.MOUSEBUTTONUP and event.button == 3 :
  493.                                 x, y = event.pos
  494.                         ###---choix du style---###
  495.                                
  496.                                 if 301 >= x >= 102 and 255 >= y >= 99 :
  497.                                         stl = 1
  498.                                         print(stl)
  499.                                        
  500.                                 elif 921 >= x >= 622 and 254 >= y >= 98 :
  501.                                         stl = 2
  502.                                         print(stl)
  503.                                        
  504.                                 elif 561 >= x >= 362 and 253 >= y >= 94 :
  505.                                         stl = 3
  506.                                         print(stl)
  507.                                        
  508.                         ###---passer au jeu---###
  509.                                        
  510.                                 elif 900 >= x >= 706 and 900 >= y >= 789:
  511.                                         continuer_ChoixJoueur = 0
  512.  
  513.                         ###---Style_one---###
  514.                                 elif stl == 1:
  515.                                                
  516.                                         if 608 >= x >= 457 and 499 >= y >= 348:
  517.                                                 Joueur2 = Perso("images/personnages/perso2/style_one/gris/perso2_droite.png","images/personnages/perso2/style_one/gris/perso2_gauche.png",
  518.                                                 "images/personnages/perso2/style_one/gris/perso2_haut.png","images/personnages/perso2/style_one/gris/perso2_bas.png", niveau)
  519.                                                 Joueur2_drapeau = Perso("images/personnages/perso2/style_one/gris/perso2_droite_d.png","images/personnages/perso2/style_one/gris/perso2_gauche_d.png",
  520.                                                 "images/personnages/perso2/style_one/gris/perso2_haut_d.png","images/personnages/perso2/style_one/gris/perso2_bas_d.png", niveau)
  521.  
  522.                                         elif 251 >= x >= 100 and 499 >= y >= 348:
  523.                                                 Joueur2 = Perso("images/personnages/perso2/style_one/marron/perso2_droite.png","images/personnages/perso2/style_one/marron/perso2_gauche.png",
  524.                                                 "images/personnages/perso2/style_one/marron/perso2_haut.png","images/personnages/perso2/style_one/marron/perso2_bas.png", niveau)
  525.                                                 Joueur2_drapeau = Perso("images/personnages/perso2/style_one/marron/perso2_droite_d.png","images/personnages/perso2/style_one/marron/perso2_gauche_d.png",
  526.                                                 "images/personnages/perso2/style_one/marron/perso2_haut_d.png","images/personnages/perso2/style_one/marron/perso2_bas_d.png", niveau)
  527.  
  528.                                         elif 790 >= x >= 639 and 499 >= y >= 348:
  529.                                                 Joueur2 = Perso("images/personnages/perso2/style_one/vert/perso2_droite.png","images/personnages/perso2/style_one/vert/perso2_gauche.png",
  530.                                                 "images/personnages/perso2/style_one/vert/perso2_haut.png","images/personnages/perso2/style_one/vert/perso2_bas.png", niveau)
  531.                                                 Joueur2_drapeau = Perso("images/personnages/perso2/style_one/vert/perso2_droite_d.png","images/personnages/perso2/style_one/vert/perso2_gauche_d.png",
  532.                                                 "images/personnages/perso2/style_one/vert/perso2_haut_d.png","images/personnages/perso2/style_one/vert/perso2_bas_d.png", niveau)
  533.  
  534.                                         elif 431 >= x >= 280 and 499 >= y >= 348:
  535.                                                 Joueur2 = Perso("images/personnages/perso2/style_one/jaune/perso2_droite.png","images/personnages/perso2/style_one/jaune/perso2_gauche.png",
  536.                                                 "images/personnages/perso2/style_one/jaune/perso2_haut.png","images/personnages/perso2/style_one/jaune/perso2_bas.png", niveau)
  537.                                                 Joueur2_drapeau = Perso("images/personnages/perso2/style_one/jaune/perso2_droite_d.png","images/personnages/perso2/style_one/jaune/perso2_gauche_d.png",
  538.                                                 "images/personnages/perso2/style_one/jaune/perso2_haut_d.png","images/personnages/perso2/style_one/jaune/perso2_bas_d.png", niveau)
  539.  
  540.                         ###---Style_2---###
  541.                                 elif stl == 2:
  542.  
  543.                                         if 608 >= x >= 457 and 499 >= y >= 348:
  544.                                                 Joueur2 = Perso("images/personnages/perso2/style_2/gris/perso2_droite.png","images/personnages/perso2/style_2/gris/perso2_gauche.png",
  545.                                                 "images/personnages/perso2/style_2/gris/perso2_haut.png","images/personnages/perso2/style_2/gris/perso2_bas.png", niveau)
  546.                                                 Joueur2_drapeau = Perso("images/personnages/perso2/style_2/gris/perso2_droite_d.png","images/personnages/perso2/style_2/gris/perso2_gauche_d.png",
  547.                                                 "images/personnages/perso2/style_2/gris/perso2_haut_d.png","images/personnages/perso2/style_2/gris/perso2_bas_d.png", niveau)
  548.  
  549.                                         elif 251 >= x >= 100 and 499 >= y >= 348:
  550.                                                 Joueur2 = Perso("images/personnages/perso2/style_2/marron/perso2_droite.png","images/personnages/perso2/style_2/marron/perso2_gauche.png",
  551.                                                 "images/personnages/perso2/style_2/marron/perso2_haut.png","images/personnages/perso2/style_2/marron/perso2_bas.png", niveau)
  552.                                                 Joueur2_drapeau = Perso("images/personnages/perso2/style_2/marron/perso2_droite_d.png","images/personnages/perso2/style_2/marron/perso2_gauche_d.png",
  553.                                                 "images/personnages/perso2/style_2/marron/perso2_haut_d.png","images/personnages/perso2/style_2/marron/perso2_bas_d.png", niveau)
  554.  
  555.                                         elif 790 >= x >= 639 and 499 >= y >= 348:
  556.                                                 Joueur2 = Perso("images/personnages/perso2/style_2/vert/perso2_droite.png","images/personnages/perso2/style_2/vert/perso2_gauche.png",
  557.                                                 "images/personnages/perso2/style_2/vert/perso2_haut.png","images/personnages/perso2/style_2/vert/perso2_bas.png", niveau)
  558.                                                 Joueur2_drapeau = Perso("images/personnages/perso2/style_2/vert/perso2_droite_d.png","images/personnages/perso2/style_2/vert/perso2_gauche_d.png",
  559.                                                 "images/personnages/perso2/style_2/vert/perso2_haut_d.png","images/personnages/perso2/style_2/vert/perso2_bas_d.png", niveau)
  560.  
  561.                                         elif 431 >= x >= 280 and 499 >= y >= 348:
  562.                                                 Joueur2 = Perso("images/personnages/perso2/style_2/jaune/perso2_droite.png","images/personnages/perso2/style_2/jaune/perso2_gauche.png",
  563.                                                 "images/personnages/perso2/style_2/jaune/perso2_haut.png","images/personnages/perso2/style_2/jaune/perso2_bas.png", niveau)
  564.                                                 Joueur2_drapeau = Perso("images/personnages/perso2/style_2/jaune/perso2_droite_d.png","images/personnages/perso2/style_2/jaune/perso2_gauche_d.png",
  565.                                                 "images/personnages/perso2/style_2/jaune/perso2_haut_d.png","images/personnages/perso2/style_2/jaune/perso2_bas_d.png", niveau)                                
  566.  
  567.                         ###---Style_3---###
  568.                                 elif stl == 3:
  569.  
  570.                                         if 608 >= x >= 457 and 499 >= y >= 348:
  571.                                                 Joueur2 = Perso("images/personnages/perso2/style_3/gris/perso2_droite.png","images/personnages/perso2/style_3/gris/perso2_gauche.png",
  572.                                                 "images/personnages/perso2/style_3/gris/perso2_haut.png","images/personnages/perso2/style_3/gris/perso2_bas.png", niveau)
  573.                                                 Joueur2_drapeau = Perso("images/personnages/perso2/style_3/gris/perso2_droite_d.png","images/personnages/perso2/style_3/gris/perso2_gauche_d.png",
  574.                                                 "images/personnages/perso2/style_3/gris/perso2_haut_d.png","images/personnages/perso2/style_3/gris/perso2_bas_d.png", niveau)
  575.  
  576.                                         elif 251 >= x >= 100 and 499 >= y >= 348:
  577.                                                 Joueur2 = Perso("images/personnages/perso2/style_3/marron/perso2_droite.png","images/personnages/perso2/style_3/marron/perso2_gauche.png",
  578.                                                 "images/personnages/perso2/style_3/marron/perso2_haut.png","images/personnages/perso2/style_3/marron/perso2_bas.png", niveau)
  579.                                                 Joueur2_drapeau = Perso("images/personnages/perso2/style_3/marron/perso2_droite_d.png","images/personnages/perso2/style_3/marron/perso2_gauche_d.png",
  580.                                                 "images/personnages/perso2/style_3/marron/perso2_haut_d.png","images/personnages/perso2/style_3/marron/perso2_bas_d.png", niveau)
  581.  
  582.                                         elif 790 >= x >= 639 and 499 >= y >= 348:
  583.                                                 Joueur2 = Perso("images/personnages/perso2/style_3/vert/perso2_droite.png","images/personnages/perso2/style_3/vert/perso2_gauche.png",
  584.                                                 "images/personnages/perso2/style_3/vert/perso2_haut.png","images/personnages/perso2/style_3/vert/perso2_bas.png", niveau)
  585.                                                 Joueur2_drapeau = Perso("images/personnages/perso2/style_3/vert/perso2_droite_d.png","images/personnages/perso2/style_3/vert/perso2_gauche_d.png",
  586.                                                 "images/personnages/perso2/style_3/vert/perso2_haut_d.png","images/personnages/perso2/style_3/vert/perso2_bas_d.png", niveau)
  587.  
  588.                                         elif 431 >= x >= 280 and 499 >= y >= 348:
  589.                                                 Joueur2 = Perso("images/personnages/perso2/style_3/jaune/perso2_droite.png","images/personnages/perso2/style_3/jaune/perso2_gauche.png",
  590.                                                 "images/personnages/perso2/style_3/jaune/perso2_haut.png","images/personnages/perso2/style_3/jaune/perso2_bas.png", niveau)
  591.                                                 Joueur2_drapeau = Perso("images/personnages/perso2/style_3/jaune/perso2_droite_d.png","images/personnages/perso2/style_3/jaune/perso2_gauche_d.png",
  592.                                                 "images/personnages/perso2/style_3/jaune/perso2_haut_d.png","images/personnages/perso2/style_3/jaune/perso2_bas_d.png", niveau)                                
  593.  
  594.                                 elif event.type == KEYDOWN:
  595.                                         if event.key == K_F1:
  596.                                                 perso2= Perso("images/personnages/tank_droite.png","images/personnages/tank_gauche.png","images/personnages/tank_haut.png","images/personnages/tank_bas.png",niveau)
  597.                                                 perso2_drapeau = Perso("images/personnages/tank_droite.png","images/personnages/tank_gauche.png","images/personnages/tank_haut.png","images/personnages/tank_bas.png",niveau)
  598.  
  599.                                         elif event.key == K_F2:
  600.                                                 perso2 = Perso("images/personnages/tnk_droite.png","images/personnages/tnk_gauche.png","images/personnages/tnk_haut.png","images/personnages/tnk_bas.png",niveau)
  601.                                                 perso2_drapeau = Perso("images/personnages/tnk_droite.png","images/personnages/tnk_gauche.png","images/personnages/tnk_haut.png","images/personnages/tnk_bas.png",niveau)
  602.  
  603.  
  604. ########################################
  605. ###---Boucle définition son du jeu---###
  606. ########################################
  607.  
  608.         while continuer_choix_son_jeu:
  609.                 pygame.time.Clock().tick(30)
  610.                 choix_son_jeu = pygame.image.load(image_choix_son_jeu).convert()
  611.                 fenetre.blit(choix_son_jeu, (0,0))
  612.                 pygame.display.flip()
  613.                 for event in pygame.event.get():
  614.                         if event.type == QUIT:
  615.                                 pygame.quit()
  616.  
  617.                         elif event.type == MOUSEBUTTONUP:
  618.                                 x, y = event.pos
  619.  
  620.                                 if 104 <= x <= 216 and 167 <= y <= 403 :
  621.                                         pygame.mixer.music.stop()
  622.                                         pygame.mixer.music.load(son_jeu)
  623.                                         pygame.mixer.music.play()
  624.                                        
  625.                                 elif 394 <= x <= 508 and 167 <= y <= 393 :
  626.                                         pygame.mixer.music.stop()
  627.                                         pygame.mixer.music.load(son_jeu2)
  628.                                         pygame.mixer.music.play()
  629.  
  630.                                 elif 674 <= x <= 789 and 168 <= y <= 396 :
  631.                                         pygame.mixer.music.stop()
  632.                                         pygame.mixer.music.load(son_jeu3)
  633.                                         pygame.mixer.music.play()
  634.                                        
  635.                                 elif 700 <= x <= 900 and 780 <= y <= 900 :
  636.                                         continuer_choix_son_jeu = 0
  637.                                         c = time.time()
  638.                                
  639.  
  640. ########################################
  641. ##########---Boucle du jeu---###########
  642. ########################################
  643.                                
  644.         while continuer_jeu:
  645.        
  646.         ###---Limitation de vitesse de la boucle---###
  647.                 pygame.time.Clock().tick(30)
  648.                
  649.                 for event in pygame.event.get():
  650.                        
  651.                         if event.type == QUIT:
  652.                                 pygame.quit()
  653.                                
  654.                         elif event.type == KEYDOWN:
  655.                                
  656.                                 if event.key == K_ESCAPE:
  657.                                         continuer_jeu = 0
  658.                                         continuer_Victoire_Joueur1 = 0
  659.                                         continuer_Victoire_Joueur2 = 0
  660.  
  661.  
  662.                 ###---Touche de Mouvement Joueur1---###
  663.                                 elif event.key == K_d:
  664.                                         Grenade_Item_Joueur1.deplacer('droite')
  665.                                 ##--Collision Drapeau / person_one--##
  666.                                         if niveau.structure[Joueur1.case_y][Joueur1.case_x+1] == 'i':
  667.                                                 niveau.structure[Joueur1.case_y][Joueur1.case_x+1]='0'
  668.                                                 DEM_Joueur1 += 1
  669.                                                 Joueur1.d1 = 0
  670.                                 ##--Déplacement Joueur1--##
  671.                                         Joueur1.deplacer('droite')
  672.                                         direction='droite'
  673.                                        
  674.                                 elif event.key == K_a:
  675.                                         Grenade_Item_Joueur1.deplacer('gauche')
  676.                                         if niveau.structure[Joueur1.case_y][Joueur1.case_x-1] == 'i':
  677.                                                 niveau.structure[Joueur1.case_y][Joueur1.case_x-1]='0'
  678.                                                 DEM_Joueur1 += 1
  679.                                                 Joueur1.d1 = 0
  680.                                         Joueur1.deplacer('gauche')
  681.                                         direction='gauche'
  682.                                        
  683.                                 elif event.key == K_w:
  684.                                         Grenade_Item_Joueur1.deplacer('haut')
  685.                                         if niveau.structure[Joueur1.case_y-1][Joueur1.case_x] == 'i':
  686.                                                 niveau.structure[Joueur1.case_y-1][Joueur1.case_x]='0'
  687.                                                 DEM_Joueur1 += 1
  688.                                                 Joueur1.d1 = 0
  689.                                         Joueur1.deplacer('haut')
  690.                                         direction='haut'
  691.                                        
  692.                                 elif event.key == K_s:
  693.                                         Grenade_Item_Joueur1.deplacer('bas')
  694.                                         if niveau.structure[Joueur1.case_y+1][Joueur1.case_x] == 'i':
  695.                                                 niveau.structure[Joueur1.case_y+1][Joueur1.case_x]='0'
  696.                                                 DEM_Joueur1 += 1
  697.                                                 Joueur1.d1 = 0
  698.                                         Joueur1.deplacer('bas')
  699.                                         direction='bas'
  700.  
  701.                         ##--Tir du Joueur1--##
  702.                                 elif event.key == K_SPACE:
  703.                                         i=0
  704.                                         if Munition_Joueur1 > 0:
  705.                                                 son_tir.play()
  706.                                                 Munition_Joueur1 -= 1
  707.                                                 TirJoueur1(Joueur1, Joueur2, niveau, direction, i)
  708.                                                                        
  709.                         ##--Rechargement Joueur1--##
  710.                                 elif event.key == K_r and niveau.structure[Joueur1.case_y][Joueur1.case_x] == 'c'  and Munition_Joueur1 < 24 and TempsActuel > recharge_tireJoueur1:
  711.                                         recharge_tireJoueur1 = TempsActuel + 3
  712.                                         print ("tps actuel =", round(TempsActuel),"seconde")
  713.                                         print ("recharge tire à = ", round(recharge_tireJoueur1),"seconde")
  714.                                         Munition_Joueur1 += 8
  715.                                         if Munition_Joueur1 >24:  #-Limitation a 24 munition-#
  716.                                                 Munition_Joueur1 = 24
  717.                                                
  718.                 ###---Touche de Mouvement Joueur2---###
  719.                                 elif event.key == K_RIGHT:
  720.                                         if niveau.structure[Joueur2.case_y][Joueur2.case_x+1] == 'i':
  721.                                                 niveau.structure[Joueur2.case_y][Joueur2.case_x+1]='0'
  722.                                                 DEM_Joueur2 += 1
  723.                                                 Joueur2.d1 = 0
  724.                                         Joueur2.deplacer('droite')
  725.                                         direction = 'droite'
  726.                                        
  727.                                 elif event.key == K_LEFT:
  728.                                         if niveau.structure[Joueur2.case_y][Joueur2.case_x-1] == 'i':
  729.                                                 niveau.structure[Joueur2.case_y][Joueur2.case_x-1]='0'
  730.                                                 DEM_Joueur2 += 1
  731.                                                 Joueur2.d1 = 0
  732.                                         Joueur2.deplacer('gauche')
  733.                                         direction = 'gauche'
  734.                                        
  735.                                 elif event.key == K_UP:
  736.                                         if niveau.structure[Joueur2.case_y-1][Joueur2.case_x] == 'i':
  737.                                                 niveau.structure[Joueur2.case_y-1][Joueur2.case_x]='0'
  738.                                                 DEM_Joueur2 += 1
  739.                                                 Joueur2.d1 = 0
  740.                                         Joueur2.deplacer('haut')
  741.                                         direction = 'haut'
  742.                                        
  743.                                 elif event.key == K_DOWN:
  744.                                         if niveau.structure[Joueur2.case_y+1][Joueur2.case_x] == 'i':
  745.                                                 niveau.structure[Joueur2.case_y+1][Joueur2.case_x]='0'
  746.                                                 DEM_Joueur2 += 1
  747.                                                 Joueur2.d1 = 0
  748.                                         Joueur2.deplacer('bas')
  749.                                         direction = 'bas'
  750.  
  751.                         ##--Tir du Joueur2--##
  752.                                 elif event.key == K_KP0:
  753.                                         i=0
  754.                                         if Munition_Joueur2 > 0:
  755.                                                 son_tir.play()
  756.                                                 Munition_Joueur2 -= 1
  757.                                                 TirJoueur2(Joueur1, Joueur2, niveau, direction, i)
  758.                                                 print(r1)
  759.  
  760.                         ##--rechargement du Joueur2--##                    
  761.                                 elif event.key == K_KP3 and niveau.structure[Joueur2.case_y][Joueur2.case_x] == 'c'  and Munition_Joueur2 < 24 and TempsActuel > recharge_tireJoueur2:
  762.                                         recharge_tireJoueur2 = TempsActuel + 3
  763.                                         print ("tps actuel =", round(TempsActuel),"seconde")
  764.                                         print ("recharge tire à = ", round(recharge_tireJoueur2),"seconde")
  765.                                         Munition_Joueur2 += 8
  766.                                         if Munition_Joueur2 >24:  #-Limitation a 24 munition-#
  767.                                                 Munition_Joueur2 = 24
  768.  
  769.                         ###---Lancement de Grenade Joueur1---###
  770.                                 elif event.key == K_g:
  771.                                         if len (GRENADEJoueur1) < 1:
  772.                                                 Grenade_Item_Joueur1.placer(niveau, Joueur1, direction, pdb)
  773.                                                 print(GRENADEJoueur1)
  774.                                                 print(EXPLOJoueur1)
  775.                                                 Temps_Explo_Grenade = TempsActuel + 3
  776.                                                 if direction == 'droite' :
  777.                                                         GRENADEJoueur1.append((Grenade_Item_Joueur1.case_x+pdb, Grenade_Item_Joueur1.case_y ))
  778.                                                         EXPLOJoueur1.append((Grenade_Item_Joueur1.case_x+pdb, Grenade_Item_Joueur1.case_y ))
  779.  
  780.                                                 elif direction == 'gauche' :
  781.                                                         GRENADEJoueur1.append((Grenade_Item_Joueur1.case_x-pdb, Grenade_Item_Joueur1.case_y ))
  782.                                                         EXPLOJoueur1.append((Grenade_Item_Joueur1.case_x+pdb, Grenade_Item_Joueur1.case_y ))
  783.  
  784.                                                 elif direction == 'bas' :
  785.                                                         GRENADEJoueur1.append((Grenade_Item_Joueur1.case_x, Grenade_Item_Joueur1.case_y+pdb ))
  786.                                                         EXPLOJoueur1.append((Grenade_Item_Joueur1.case_x+pdb, Grenade_Item_Joueur1.case_y ))
  787.  
  788.                                                 elif direction == 'haut' :
  789.                                                         GRENADEJoueur1.append((Grenade_Item_Joueur1.case_x, Grenade_Item_Joueur1.case_y-pdb ))
  790.                                                         EXPLOJoueur1.append((Grenade_Item_Joueur1.case_x+pdb, Grenade_Item_Joueur1.case_y ))
  791.  
  792.  
  793.                                 elif event.key == K_o :
  794.                                     reaparition(Joueur1)
  795.                                     direction='droite'
  796.  
  797.                 if len(GRENADEJoueur1)!=0:
  798.                         if TempsActuel >= Temps_Explo_Grenade : #Fait exploser la bombe au bout de 3 sec
  799.                                 Grenade_Item_Joueur1.exploser(GRENADEJoueur1[0])
  800.                                 GRENADEJoueur1 = GRENADEJoueur1[1:]
  801.                                 Temps_Sup_Explo = TempsActuel + 3
  802.                                 #son_explosion.play()
  803.                 elif len(EXPLOJoueur1) !=0:
  804.                         if TempsActuel >= Temps_Sup_Explo : #Fait exploser la bombe au bout de 3 sec
  805.                                 Grenade_Item_Joueur1.supprimer(EXPLOJoueur1[0])
  806.                                 EXPLOJoueur1=EXPLOJoueur1[1:]
  807.                                                                
  808. ##                                elif len(BOMBES2)!=0:
  809. ##                                        if time.clock()-BOMBES2[0][2] > 3:
  810. ##                                                b2.exploser2(BOMBES2[0])
  811. ##                                                BOMBES2=BOMBES2[1:]
  812. ##                                                son_explosion.play()
  813. ##                                elif len(EXPLO2) !=0:
  814. ##                                        if time.clock()-EXPLO2[0][2] > 4:
  815. ##                                                b2.effacer2(EXPLO2[0])
  816. ##                                                EXPLO2=EXPLO2[1:]
  817.  
  818. ##                elif r1 == 1:
  819. ##                        if Score_Joueur1 >=2 :
  820. ##                                Score_Joueur1 = Score_Joueur1 //2
  821. ##                                drapeau_spawn = Score_Joueur1 //2                # à refaire
  822. ##
  823. ##                        elif drapeau_spawn !=0 :
  824. ##                                drapeau_spawn -=1
  825. ##                                drapeau_spawn_list += [1]
  826. ##                                print(drapeau_spawn_list)
  827.  
  828.                 elif niveau.structure[Joueur1.case_y][Joueur1.case_x] == 'e':
  829.                         reaparition(Joueur1)
  830.  
  831.                 elif niveau.structure[Joueur2.case_y][Joueur2.case_x] == 'e':
  832.                         reaparition(Joueur2)
  833.  
  834.         ###---Affichages aux nouvelles positions---###
  835.                 fenetre.blit(fond, (0,0))
  836.                 niveau.afficher(fenetre)
  837.                 fenetre.blit(Joueur1.direction, (Joueur1.x, Joueur1.y))
  838.                 fenetre.blit(Joueur2.direction, (Joueur2.x, Joueur2.y))
  839.                
  840.                 #-IA Passive-#
  841.                 Mouton1.deplacer("Partout")
  842.                 bele(son_mouton)
  843.                 fenetre.blit(Mouton1.direction, (Mouton1.x, Mouton1.y))
  844.                
  845.                 #-Tourelle-#
  846.                 tourelle.tourne()
  847.                 fenetre.blit(tourelle.direction, (tourelle.x, tourelle.y))
  848.                 tourelle2.tourne()
  849.                 fenetre.blit(tourelle2.direction, (tourelle2.x, tourelle2.y))
  850.  
  851.                 smallfont = pygame.font.SysFont("comicsansms", 25)
  852.                
  853.         ###---Score_Joueur1---###
  854.                 HUD = pygame.image.load(image_HUD).convert()
  855.                 fenetre.blit(HUD, (0,731))
  856.                
  857.                 score_affJoueur1=smallfont.render(str(Score_Joueur1), True, (0,0,0))
  858.                 fenetre.blit(score_affJoueur1, (25,815))
  859.                
  860.                 score_affDEM_Joueur1=smallfont.render(str(DEM_Joueur1), True, (0,0,0))
  861.                 fenetre.blit(score_affDEM_Joueur1, (75,768))
  862.  
  863.                 Munition_Joueur1_aff = smallfont.render(str(Munition_Joueur1), True, (BLACK))
  864.                 fenetre.blit(Munition_Joueur1_aff, (130,815))
  865.                
  866.         ###---Score_Joueur2---###
  867.                 HUD = pygame.image.load(image_HUD).convert()
  868.                 fenetre.blit(HUD, (731,731))
  869.                
  870.                 score_affJoueur2=smallfont.render(str(Score_Joueur2), True, (0,0,0))
  871.                 fenetre.blit(score_affJoueur2, (755,815))
  872.                
  873.                 score_affDEM_Joueur2=smallfont.render(str(DEM_Joueur2), True, (0,0,0))
  874.                 fenetre.blit(score_affDEM_Joueur2, (805,768))
  875.  
  876.                 Munition_Joueur2_aff = smallfont.render(str(Munition_Joueur2), True, (BLACK))
  877.                 fenetre.blit(Munition_Joueur2_aff, (860,815))
  878.  
  879.         ###---Chronometre---###
  880.                 Tpsi = time.time()
  881.                 TempsActuel = Tpsi-c
  882.                 Chronotxt = smallfont.render(str(round(TempsActuel)), True, (0,0,0))
  883.                 fenetre.blit(Chronotxt, (805,858))
  884.                 fenetre.blit(Chronotxt, (75,858))
  885.                
  886.                 if Joueur1.d1 == 0:
  887.                         Joueur1 = Joueur1_drapeau
  888.                 if Joueur2.d1 == 0:
  889.                         Joueur2 = Joueur2_drapeau
  890.                        
  891.                 if p1.u !=0 or p1.v !=0 :
  892.                         fenetre.blit(p1.direction,(p1.u, p1.v))
  893.  
  894.                 if p2.u !=0 or p2.v !=0 :
  895.                         fenetre.blit(Joueur2.direction,(Joueur2.u, Joueur2.v))
  896.  
  897.                 drapeau_aleat(TempsActuel, Temps_Spawn_Drapeau, niveau)
  898.                
  899.                 pygame.display.flip()
  900.                
  901.         ###---Collision Joueur / base ###
  902.                 if niveau.structure[Joueur1.case_y][Joueur1.case_x] == 'a' and Joueur1 == Joueur1_drapeau:
  903.                         Score_Joueur1 += DEM_Joueur1
  904.                         DEM_Joueur1 = 0
  905.                        
  906.                 if niveau.structure[Joueur2.case_y][Joueur2.case_x] == 'b' and Joueur2 == Joueur2_drapeau:
  907.                         Score_Joueur2 += DEM_Joueur2
  908.                         DEM_Joueur2 = 0
  909.  
  910.         ###---collision joueur/ base ennemie---###
  911.                 if niveau.structure[Joueur1.case_y][Joueur1.case_x] == 'b' and Joueur1 == Joueur1_drapeau and Score_Joueur2 >=1:
  912.                         if TempsActuel > Joueur1_Vole_DP :
  913.                                 Joueur1_Vole_DP = TempsActuel + 3
  914.                                 DEM_Joueur1 += 1
  915.                                 Score_Joueur2 -= 1
  916.  
  917.                 if niveau.structure[Joueur2.case_y][Joueur2.case_x] == 'a' and Joueur2 == Joueur2_drapeau and Score_Joueur1 >=1:
  918.                         if TempsActuel > Joueur2_Vole_DP :
  919.                                 Joueur2_Vole_DP = TempsActuel + 3
  920.                                 DEM_Joueur2 += 1
  921.                                 Score_Joueur1 -= 1
  922.                                
  923.         ###---Si joueur arrive au nombre de drapeau définit---###
  924.                 if Score_Joueur1 >= DPG:
  925.                         continuer_Victoire_Joueur2 = 0
  926.                         continuer_jeu = 0
  927.                        
  928.                 if Score_Joueur2 >= DPG:
  929.                         continuer_Victoire_Joueur1 = 0
  930.                         continuer_jeu = 0
  931.  
  932.                 if round(TempsActuel) >= tpsf :
  933.                         print('fin')
  934.                         if Score_Joueur1 >= Score_Joueur2 :
  935.                                 continuer_jeu = 0
  936.                                 continuer_Victoire_Joueur2 = 0
  937.                                 print('Joueur1')
  938.                         if Score_Joueur1 <= Score_Joueur2 :
  939.                                 continuer_jeu = 0
  940.                                 continuer_Victoire_Joueur1 = 0
  941.                                 print('Joueur2')
  942.                         if Score_Joueur1 == Score_Joueur2 :
  943.                                 continuer_jeu = 0
  944.                                 continuer_Victoire_Joueur1 = 0
  945.                                 continuer_Victoire_Joueur2 = 0
  946.                                 print ('rien')
  947.  
  948. ########################################
  949. #####---Boucle de victoire Joueur1---######
  950. ########################################
  951.                
  952.         while continuer_Victoire_Joueur1:
  953.                 pygame.time.Clock().tick(30)
  954.                 continuer_Victoire_Joueur1 = pygame.image.load(image_VictoireJoueur1)
  955.                 fenetre.blit(continuer_Victoire_Joueur1, (0,0))
  956.                 pygame.display.flip()
  957.                 for event in pygame.event.get():
  958.                         if event.type == QUIT or event.type == KEYDOWN and event.key == K_ESCAPE:
  959.                                 pygame.quit()
  960.                                        
  961.                         elif event.type == KEYDOWN:
  962.                                 if event.key == K_SPACE:
  963.                                         continuer_Victoire_Joueur1 = 0
  964.                                         continuer_Victoire_Joueur2 = 0
  965.  
  966. ########################################
  967. ######---Boucle de victoire Joueur2---#######
  968. ########################################
  969.                                        
  970.         while continuer_Victoire_Joueur2:
  971.                 pygame.time.Clock().tick(30)
  972.                 continuer_Victoire_Joueur2 = pygame.image.load(image_VictoireJoueur2)
  973.                 fenetre.blit(continuer_Victoire_Joueur2, (0,0))
  974.                 pygame.display.flip()
  975.                 for event in pygame.event.get():
  976.                         if event.type == QUIT or event.type == KEYDOWN and event.key == K_ESCAPE:
  977.                                 pygame.quit()
  978.                                        
  979.                         elif event.type == KEYDOWN:
  980.                                 if event.key == K_SPACE:
  981.                                         continuer_Victoire_Joueur1 = 0
  982.                                         continuer_Victoire_Joueur2 = 0
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement