Example #1
0
    def __init__(self,
                 x,
                 y,
                 z,
                 Width,
                 Height,
                 Depth,
                 life,
                 speed,
                 name,
                 centered=False):
        self.name = name
        self.pos = vec3(x, y, z)
        self.scale = vec3(Width, Height, Depth)
        self.rotation = 0
        self.worldMatrix = None
        self.setWorldMatrix()

        self.Width = Width
        self.Height = Height
        self.Depth = Depth
        self.life = life
        self.speed = speed
        #self.hitBox     = BoundingBox(self.pos, vec3(x+Width, y+Height, z+Depth))

        self.deathFadeT = globs.bulletLife
        self.State = globs.ALIVE
        self.fadeTime = 0
        self.centered = centered

        if Entity.vao == None:
            vbuff = array.array("f")
            centerVbuff = array.array("f")

            tbuff = array.array("f")
            centerTBuff = array.array("f")

            ibuff = array.array("I")
            centerIBuff = array.array("I")

            Shapes.createSquare(
                vbuff, 1, 1, 0,
                0)  #create vbuff of square that is 1 by 1 at center of screen
            Shapes.createSquare(centerVbuff, 1, 1, 0, 0, True)

            Shapes.createSquareIndexArray(ibuff)
            Shapes.createSquareIndexArray(centerIBuff, True)

            Shapes.createSquareTextureArray(tbuff)
            Shapes.createSquareTextureArray(centerTBuff, 1, True)

            Entity.vao = glCommands.setup(vbuff, tbuff, ibuff)
            Entity.centerVao = glCommands.setup(centerVbuff, centerTBuff,
                                                centerIBuff)

            Entity.ibuffSize = len(ibuff)
            Entity.ibuffCenterSize = len(centerIBuff)
            Entity.ibuffStart = 0

            Entity.prog = Program("vs.txt", "fs.txt")
Example #2
0
 def __init__(self):
     with open(os.path.join("assets", "map.tmx")) as fp:
         data = fp.read()
     i = data.find("<data ")
     j = data.find("</data>")
     tiles = data[i:j]
     i = tiles.find(">")
     tiles = tiles[i + 1:].strip()
     L = tiles.split("\n")
     outputList = []
     for line in L:
         if line.endswith(","):
             line = line[:-1]
         outputList.append([int(q) for q in line.split(",")])
     self.tileList = outputList
     self.pos = math3d.vec2(0, 0)
     self.size = 2 / len(self.tileList)
     self.texList = []
     if Map.vao == None:
         Map.vbuff = array.array("f")
         Map.tbuff = array.array("f")
         Map.ibuff = array.array("I")
         for i in range(len(globs.mapTextures)):
             self.texList.append(
                 ImageTexture2DArray.ImageTexture2DArray(
                     globs.mapTextures[i]))
         Shapes.createSquare(Map.vbuff, self.size, self.size, -1, -1)
         Shapes.createSquareTextureArray(Map.tbuff)
         Shapes.createSquareIndexArray(Map.ibuff)
         self.vao = glCommands.setup(Map.vbuff, Map.tbuff, Map.ibuff)
Example #3
0
    def __init__(self, x, y, size):
        self.pos = math3d.vec2(x, y)  #set players start position
        self.crouchScale = math3d.vec2(1, .5)
        self.crouching = False
        self.direction = 0  #-1:Left, 1:Right
        self.lastFired = 0  #Time since last Fired
        self.state = globs.ON_GROUND  #State player is in
        self.life = 10  #amount of life left
        self.size = size  #Scale of player
        self.halfSize = size / 2  #half scale of player

        #'''
        if Player.vao == None:
            Player.vbuff = array.array("f")
            Player.tbuff = array.array("f")
            Player.ibuff = array.array("I")
            Shapes.createSquare(Player.vbuff, size, size, x, y)
            Shapes.createSquareTextureArray(Player.tbuff)
            Shapes.createSquareIndexArray(Player.ibuff)
            Player.vao = glCommands.setup(Player.vbuff, Player.tbuff,
                                          Player.ibuff)
        #'''
        #super().__init__()

        if Player.tex == None:
            Player.tex = ImageTexture2DArray.ImageTexture2DArray(
                *globs.playerTextures)
Example #4
0
    def __init__(self, x, y, direction, Width, Height, life, speed):
        self.pos = math3d.vec2(x, y)
        self.scale = math3d.vec2(Width, Height)
        self.Width = Width
        self.Height = Height
        self.dir = direction
        self.life = life
        self.speed = speed

        if Entity.vao == None:
            vbuff = array.array("f")
            tbuff = array.array("f")
            ibuff = array.array("I")
            Entity.ibuffSize = len(ibuff)
            Entity.ibuffStart = 0

            Shapes.createSquare(
                vbuff, 1, 1, 0,
                0)  #create vbuff of square that is 1 by 1 at center of screen
            Shapes.createSquareIndexArray(ibuff)
            Shapes.createSquareTextureArray(tbuff)
            Entity.vao = glCommands.setup(vbuff, tbuff, ibuff)

            Entity.ibuffSize = len(ibuff)
            Entity.ibuffStart = 0
Example #5
0
    def __init__(self, x, y, direction, Width, Height, life, speed):
        self.pos = math3d.vec2(x, y)
        self.scale = math3d.vec2(Width, Height)
        self.Width = Width
        self.Height = Height
        self.dir = direction
        self.life = life
        self.speed = speed
        self.hitBox = BoundingBox(self.pos, math3d.vec2(x + Width, y + Height))

        self.deathFadeT = globs.bulletLife
        self.State = globs.ALIVE
        self.fadeTime = 0

        if Entity.vao == None:
            vbuff = array.array("f")
            tbuff = array.array("f")
            ibuff = array.array("I")
            Entity.ibuffSize = len(ibuff)
            Entity.ibuffStart = 0

            Shapes.createSquare(
                vbuff, 1, 1, 0,
                0)  #create vbuff of square that is 1 by 1 at center of screen
            Shapes.createSquareIndexArray(ibuff)
            Shapes.createSquareTextureArray(tbuff)
            Entity.vao = glCommands.setup(vbuff, tbuff, ibuff)

            Entity.ibuffSize = len(ibuff)
            Entity.ibuffStart = 0

            Entity.prog = Program("vs.txt", "fs.txt")
 def __init__(self, x, y, size):
     self.pos = math3d.vec2(x, y)
     self.size = size
     if mapSquare.vbuff == None or mapSquare.tbuff == None or mapSquare.ibuff == None:
         mapSquare.vbuff = array.array("f")
         mapSquare.tbuff = array.array("f")
         mapSquare.ibuff = array.array("I")
         mapSquare.tex = ImageTexture2DArray(globs.mapTextures)
         Shapes.createSquare(mapSquare.vbuff, self.size, self.pox.x,
                             self.pos.y)
         Shapes.createSquareIndexArray(mapSquare.ibuff)
         glCommands.setup(mapSquare.vbuff, mapSquare.ibuff, mapSquare.tbuff)
Example #7
0
    def __init__(self):
        if Entity.vao == None:
            print("making vao")
            vbuff = array.array("f")
            tbuff = array.array("f")
            ibuff = array.array("f")
            Entity.ibuffSize = len(ibuff)
            Entity.ibuffStart = 0

            Shapes.createSquare(vbuff, 1, 1) #create vbuff of square that is 1 by 1
            Shapes.createTriangleIndexArray(ibuff)
            Shapes.createSquareTextureArray(tbuff)
            Entity.vao = glCommands.setup(vbuff, tbuff, ibuff)
Example #8
0
    def __init__(self, x, y, direction, size=.05):
        self.pos = math3d.vec2(x, y)
        self.dir = direction
        self.life = 750

        if Bullet.vbuff == None and Bullet.ibuff == None:
            Bullet.vbuff = array.array("f")
            Bullet.tbuff = array.array("f")
            Bullet.ibuff = array.array("I")
            Bullet.tex = ImageTexture2DArray.ImageTexture2DArray(
                globs.bulletTextures[0])
            Shapes.createSquare(Bullet.vbuff, size, size, x, y)
            Shapes.createSquareTextureArray(Bullet.tbuff)
            Shapes.createSquareIndexArray(Bullet.ibuff)
            Bullet.vao = glCommands.setup(Bullet.vbuff, Bullet.tbuff,
                                          Bullet.ibuff)

        self.playSound()