Example #1
0
def resize(width, height):
    glViewport(0, 0, width, height)
    glMatrixMode(GL_PROJECTION)
    glLoadIdentity()
    gluPerspective(60.0, float(width)/height, 0.1, 1000.0)
    glMatrixMode(GL_MODELVIEW)
    glLoadIdentity()
Example #2
0
    def resizeGL(self, w, h):
        if h <= 0:
            h = 1

        glViewport(0, 0, w, h)

        glMatrixMode(GL_PROJECTION)
        glLoadIdentity()
        gluPerspective(60.0, float(w) / float(h), 0.1, 100)
Example #3
0
    def initializeGL(self):
        glClearColor(0.0, 0.0, 0.0, 0.0)
        glShadeModel(GL_SMOOTH)

        glEnable(GL_BLEND)
        glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA)

        glEnable(GL_ALPHA_TEST)
        glAlphaFunc(GL_NOTEQUAL, 0.0)

        glMatrixMode(GL_PROJECTION)
        glLoadIdentity()
        glOrtho(-50.0, 50.0, -50.0, 50.0, -1, 1)
        glMatrixMode(GL_MODELVIEW)
        glLoadIdentity()

        self.myNave = Nave(self.animation_propellant_enemy, self.player_x)
        self.in_scene.append(self.myNave)

        self.myNave2 = Nave(self.animation_propellant_enemy, self.player2_x)
        self.in_scene.append(self.myNave2)

        self.imageID_back = self.loadImage("img/Background.png")

        for i in range(EXPLOSION_FRAMES):
            self.animation_explosion[i] = self.loadImage("img/explosion/Comp" +
                                                         str(i) + ".png")

        for i in range(PROPELLANT_FRAMES):
            self.animation_propellant_enemy[i] = self.loadImage(
                "img/fire/Comp" + str(i) + ".png")

        self.img_nave_amarela = self.loadImage("img/nave4.png")
        self.img_nave_azul = self.loadImage("img/nave1.png")
        self.img_nave_preta = self.loadImage("img/nave3.png")
        self.img_tiro_amarelo = self.loadImage("img/nave4_pow.png")
        self.img_tiro_preto = self.loadImage("img/nave3_pow.png")
        self.img_tiro_azul = self.loadImage("img/nave1_pow.png")
        self.img_tiro = self.loadImage("img/nave2_pow.png")
        self.logo_init = self.loadImage("img/SpaceCute.png")
        self.logo_end = self.loadImage("img/YouDied.png")

        self.myLogo_i.load("inicio", self.logo_init, self.logo_end)
        self.ornaments.append(self.myLogo_i)
        self.myLogo_i.inited = True

        self.myLogo_e.load("fim", self.logo_init, self.logo_end)

        self.init_queue()
Example #4
0
    def paintGL(self):
        glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT)

        glMatrixMode(GL_MODELVIEW)
        glPushMatrix()

        gluLookAt(0.0, 2.5, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0)

        glRotatef(self.angle, 0.0, 1.0, 0.0)

        glBegin(GL_TRIANGLES)
        glColor3f(1.0, 1.0, 0.0)
        glVertex3f(0.0, 1.0, 0.0)
        glVertex3f(-1.0, -1.0, 0.0)
        glVertex3f(1.0, -1.0, 0.0)
        glEnd()

        glPopMatrix()

        glFlush()
Example #5
0
    def draw(self):

        glMatrixMode(GL_PROJECTION)
        glLoadIdentity()

        gluPerspective(45, 1.65, 0.1, 500)
        gluLookAt(self.xizi, self.yizi - 50, 3.9, self.xizi, self.yizi, 0, 0,
                  1, 0)
        glMatrixMode(GL_MODELVIEW)
        glLoadIdentity()

        glColor3f(1.0, 1.0, 1.0)
        glEnable(GL_TEXTURE_2D)

        glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE)
        glTexParameter(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR)
        glTexParameter(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR)
        # glRotate(20, 0, 0, 1)
        glPushMatrix()
        # glBindTexture(GL_TEXTURE_2D, self.casco)
        #
        # #Base da nave
        # glBegin(GL_TRIANGLE_FAN)
        # glTexCoord2f(0, 1)
        # glVertex3f(self.move_x + 0, self.move_y + 0, 1)
        # glTexCoord2f(1, 1)
        # glVertex3f(self.move_x + 0, self.move_y + 6, 1)
        # glTexCoord2f(1, 0)
        # glVertex3f(self.move_x + 1.5, self.move_y + 3, 1)
        # glTexCoord2f(0, 0)
        # glVertex3f(self.move_x + 2, self.move_y + 0, 1)
        # glTexCoord2f(0, 1)
        # glVertex3f(self.move_x + 5, self.move_y - 6, 1)
        # glTexCoord2f(1, 1)
        # glVertex3f(self.move_x + 2, self.move_y - 7, 1)
        # glTexCoord2f(1, 0)
        # glVertex3f(self.move_x + 1, self.move_y - 7, 1)
        # glTexCoord2f(1, 1)
        # glVertex3f(self.move_x + 0, self.move_y - 8, 1)
        # glTexCoord2f(1, 0)
        # glVertex3f(self.move_x - 1, self.move_y - 7, 1)
        # glTexCoord2f(0, 0)
        # glVertex3f(self.move_x - 2, self.move_y - 7, 1)
        # glTexCoord2f(0, 1)
        # glVertex3f(self.move_x - 5, self.move_y - 6, 1)
        # glTexCoord2f(1, 1)
        # glVertex3f(self.move_x - 2, self.move_y + 0, 1)
        # glTexCoord2f(1, 0)
        # glVertex3f(self.move_x - 1.5, self.move_y + 3, 1)
        # glTexCoord2f(0, 0)
        # glVertex3f(self.move_x + 0, self.move_y + 6, 1)
        # glEnd()
        #
        # #Casco da nave (fora)
        # glBegin(GL_QUAD_STRIP)
        # glTexCoord2f(0, 1)
        # glVertex3f(self.move_x + 0, self.move_y + 6, 1)
        # glVertex3f(self.move_x + 0, self.move_y + 3, 2)
        # glVertex3f(self.move_x + 1.5, self.move_y + 3, 1)
        # glVertex3f(self.move_x + 0.5, self.move_y + 2, 2)
        # glVertex3f(self.move_x + 2, self.move_y + 0, 1)
        # glVertex3f(self.move_x + 1, self.move_y + 0, 2)
        # glVertex3f(self.move_x + 5, self.move_y - 6, 1)
        # glVertex3f(self.move_x + 2, self.move_y - 4, 2)
        # glTexCoord2f(1, 1)
        # glVertex3f(self.move_x + 2, self.move_y - 7, 1)
        # glVertex3f(self.move_x + 1, self.move_y - 6, 2)
        # glVertex3f(self.move_x + 1, self.move_y - 7, 1)
        # glVertex3f(self.move_x + 0.5, self.move_y - 6, 2)
        # glVertex3f(self.move_x + 0, self.move_y - 8, 1)
        # glVertex3f(self.move_x + 0, self.move_y - 7, 2)
        # glVertex3f(self.move_x - 1, self.move_y - 7, 1)
        # glTexCoord2f(1, 0)
        # glVertex3f(self.move_x - 0.5, self.move_y - 6, 2)
        # glVertex3f(self.move_x - 2, self.move_y - 7, 1)
        # glVertex3f(self.move_x - 1, self.move_y - 6, 2)
        # glVertex3f(self.move_x - 5, self.move_y - 6, 1)
        # glVertex3f(self.move_x - 2, self.move_y - 4, 2)
        # glVertex3f(self.move_x - 2, self.move_y + 0, 1)
        # glTexCoord2f(0, 0)
        # glVertex3f(self.move_x - 1, self.move_y + 0, 2)
        # glVertex3f(self.move_x - 1.5, self.move_y + 3, 1)
        # glVertex3f(self.move_x - 0.5, self.move_y + 2, 2)
        # glVertex3f(self.move_x + 0, self.move_y + 6, 1)
        # glVertex3f(self.move_x + 0, self.move_y + 3, 2)
        # glEnd()
        #
        # glDisable(GL_TEXTURE_2D)
        #
        # glColor3f(1.0, 1.0, 1.0)
        # glDisable(GL_LIGHTING)
        # glEnable(GL_TEXTURE_2D)
        #
        # glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE)
        # glTexParameter(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR)
        # glTexParameter(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR)
        #
        # glBindTexture(GL_TEXTURE_2D, self.metal)
        #
        # #Parte verde
        # glBegin(GL_QUAD_STRIP)
        # glTexCoord2f(0, 1)
        # glVertex3f(self.move_x + 0, self.move_y + 3, 2)
        # glVertex3f(self.move_x + 0, self.move_y + 2, 2.5)
        # glVertex3f(self.move_x + 0.5, self.move_y + 2, 2)
        # glVertex3f(self.move_x + 0.5, self.move_y + 1, 2.5)
        # glVertex3f(self.move_x + 1, self.move_y + 0, 2)
        # glVertex3f(self.move_x + 0.5, self.move_y + 0, 2.5)
        # glVertex3f(self.move_x + 2, self.move_y - 4, 2)
        # glTexCoord2f(1, 1)
        # glVertex3f(self.move_x + 1, self.move_y - 4, 2.5)
        # glVertex3f(self.move_x + 1, self.move_y - 6, 2)
        # glVertex3f(self.move_x + 1, self.move_y - 5, 2.5)
        # glVertex3f(self.move_x + 0.5, self.move_y - 6, 2)
        # glVertex3f(self.move_x + 0.5, self.move_y - 5, 2.5)
        # glVertex3f(self.move_x + 0, self.move_y - 7, 2)
        # glVertex3f(self.move_x + 0, self.move_y - 5, 2.5)
        # glVertex3f(self.move_x - 0.5, self.move_y - 6, 2)
        # glTexCoord2f(1, 0)
        # glVertex3f(self.move_x - 0.5, self.move_y - 5, 2.5)
        # glVertex3f(self.move_x - 1, self.move_y - 6, 2)
        # glVertex3f(self.move_x - 1, self.move_y - 5, 2.5)
        # glVertex3f(self.move_x - 2, self.move_y - 4, 2)
        # glVertex3f(self.move_x - 1, self.move_y - 4, 2.5)
        # glVertex3f(self.move_x - 1, self.move_y + 0, 2)
        # glTexCoord2f(0, 0)
        # glVertex3f(self.move_x - 0.5, self.move_y + 0, 2.5)
        # glVertex3f(self.move_x - 0.5, self.move_y + 2, 2)
        # glVertex3f(self.move_x - 0.5, self.move_y + 1, 2.5)
        # glVertex3f(self.move_x + 0, self.move_y + 3, 2)
        # glVertex3f(self.move_x + 0, self.move_y + 2, 2.5)
        # glEnd()
        #
        # glDisable(GL_TEXTURE_2D)
        #
        # glColor3f(1.0, 1.0, 1.0)
        # glEnable(GL_TEXTURE_2D)
        #
        # glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE)
        # glTexParameter(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR)
        # glTexParameter(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR)
        # glBindTexture(GL_TEXTURE_2D, self.vidro)
        #
        # #Mira
        #
        # glDisable(GL_TEXTURE_2D)
        glColor3f(1, 0, 0)

        glBegin(GL_LINES)
        glVertex3f(self.move_x + 0, self.move_y + 70, 3)
        glVertex3f(self.move_x + 0, self.move_y + 70, -3)
        glEnd()
        glBegin(GL_LINES)
        glVertex3f(self.move_x + 3, self.move_y + 70, 0)
        glVertex3f(self.move_x + -3, self.move_y + 70, 0)
        glEnd()
        glPopMatrix()

        glColor3f(1.0, 1.0, 1.0)
        glEnable(GL_TEXTURE_2D)

        glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE)
        glTexParameter(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR)
        glTexParameter(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR)
        glBindTexture(GL_TEXTURE_2D, self.vidro)

        #Cookpit
        # glPushMatrix()
        glBegin(GL_QUADS)
        glTexCoord2f(0, 0)
        glVertex3f(self.move_x + -11, self.move_y + 6.9, 9.5)
        glTexCoord2f(1, 0)
        glVertex3f(self.move_x + 11, self.move_y + 6.9, 9.5)
        glTexCoord2f(1, 1)
        glVertex3f(self.move_x + 11, self.move_y + 6.9, -4)
        glTexCoord2f(0, 1)
        glVertex3f(self.move_x + -11, self.move_y + 6.9, -4)
        # glTexCoord2f(0, 1)
        # glVertex3f(self.move_x+ -50, self.move_y +50, 50)
        # glTexCoord2f(1, 1)
        # glVertex3f(self.move_x+ 50, self.move_y +50, 50)
        # glTexCoord2f(1, 0)
        # glVertex3f(self.move_x+ 50, self.move_y +-50, -50)
        # glTexCoord2f(0, 0)
        # glVertex3f(self.move_x+ -50, self.move_y +-50, -50)
        glEnd()
        glDisable(GL_TEXTURE_2D)
Example #6
0
    def initializeGL(self):
        glClearColor(0.0, 0.0, 0.0, 0.0)
        glShadeModel(GL_SMOOTH)
        glEnable(GL_DEPTH_TEST)
        glEnable(GL_BLEND)
        glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA)

        glEnable(GL_ALPHA_TEST)
        glAlphaFunc(GL_NOTEQUAL, 0.0)

        glMatrixMode(GL_PROJECTION)
        glLoadIdentity()

        gluPerspective(45, 1.65, 0.1, 500)
        gluLookAt(0, -100, 50, 0, 0, 0, 0, 1, 0)
        glMatrixMode(GL_MODELVIEW)
        glLoadIdentity()

        self.myNave = Nave(self.animation_propellant_enemy, 0)
        self.in_scene.append(self.myNave)

        for i in range(EXPLOSION_FRAMES):
            self.animation_explosion[i] = self.loadImage("img/explosion/Comp" +
                                                         str(i) + ".png")

        for i in range(PROPELLANT_FRAMES):
            self.animation_propellant_enemy[i] = self.loadImage(
                "img/fire/Comp" + str(i) + ".png")

        for i in range(10):
            self.img_planets[i] = self.loadImage("img/planets/planeta" +
                                                 str(i) + ".png")

        self.img_nave_amarela = self.loadImage("img/nave4.png")
        self.img_nave_azul = self.loadImage("img/nave1.png")
        self.img_nave_preta = self.loadImage("img/nave3.png")
        self.img_tiro_amarelo = self.loadImage("img/nave4_pow.png")
        self.img_tiro_preto = self.loadImage("img/nave3_pow.png")
        self.img_tiro_azul = self.loadImage("img/nave1_pow.png")
        self.img_tiro = self.loadImage("img/nave2_pow.png")
        self.logo_init = self.loadImage("img/SpaceCute.png")
        self.logo_end = self.loadImage("img/YouDied.png")
        self.power_up_vida = self.loadImage("img/power_up_life.png")
        self.power_up_shoot = self.loadImage("img/power_up_shot.png")
        self.power_up_speed = self.loadImage("img/power_up_speed.png")

        self.myLogo_i.load("inicio", self.logo_init, self.logo_end)
        self.ornaments.append(self.myLogo_i)
        self.myLogo_i.inited = True

        self.myLogo_e.load("fim", self.logo_init, self.logo_end)

        self.init_queue()

        # Arrumando erros de frict
        fix_p = self.propellant_queue.pop()
        fix_p.load(self.animation_propellant_enemy, 1000, 1000, "fix")
        self.ornaments.append(fix_p)

        new_explosion = self.explosion_queue.pop()
        new_explosion.load(self.animation_explosion, 1000, 1000, "fix")
        self.ornaments.append(new_explosion)

        tx = 0
        ambiente = [0.2, 0.2, 0.2, 1.0]
        difusa = [0.7, 0.7, 0.7, 1.0]
        especular = [1.0, 1.0, 1.0, 1.0]
        posicao = [0.0, 3.0, 2.0, 0.0]
        lmodelo_ambiente = [0.2, 0.2, 0.2, 1.0]

        glLightfv(GL_LIGHT0, GL_AMBIENT, ambiente)
        glLightfv(GL_LIGHT0, GL_DIFFUSE, difusa)
        glLightfv(GL_LIGHT0, GL_POSITION, posicao)
        glLightfv(GL_LIGHT0, GL_SPECULAR, especular)
        glLightModelfv(GL_LIGHT_MODEL_AMBIENT, lmodelo_ambiente)
        glEnable(GL_LIGHTING)
        glEnable(GL_LIGHT0)
        glEnable(GL_COLOR_MATERIAL)