Exemple #1
0
def load_map():
    size_tile = 0.64
    from clases.casilla import casilla
    from clases.objetos import objetos
    import copy
    #MatrixT = [[0 for x in xrange(30)] for x in xrange(400)]
    Matrix = []
    items = []
    itemsDisplayList = []
    global chunkDisplayList
    chunkDisplayList = glGenLists(2)

    mapa = list(csv.reader(open('assets/mapa.tmx')))
    estado = 0
    x = -1
    y = 29
    capa = -1
    #for taa in range(int(50)):
    #    self.items.append([])
    for pepe in mapa:
        if "orientation" in pepe[0]:
            pos_tmp = pepe[0].find('width="')
            string_tmp = pepe[0][pos_tmp+7:]
            pos_tmp = string_tmp.find('"')
            total_x = int(string_tmp[:pos_tmp])

            pos_tmp = pepe[0].find('height="')
            string_tmp = pepe[0][pos_tmp+8:]
            pos_tmp = string_tmp.find('"')
            total_y = int(string_tmp[:pos_tmp])
            y = total_y-1
            print total_x, total_y
            xasd = 0
            MatrixT = [[0 for xasd in xrange(total_y)] for xasd in xrange(total_x)]
            print "matrixt generado"

            for taa in range(int(total_x/8)):
                items.append([])
                itemsDisplayList.append((glGenLists(1)))

        if pepe[0] == '  <data encoding="csv">':
            capa +=1
            if (capa < 2):
                glNewList(chunkDisplayList+capa, GL_COMPILE)
            estado = 1
        elif pepe[0] == '</data>':
            if (capa < 2):
                glEndList()
            estado = 0
            Matrix.append(copy.deepcopy(MatrixT))
            x = -1
            y = total_y-1
        elif estado == 1:
            for taa in pepe:
                if taa != "":
                    x +=1
                    if (capa == 2 and int(taa)-1 != -1):
                        tmpe = casilla(int(taa)-1, objetos(int(taa)-1, 1))
                    else:
                        tmpe = casilla(int(taa)-1)
                    if (int(taa)-1 != -1):
                        if (capa < 2):
                            create_tile(x,y,int(taa)-1)
                        if (capa == 2):
                            items[int(x/20)].append([x,y,tmpe])
                    MatrixT[x][y] = tmpe
                else:
                    y -=1
                    x = -1
Exemple #2
0
    def load_map(self):
        #MatrixT = [[0 for x in xrange(30)] for x in xrange(400)]

        import csv
        mapa = list(csv.reader(open('assets/mapa.tmx')))
        estado = 0
        x = -1
        y = 29
        capa = -1
        #for taa in range(int(50)):
        #    self.items.append([])
        for pepe in mapa:
            if "orientation" in pepe[0]:
                pos_tmp = pepe[0].find('width="')
                string_tmp = pepe[0][pos_tmp + 7:]
                pos_tmp = string_tmp.find('"')
                self.total_x = int(string_tmp[:pos_tmp])

                pos_tmp = pepe[0].find('height="')
                string_tmp = pepe[0][pos_tmp + 8:]
                pos_tmp = string_tmp.find('"')
                self.total_y = int(string_tmp[:pos_tmp])
                y = self.total_y - 1
                print self.total_x, self.total_y
                xasd = 0
                MatrixT = [[0 for xasd in xrange(self.total_y)]
                           for xasd in xrange(self.total_x)]
                print "matrixt generado"

                for taa in range(int(self.total_x / 8)):
                    self.items.append([])
                    self.itemsDisplayList.append((glGenLists(1)))

            if pepe[0] == '  <data encoding="csv">':
                capa += 1
                if (capa < 2):
                    glNewList(self.chunkDisplayList + capa, GL_COMPILE)
                estado = 1
            elif pepe[0] == '</data>':
                if (capa < 2):
                    glEndList()
                estado = 0
                self.Matrix.append(copy.deepcopy(MatrixT))
                x = -1
                y = self.total_y - 1
            elif estado == 1:
                for taa in pepe:
                    if taa != "":
                        x += 1
                        if (capa == 2 and int(taa) - 1 != -1):
                            tmpe = casilla(
                                int(taa) - 1, objetos(int(taa) - 1, 1))
                        else:
                            tmpe = casilla(int(taa) - 1)
                        if (int(taa) - 1 != -1):
                            if (capa < 2):
                                self.create_tile(x, y, int(taa) - 1)
                            if (capa == 2):
                                self.items[int(x / 20)].append([x, y, tmpe])
                        MatrixT[x][y] = tmpe
                    else:
                        y -= 1
                        x = -1

        shape = []
        tmp_v = 0
        for taa in self.items:
            self.regenerate_items(tmp_v)
            tmp_v += 1
        posible_shape = [(-1, -1), (-1, -1)]
        for y in range(self.total_y):
            for x in range(self.total_x):
                s_y = (self.total_y - 1) - int(y)
                tile = self.Matrix[0][x][y].get_tile()
                if (tile != -1):
                    if posible_shape[0][0] != -1 and posible_shape[0][
                            0] != -1 and posible_shape[1][
                                0] != -1 and posible_shape[1][1] != -1:
                        shape.append(posible_shape)
                    if posible_shape[0][0] != -1 and posible_shape[0][
                            0] != -1 and posible_shape[1][
                                0] == -1 and posible_shape[1][0] == -1:
                        posible_shape[1] = posible_shape[0]
                        shape.append(posible_shape)
                    posible_shape = [(-1, -1), (-1, -1)]
                    #if (tile == 4):
                    #    self.create_colision_triangle((x,y),True)
                    #if (tile == 5):
                    #    self.create_colision_triangle((x,y),False)
                else:
                    if posible_shape[0][0] == -1 and posible_shape[0][1] == -1:
                        posible_shape[0] = (x, y)
                    else:
                        posible_shape[1] = (x, y)
                #create dynamic bodys
                tile = self.Matrix[3][x][y].get_tile()
                if (tile != -1):
                    #    pass
                    self.dynamics.append(
                        asteroids(self.worlds.CreateDynamicBody(
                            position=(x * size_tile, y * size_tile),
                            angularDamping=10.0,
                            linearDamping=10.0),
                                  tile,
                                  dl=self.global_DL))
        self.create_colision(shape)
Exemple #3
0
def load_map():
    size_tile = 0.64
    from clases.casilla import casilla
    from clases.objetos import objetos
    import copy

    # MatrixT = [[0 for x in xrange(30)] for x in xrange(400)]
    Matrix = []
    items = []
    itemsDisplayList = []
    global chunkDisplayList
    chunkDisplayList = glGenLists(2)

    mapa = list(csv.reader(open("assets/mapa.tmx")))
    estado = 0
    x = -1
    y = 29
    capa = -1
    # for taa in range(int(50)):
    #    self.items.append([])
    for pepe in mapa:
        if "orientation" in pepe[0]:
            pos_tmp = pepe[0].find('width="')
            string_tmp = pepe[0][pos_tmp + 7 :]
            pos_tmp = string_tmp.find('"')
            total_x = int(string_tmp[:pos_tmp])

            pos_tmp = pepe[0].find('height="')
            string_tmp = pepe[0][pos_tmp + 8 :]
            pos_tmp = string_tmp.find('"')
            total_y = int(string_tmp[:pos_tmp])
            y = total_y - 1
            print total_x, total_y
            xasd = 0
            MatrixT = [[0 for xasd in xrange(total_y)] for xasd in xrange(total_x)]
            print "matrixt generado"

            for taa in range(int(total_x / 8)):
                items.append([])
                itemsDisplayList.append((glGenLists(1)))

        if pepe[0] == '  <data encoding="csv">':
            capa += 1
            if capa < 2:
                glNewList(chunkDisplayList + capa, GL_COMPILE)
            estado = 1
        elif pepe[0] == "</data>":
            if capa < 2:
                glEndList()
            estado = 0
            Matrix.append(copy.deepcopy(MatrixT))
            x = -1
            y = total_y - 1
        elif estado == 1:
            for taa in pepe:
                if taa != "":
                    x += 1
                    if capa == 2 and int(taa) - 1 != -1:
                        tmpe = casilla(int(taa) - 1, objetos(int(taa) - 1, 1))
                    else:
                        tmpe = casilla(int(taa) - 1)
                    if int(taa) - 1 != -1:
                        if capa < 2:
                            create_tile(x, y, int(taa) - 1)
                        if capa == 2:
                            items[int(x / 20)].append([x, y, tmpe])
                    MatrixT[x][y] = tmpe
                else:
                    y -= 1
                    x = -1
Exemple #4
0
    def load_map(self):
        #MatrixT = [[0 for x in xrange(30)] for x in xrange(400)]

        import csv
        mapa = list(csv.reader(open('assets/mapa.tmx')))
        estado = 0
        x = -1
        y = 29
        capa = -1
        #for taa in range(int(50)):
        #    self.items.append([])
        for pepe in mapa:
            if "orientation" in pepe[0]:
                pos_tmp = pepe[0].find('width="')
                string_tmp = pepe[0][pos_tmp+7:]
                pos_tmp = string_tmp.find('"')
                self.total_x = int(string_tmp[:pos_tmp])

                pos_tmp = pepe[0].find('height="')
                string_tmp = pepe[0][pos_tmp+8:]
                pos_tmp = string_tmp.find('"')
                self.total_y = int(string_tmp[:pos_tmp])
                y = self.total_y-1
                print self.total_x, self.total_y
                xasd = 0
                MatrixT = [[0 for xasd in xrange(self.total_y)] for xasd in xrange(self.total_x)]
                print "matrixt generado"

                for taa in range(int(self.total_x/8)):
                    self.items.append([])

            if pepe[0] == '  <data encoding="csv">':
                capa +=1
                estado = 1
            elif pepe[0] == '</data>':
                estado = 0
                self.Matrix.append(copy.deepcopy(MatrixT))
                x = -1
                y = self.total_y-1
            elif estado == 1:
                for taa in pepe:
                    if taa != "":
                        x +=1
                        if (capa == 2 and int(taa)-1 != -1):
                            tmpe = casilla(int(taa)-1, objetos(int(taa)-1, 1))
                        else:
                            tmpe = casilla(int(taa)-1)
                        if (int(taa)-1 != -1):
                            if (capa == 2):
                                self.items[int(x/20)].append([x,y,tmpe])
                        MatrixT[x][y] = tmpe
                    else:
                        y -=1
                        x = -1

        shape = []

        posible_shape = [(-1,-1),(-1,-1)]
        for y in range(self.total_y):
            for x in range(self.total_x):
                s_y = (self.total_y-1) - int(y)
                tile = self.Matrix[0][x][y].get_tile()
                if (tile != -1):
                    if posible_shape[0][0] == -1 and posible_shape[0][1] == -1:
                        posible_shape[0] = (x,y)
                    else:
                        posible_shape[1] = (x,y)
                else:
                    if posible_shape[0][0] != -1 and posible_shape[0][0] != -1 and posible_shape[1][0] != -1 and posible_shape[1][1] != -1:
                        shape.append(posible_shape)
                    if posible_shape[0][0] != -1 and posible_shape[0][0] != -1 and posible_shape[1][0] == -1 and posible_shape[1][0] == -1:
                        posible_shape[1] = posible_shape[0]
                        shape.append(posible_shape)
                    posible_shape = [(-1,-1),(-1,-1)]
                    #if (tile == 4):
                    #    self.create_colision_triangle((x,y),True)
                    #if (tile == 5):
                    #    self.create_colision_triangle((x,y),False)
                #create dynamic bodys
                tile = self.Matrix[3][x][y].get_tile()
                #if (tile != -1):
                ##    pass
                #    self.dynamics.append(asteroids(self.worlds.CreateDynamicBody(position=(x*size_tile,y*size_tile), angularDamping=10.0, linearDamping= 10.0), tile, dl = self.global_DL))
        self.create_colision(shape)