IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

Python Discussion :

mon programme ne fonctionne pas


Sujet :

Python

Vue hybride

Message précédent Message précédent   Message suivant Message suivant
  1. #1
    Membre averti
    Inscrit en
    Février 2010
    Messages
    16
    Détails du profil
    Informations forums :
    Inscription : Février 2010
    Messages : 16
    Par défaut mon programme ne fonctionne pas
    bonjour,

    j'ai fait le programme suivant, normalement on devrait voir deux cubes tourner, puis lorsqu'on clique avec la souris, les cubes doivent être remplacés par des dés.
    Mais lorsque je lance le programme, il n'y a pas de message d'erreur mais ça ne fonctionne pas, et je ne comprend pas pourquoi.

    au lieu d'écrire un message d'erreur ça écrit juste : <function lancedes at 0x03BEC9B0>

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    93
    94
    95
    96
    97
    98
    99
    100
    101
    102
    103
    104
    105
    106
    107
    108
    109
    110
    111
    112
    113
    114
    115
    116
    117
    118
    119
    120
    121
    122
    123
    124
    125
    126
    127
    128
    129
    130
    import pygame,math,time
    import numpy as np
    import random
     
     
     
    RED=(255,0,0)
    GREEN=(0,255,0)
    BLUE=(0,0,255)
    BLACK=(0,0,0)
    GRAY=(128,128,128)
    WHITE=(255,255,255)
    YELLOW=(0,255,255)
     
    pygame.init()
     
    fond=pygame.image.load("fond.jpg")
     
    de11=pygame.image.load("des11.jpg")
    de12=pygame.image.load("des12.jpg")
    de13=pygame.image.load("des13.jpg")
    de14=pygame.image.load("des14.jpg")
    de15=pygame.image.load("des15.jpg")
    de16=pygame.image.load("des16.jpg")
     
     
    sizeim=fond.get_size()
    size=(sizeim[0],sizeim[1])
    screen = pygame.display.set_mode(size)
     
    def drawFace(screen,face,color=(0,0,255),echelle=200,centre=(512,400)):
        npoints=face.shape[0]
        for i in range(0,npoints-1):
            pygame.draw.aaline(screen, color, \
                  (centre[0]+echelle*face[i,0]/face[i,2], centre[1]-echelle*face[i,1]/face[i,2]), \
                  (centre[0]+echelle*face[i+1,0]/face[i+1,2], centre[1]-echelle*face[i+1,1]/face[i+1,2]))
        pygame.draw.aaline(screen, color, \
              (centre[0]+echelle*face[npoints-1,0]/face[npoints-1,2], centre[1]-echelle*face[npoints-1,1]/face[npoints-1,2]), \
              (centre[0]+echelle*face[0,0]/face[0,2], centre[1]-echelle*face[0,1]/face[0,2]))
     
     
     
    def cube(L):
        faceA=np.matrix([[float(L)/2,-float(L)/2,float(L)/2],[float(L)/2,float(L)/2,float(L)/2],[float(L)/2,float(L)/2,-float(L)/2],[float(L)/2,-float(L)/2,-float(L)/2]])
        faceB=np.matrix([[float(L)/2,float(L)/2,float(L)/2],[-float(L)/2,float(L)/2,float(L)/2],[-float(L)/2,float(L)/2,-float(L)/2],[float(L)/2,float(L)/2,-float(L)/2]])
        faceC=np.matrix([[float(L)/2,-float(L)/2,float(L)/2],[float(L)/2,float(L)/2,float(L)/2],[-float(L)/2,float(L)/2,float(L)/2],[-float(L)/2,-float(L)/2,float(L)/2]])
        faceD=(-1)*faceA
        faceE=(-1)*faceB
        faceF=(-1)*faceC
        return [faceA, faceB, faceC, faceD, faceE, faceF]
     
    def translation(face, dx, dy,dz):
        X=np.matrix([[dx,0,0],[dx,0,0],[dx,0,0],[dx,0,0]])
        Y=np.matrix([[0,dy,0],[0,dy,0],[0,dy,0],[0,dy,0]])
        Z=np.matrix([[0,0,dz],[0,0,dz],[0,0,dz],[0,0,dz]])
        T=X+Y+Z
        return face+T
     
    def rotationz(point,a):
        M=[[math.cos(a),math.sin(a),0],[-math.sin(a),math.cos(a),0],[0,0,1]]
        R=(point)*M
        return R
     
    def rotationx(point,a):
        M=[[1,0,0],[0,math.cos(a),math.sin(a)],[0,-math.sin(a),math.cos(a)]]
        R=(point)*M
        return R
     
    def rotationy(point,a):
        M=[[math.cos(a),0,math.sin(a)],[0,1,0],[-math.sin(a),0,math.cos(a)]]
        R=(point)*M
        return R
     
    def rotationface(face,a):
        for k in range(0,4) :
            face[k]=rotation(face[k],a)
        return [face[0],face[1],face[2],face[3]]
     
     
    def lancedes():
        running=1
        a=1
        b=0
        c=0
        while running:
            if a>0 :
                event = pygame.event.poll()
                if event.type == pygame.QUIT:
                    running = 0
                    screen.fill((0, 0, 0))
                t=time.time()
                screen.blit(fond,(0,0))
                drawFace(screen,translation(rotationx(rotationy(rotationz(cube(2)[0],5*t),5*t),0),18,25,20),BLACK)
                drawFace(screen,translation(rotationx(rotationy(rotationz(cube(2)[1],5*t),5*t),0),18,25,20),BLACK)
                drawFace(screen,translation(rotationx(rotationy(rotationz(cube(2)[2],5*t),5*t),0),18,25,20),BLACK)
                drawFace(screen,translation(rotationx(rotationy(rotationz(cube(2)[3],5*t),5*t),0),18,25,20),BLACK)
                drawFace(screen,translation(rotationx(rotationy(rotationz(cube(2)[4],5*t),5*t),0),18,25,20),BLACK)
                drawFace(screen,translation(rotationx(rotationy(rotationz(cube(2)[5],5*t),5*t),0),18,25,20),BLACK)
     
                drawFace(screen,translation(rotationx(rotationy(rotationz(cube(2)[0],5*t),5*t),0),25,25,20),BLACK)
                drawFace(screen,translation(rotationx(rotationy(rotationz(cube(2)[1],5*t),5*t),0),25,25,20),BLACK)
                drawFace(screen,translation(rotationx(rotationy(rotationz(cube(2)[2],5*t),5*t),0),25,25,20),BLACK)
                drawFace(screen,translation(rotationx(rotationy(rotationz(cube(2)[3],5*t),5*t),0),25,25,20),BLACK)
                drawFace(screen,translation(rotationx(rotationy(rotationz(cube(2)[4],5*t),5*t),0),25,25,20),BLACK)
                drawFace(screen,translation(rotationx(rotationy(rotationz(cube(2)[5],5*t),5*t),0),25,25,20),BLACK)
                for event in pygame.event.get():
                    if event.type == pygame.MOUSEBUTTONUP :
                        a=0
                    else : pass
            else :
                b=random.randint(1,6)
                c=random.randint(1,6)
                if 0<b<2 : screen.blit(de11,(650,120))
                if 1<b<3 : screen.blit(de12,(650,120))
                if 2<b<4 : screen.blit(de13,(650,120))
                if 3<b<5 : screen.blit(de14,(650,120))
                if 4<b<6 : screen.blit(de15,(650,120))
                if 5<b : screen.blit(de16,(650,120))
                if 0<c<2 : screen.blit(de11,(730,120))
                if 1<c<3 : screen.blit(de12,(730,120))
                if 2<c<4 : screen.blit(de13,(730,120))
                if 3<c<5 : screen.blit(de14,(730,120))
                if 4<c<6 : screen.blit(de15,(730,120))
                if 5<c : screen.blit(de16,(730,120))
                running=0
     
                pygame.display.flip ()
     
     
    print lancedes
    J'espère que vous pourrez m'aider

  2. #2
    Expert confirmé

    Homme Profil pro
    Inscrit en
    Octobre 2008
    Messages
    4 307
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : Belgique

    Informations forums :
    Inscription : Octobre 2008
    Messages : 4 307
    Par défaut
    Il n'y a pas de raison que tu reçoives un message d'erreur, il n'y en a pas.

    Ton script se termine par print lancerdes, donc python fait ce que tu lui demande, il printe la valeur de lancerdes.

    Il ne me semble pas y avoir de ligne qui lance ton code, c'est tout.

    vincent

  3. #3
    Membre émérite
    Homme Profil pro
    Inscrit en
    Décembre 2007
    Messages
    758
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 46
    Localisation : France

    Informations professionnelles :
    Secteur : Aéronautique - Marine - Espace - Armement

    Informations forums :
    Inscription : Décembre 2007
    Messages : 758
    Par défaut
    Citation Envoyé par VinsS Voir le message
    Ton script se termine par print lancerdes, donc python fait ce que tu lui demande, il printe la valeur de lancerdes
    bonjour,

    le problème est là, tu voulais peut être faire un:

    qui fait que la fonction lancerdes s'exécute, sinon, tu lui demandes juste ce qu'est lancerdes.

Discussions similaires

  1. Mon programme ne fonctionne pas comme je veux
    Par menoulette dans le forum Débuter avec Java
    Réponses: 6
    Dernier message: 22/04/2011, 00h16
  2. Mon programme ne fonctionne pas
    Par fouedou77 dans le forum C
    Réponses: 2
    Dernier message: 24/06/2009, 17h57
  3. Mon programme ne fonctionne pas.
    Par Apprenti Pythonien dans le forum Général Python
    Réponses: 9
    Dernier message: 13/06/2008, 18h10
  4. Mon programme ne fonctionne pas
    Par phil23 dans le forum C
    Réponses: 4
    Dernier message: 22/03/2007, 16h31
  5. mon trigger ne fonctionne pas !
    Par japi33 dans le forum SQL Procédural
    Réponses: 2
    Dernier message: 20/03/2006, 21h26

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo