Partage
  • Partager sur Facebook
  • Partager sur Twitter

Programme Python

    16 mai 2018 à 21:52:44

    Bonsoir,

    Donc je vous explique mon problème..  Donc j'ai une fenetre, qui constitue le menu principale de mon projet ( jeu du labyrinthe ).. Et j'aimerais que quand on clique sur JOUER, ça m'envoie sur le programme du labyrinthe ( code du labyrinthe, le jeu )...

    Je ne sais pas comment faire avec les boucles etc... Je vous envoie mon programme du menu principale 

    import pygame
    from constante import *
    from pygame.locals import *
    
    '''blue = (147,97,86)
    white = (255,255,255)'''
    
    pygame.init() #INITIALISATION DE LA BIBLIO PYGAME
    
    WIDHT = 800 #DIMENSION DES FENETRES
    HEIGHT= 500
    pygame.mixer.music.load("maze.wav")
    pygame.mixer.music.play()
    pygame.mixer.music.queue("maze.wav")
    
    
    
    screen = pygame.display.set_mode((WIDHT,HEIGHT)) #PARAMETRE DE LA FENETRE
    pygame.display.set_caption(titre_fenetre) # TITRE DE LA FENETRE
    icone = pygame.image.load(image_icone) #icone
    pygame.display.set_icon(icone)
    
    titre = pygame.image.load("labyt6.png").convert_alpha() #TITRE DU JEU
    screen.blit(titre,(200,0))
    
    #BOUCLE PRINCIPALE
    continuer = 1
    while continuer:
    	#Chargement et affichage de l'écran d'accueil
    	accueil= pygame.image.load("laby.jpg").convert() #BACKGROUND
    	fenetre.blit(accueil, (0,0))
    
    
    
    #Chargement et collage des boutons
    Bouton_1 = pygame.image.load("bouton1.png").convert_alpha()
    screen.blit(Bouton_1,(0,230))
    commande = pygame.image.load("commande.png")
    screen.blit(commande,(0,300))
    credit = pygame.image.load("credit.png")
    screen.blit(credit,(0,350))
    
    
    pygame.display.flip()
    
    
    
    def principale():
        x = 150
        y = 200
    
    fin = False #BOUCLE POUR FERMER LA FENETRE
    
    while not fin :
        for event in pygame.event.get():
            if event.type == pygame.QUIT:
                fin = True
            if event.type == MOUSEBUTTONDOWN and event.button==1 and event.pos[0]<233 and event.pos[1]>233 and event.pos[1]<273:
                print("jouer")
    
    
    
    principale()
    
    
    pygame.quit()
    quit()
    

    PROGRAMME DU LABYRINTHE :

    import random
    from random import*
    
    def labyrinthe(l=30,h=10):
        visite=[[0]*l+[1] for i in range(h)]+[[1]*(l+1)]
        vertical=[["|   "]*l+['|'] for i in range(h)]+[[]]
        horizontal=[["+---"]*l+['+'] for i in range(h+1)]
    
        def chemins(x,y):
            
            visite[y][x]=1
            d=[(x-1,y),(x,y+1),(x+1,y),(x,y-1)]
            shuffle(d)
            for (xx,yy) in d:
                if visite[yy][xx]:continue
                if xx==x:horizontal[max(y,yy)][x]="+   "
                if yy==y:vertical[y][max(x,xx)]="    "
                chemins(xx,yy)
    
        chemins(randrange(l),randrange(h))
        for(a,b) in zip(horizontal,vertical):
            print(''.join(a+['\n']+b))
    
    labyrinthe()
    

    Merci, j'aimerais terminer pour vendredi!

    • Partager sur Facebook
    • Partager sur Twitter
      18 mai 2018 à 11:32:55

      import monfichier
      
      monfichier.labyrithe()
      Permet d'appeler le code de ton autre fichier dans ton programme principal
      • Partager sur Facebook
      • Partager sur Twitter
      OpenClassrooms retire tellement d'aiguilles de nos pieds qu'on pourrait ne plus trouver le foin de notre botte :)
        21 mai 2018 à 21:05:58

        Ah je vois!! Je vais essayer avec ça !
        • Partager sur Facebook
        • Partager sur Twitter
          22 mai 2018 à 1:11:24

          Tu importe deux fois le module random dans le deuxième bout de code.
          • Partager sur Facebook
          • Partager sur Twitter

          Blond, bouclé, toujours le sourire aux lèvres...

            22 mai 2018 à 23:31:05

            Je fais le meme type de peogramme et je bug aussi..

            -
            Edité par KaiOrog 22 mai 2018 à 23:31:46

            • Partager sur Facebook
            • Partager sur Twitter
              22 mai 2018 à 23:33:01

              Après plusieurs essais, je n’y arrives toujours pas.. Je dois terminer ça pour dans 4j, aidez moi îil vous plais..
              • Partager sur Facebook
              • Partager sur Twitter

              Programme Python

              × Après avoir cliqué sur "Répondre" vous serez invité à vous connecter pour que votre message soit publié.
              × Attention, ce sujet est très ancien. Le déterrer n'est pas forcément approprié. Nous te conseillons de créer un nouveau sujet pour poser ta question.
              • Editeur
              • Markdown