Exemplo n.º 1
0
    def deplacer(self, matrix = None):
        if self.alive:

            if self.speed != 0: self.is_walking = True
            angle = deg2rad(self.angle)
            ex, ey, ez = self.position
            dx, dy, dz = math.sin(angle), 0, math.cos(angle)
            l = math.sqrt(dx*dx + dy*dy + dz*dz)
            d1x, d1y,d1z = dx/l, dy/l, dz/l
            
            destination = [ex + self.speed*d1x, 0 , ez + self.speed*d1z]

            if matrix != None:

                try:
                    x,y,z = destination
                    x = int((x)/TAILLE_BLOC) #(round(x,0))
                    y = int((y)/TAILLE_BLOC) #(round(y,0))
                    z = int((z)/TAILLE_BLOC) #(round(z,0))
                    if matrix[x][z].mur:
                        #self.position[1] = HAUTEUR_TROTTOIR
                        self.speed /= 1.5
                        if self.delai_son_crash >= 50 :
                            sound_data.crash.play()
                            self.delai_son_crash = 0
                    else:
                        self.position = destination
                except IndexError:
                    pass # en dehors de la ville
            else:
                self.position = destination
Exemplo n.º 2
0
    def deplacer(self, matrix=None):
        if self.alive:

            if self.speed != 0: self.is_walking = True
            angle = deg2rad(self.angle)
            ex, ey, ez = self.position
            dx, dy, dz = math.sin(angle), 0, math.cos(angle)
            l = math.sqrt(dx * dx + dy * dy + dz * dz)
            d1x, d1y, d1z = dx / l, dy / l, dz / l

            destination = [ex + self.speed * d1x, 0, ez + self.speed * d1z]

            if matrix != None:

                try:
                    x, y, z = destination
                    x = int((x) / TAILLE_BLOC)  #(round(x,0))
                    y = int((y) / TAILLE_BLOC)  #(round(y,0))
                    z = int((z) / TAILLE_BLOC)  #(round(z,0))
                    if matrix[x][z].mur:
                        #self.position[1] = HAUTEUR_TROTTOIR
                        self.speed /= 1.5
                        if self.delai_son_crash >= 50:
                            sound_data.crash.play()
                            self.delai_son_crash = 0
                    else:
                        self.position = destination
                except IndexError:
                    pass  # en dehors de la ville
            else:
                self.position = destination
Exemplo n.º 3
0
def on_draw():
    global game, vitesse, playing, gameover, gameover_score
    global cam, hauteur_camera, w, h

    pointVise = game.vehicule.position
    alpha = camera.deg2rad(game.vehicule.angle)
    ax, ay, az = pointVise
    ay += 1
    ex, ey, ez = ax + math.sin(
        alpha) * DISTANCE_CAMERA * -1, hauteur_camera, az + math.cos(
            alpha) * DISTANCE_CAMERA * -1

    if playing:
        glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT)

        actualiser_vitesse()
        actualiser_score()
        actualiser_temps()
        game.draw([ex / TAILLE_BLOC, ez / TAILLE_BLOC])

        # Placement de la camera virtuelle

        glLoadIdentity()
        prepare_text()
        vitesse.draw()
        score.draw()
        temps.draw()
        if game.vehicule.transporte_un_client:
            actualiser_distance()
            distance.draw()
        if game.pause: pause.draw()
        after_text()
        gluPerspective((game.vehicule.speed * 110 + FOCALE_DE_BASE),
                       w / float(h), .1, 1000.)
        gluLookAt(ex, ey, ez, ax, ay, az, 0.0, 1.0, 0.0)
    elif gameover:
        glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT)
        glLoadIdentity()
        actualiser_menu()
        prepare_text()
        gameover_score.draw()
        best_score.draw()
        after_text()
        gluPerspective((game.vehicule.speed * 110 + FOCALE_DE_BASE),
                       w / float(h), .1, 1000.)
        gluLookAt(ex, ey, ez, ax, ay, az, 0.0, 1.0, 0.0)
    else:
        glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT)
        glLoadIdentity()
        actualiser_menu()
        prepare_text()
        jouer.draw()
        quitter.draw()
        best_score.draw()
        after_text()
        gluPerspective((game.vehicule.speed * 110 + FOCALE_DE_BASE),
                       w / float(h), .1, 1000.)
        gluLookAt(ex, ey, ez, ax, ay, az, 0.0, 1.0, 0.0)
Exemplo n.º 4
0
def on_draw():
        global game, vitesse, playing, gameover, gameover_score
        global cam, hauteur_camera, w, h

        pointVise = game.vehicule.position
        alpha = camera.deg2rad(game.vehicule.angle)
        ax, ay, az = pointVise
        ay += 1
        ex,ey,ez = ax + math.sin(alpha)*DISTANCE_CAMERA*-1, hauteur_camera, az + math.cos(alpha)*DISTANCE_CAMERA*-1
                

        if playing:
                glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT)

                actualiser_vitesse()
                actualiser_score()
                actualiser_temps()
                game.draw([ex/TAILLE_BLOC, ez/TAILLE_BLOC])

                # Placement de la camera virtuelle
                
                glLoadIdentity()
                prepare_text()
                vitesse.draw()
                score.draw()
                temps.draw()
                if game.vehicule.transporte_un_client:
                        actualiser_distance()
                        distance.draw()
                if game.pause: pause.draw()
                after_text()
                gluPerspective((game.vehicule.speed*110 + FOCALE_DE_BASE) , w / float(h), .1, 1000.)
                gluLookAt( ex,ey,ez,  ax, ay, az,  0.0,1.0,0.0)
        elif gameover:
                glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT)
                glLoadIdentity()
                actualiser_menu()
                prepare_text()
                gameover_score.draw()
                best_score.draw()
                after_text()
                gluPerspective((game.vehicule.speed*110 + FOCALE_DE_BASE) , w / float(h), .1, 1000.)
                gluLookAt( ex,ey,ez,  ax, ay, az,  0.0,1.0,0.0)
        else:
                glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT)
                glLoadIdentity()
                actualiser_menu()
                prepare_text()
                jouer.draw()
                quitter.draw()
                best_score.draw()
                after_text()
                gluPerspective((game.vehicule.speed*110 + FOCALE_DE_BASE) , w / float(h), .1, 1000.)
                gluLookAt( ex,ey,ez,  ax, ay, az,  0.0,1.0,0.0)
Exemplo n.º 5
0
    def deplacer(self):

        matrix = self.game.map.getMatrice()

        angle = deg2rad(self.angle)
        ex, ey, ez = self.position
        dx, dy, dz = math.sin(angle), 0, math.cos(angle)
        l = math.sqrt(dx * dx + dy * dy + dz * dz)
        d1x, d1y, d1z = dx / l, dy / l, dz / l

        destination = [
            ex + VITESSE_PIETON * d1x, self.position[1],
            ez + VITESSE_PIETON * d1z
        ]

        if matrix != None:

            try:
                x, y, z = destination
                x = int((x) / TAILLE_BLOC)
                y = int((y) / TAILLE_BLOC)
                z = int((z) / TAILLE_BLOC)

                if matrix[x][z].texture in [2, 3, 7, 12]:
                    self.position = destination
                    self.position[1] = HAUTEUR_TROTTOIR
                    self.animer = True
                elif matrix[x][z].texture == 4:
                    self.position = destination
                    self.position[1] = 0
                    self.animer = True
                elif self.follow_mode and matrix[x][z].texture in [0, 5, 6]:
                    self.position = destination
                    self.position[1] = 0
                    self.animer = True
                else:
                    self.animer = False
                    self.position[1] = HAUTEUR_TROTTOIR
                    self.delai_rotation += 5
            except IndexError:
                pass  # en dehors de la ville
        else:
            self.position = destination
Exemplo n.º 6
0
    def deplacer(self):

        matrix = self.game.map.getMatrice()

        angle = deg2rad(self.angle)
        ex, ey, ez = self.position
        dx, dy, dz = math.sin(angle), 0, math.cos(angle)
        l = math.sqrt(dx*dx + dy*dy + dz*dz)
        d1x, d1y,d1z = dx/l, dy/l, dz/l
        
        destination = [ex + VITESSE_PIETON*d1x, self.position[1] , ez + VITESSE_PIETON*d1z]

        if matrix != None:

            try:
                x,y,z = destination
                x = int((x)/TAILLE_BLOC)
                y = int((y)/TAILLE_BLOC)
                z = int((z)/TAILLE_BLOC)
                
                if matrix[x][z].texture in [2,3,7,12]:
                    self.position = destination
                    self.position[1] = HAUTEUR_TROTTOIR
                    self.animer = True
                elif matrix[x][z].texture == 4:
                    self.position = destination
                    self.position[1] = 0
                    self.animer = True
                elif self.follow_mode and matrix[x][z].texture in [0,5,6]:
                    self.position = destination
                    self.position[1] = 0
                    self.animer = True
                else:
                    self.animer = False
                    self.position[1] = HAUTEUR_TROTTOIR
                    self.delai_rotation += 5
            except IndexError:
                pass # en dehors de la ville
        else:
            self.position = destination