def finPartie(run,parametres,joueur1,joueur2,collision,sperdant): # Obtention du joueur gagnant, fin du jeu et affichage du gagnant finPartie=mParametre.getFinJeu(parametres) if len(mJoueur.getSnake(joueur1))==finPartie: print(mJoueur.getNom(joueur1),"gagne") run=False pygame.time.delay(2000) if len(mJoueur.getSnake(joueur2))==finPartie: print(mJoueur.getNom(joueur2),"gagne") run=False pygame.time.delay(2000) if collision==True and sperdant=="snake1": print(mJoueur.getNom(joueur2),"gagne") run=False pygame.time.delay(2000) if collision==True and sperdant=="snake2": print(mJoueur.getNom(joueur1),"gagne") run=False pygame.time.delay(2000) return run
def bonbon(xb,yb,x,y,snake,joueur,lcarte,hcarte,carte,numJ,depSnake): if x==xb and y==yb: mSnake.appSnake(snake) mGraphique.playSound() # Joue la musique quand on est sur le bonbon mJoueur.setSnakeJ(joueur,snake) xb = random.randint(1,lcarte-1) # position au hasard de x yb = random.randint(1,hcarte-1)# position au hasard de y getEtatCase(carte,xb,yb) print('score de ', mJoueur.getNom(joueur), ' : ', len(snake))#affiche le score while carte[xb][yb] !=1: # Verification que l'on est sur la carte xb = random.randint(1,lcarte-1) yb = random.randint(1,hcarte-1) bonbon = setCaseC(carte,xb,yb,"bonbon") return snake,joueur,xb,yb