Beispiel #1
0
    def reconstruirGame(self,nick):
        #agregar players al game
        treeP = ET()
        treeP.parse(self.playersFile + ".xml")
        root = treeP.getroot()
        self.game = Game(len(root.findall("team/player")),0,len(root.findall('team')))
        for team in root.iter("team"):
            color = team.attrib["color"]
            for tagPlayer in team.iter("player"):
                nombre = tagPlayer.attrib["nombre"]
                x = int(tagPlayer.attrib["iniX"])
                y = int(tagPlayer.attrib["iniY"])
                vidas = int(tagPlayer.attrib["vidas"])
                if nombre == nick:
                    player = Player(nombre, vidas, x, y, tagPlayer.text)
                else:
                    player = PlayerSemiAutomatico(nombre, vidas, x, y, tagPlayer.text)
                player.setTeam(color)
                self.game.AgregarPlayer(player)
        #-------------------------------------------------------------
        treeM = ET()
        treeM.parse(self.mapaFile+".xml") #revisar donde se generara el XML
        root = treeM.getroot()
        config = root.find("config")

        mapa = Mapa("currentGame")
        self.game.tiempo = int(config.attrib["tiempo"])
        mapa.setFondo(config.attrib["BG"])
        mapa.setMusica(config.attrib["BGSound"])
        mapa.stage = config.attrib["stage"]
        print "STAGE!!!!: " + mapa.stage 
        tablero = root.find("tablero")
        cuadros = tablero.find("cuadros")
        for cuadro in cuadros.iter("cuadro"):
            fila = int(cuadro.attrib["fila"])
            col = int(cuadro.attrib["columna"])
            dest = cuadro.attrib["tipo"]
            
            bloque = Bloque(fila, col, dest=="D")
            bloque.setSpriteB(cuadro.text)
            bloque.setPowerUp(cuadro.attrib["tipoPower"], cuadro.attrib["powerup"])
            bloque.tienePowerUp = not(cuadro.attrib["powerup"] == "__EMPTY__")
            if mapa.stage == "STAGE3_4":
                bloque.autoDisappear = False
                bloque.destruir()
            if not mapa.bloques.has_key(fila):
                mapa.bloques[fila] = dict()
            mapa.bloques[fila][col] = bloque

        self.game.mapa = mapa
        GameOverLogic.game = self.game

        return self.game
Beispiel #2
0
    def cargarBase(self):
        tree = ET()
        tree.parse(self.tableros + self.nombre + ".xml")
        root = tree.getroot()

        self.count = int(root.find("cantPowerUps").text)
        self.fondo = root.find("fondo").text
        self.musica = root.find("musica").text
        self.stage = root.find("title").text

        for child in root.iter("bloque"):

            x = int(child.attrib["fila"])
            if not self.bloques.has_key(x):
                self.bloques[x] = dict()
            y = int(child.attrib["col"])
            tipo = child.attrib["tipo"]
            bloque = Bloque(x, y, tipo == "D")
            bloque.destruir()
            bloque.setSpriteB(child.text)
            self.bloques[x][y] = bloque
Beispiel #3
0
    def cargarObjetosMapa(self):
        indice_col = 0
        indice_fil = 0
        all_bloque_sprites = pygame.sprite.Group()
        all_sprites = pygame.sprite.Group()
        all_generadores_caracoles = pygame.sprite.Group()
        for fil_m in self.filas_mapa:
            for dato in fil_m:
                if dato == "b" or dato == "T" or dato == "a":  # Condicion para definir los elementos Bloque (piedas, palmas, tubos)
                    bloque = Bloque(self.lista_obj_sprite[dato], [
                        indice_col * self.an_sprites,
                        indice_fil * self.al_sprites
                    ])
                    all_bloque_sprites.add(bloque)
                    all_sprites.add(bloque)
                if dato == "e":  # bloque especial con los 3 modificadores
                    bloque_e = Bloque_especial([
                        indice_col * self.an_sprites,
                        indice_fil * self.al_sprites
                    ])
                    all_bloque_sprites.add(bloque_e)
                    all_sprites.add(bloque_e)
                if dato == "G":  # generador de hongos
                    generador = Generador_hongos(self.lista_obj_sprite[dato], [
                        indice_col * self.an_sprites,
                        indice_fil * self.al_sprites
                    ])
                    all_bloque_sprites.add(generador)
                    all_sprites.add(generador)
                if dato == "C":  # generador de caracoles
                    generador2 = Generador_caracol([600, 100])
                    all_generadores_caracoles.add(generador2)
                    all_sprites.add(generador2)
                indice_col += 1
            indice_fil += 1
            indice_col = 0

        return all_sprites, all_bloque_sprites, all_generadores_caracoles
Beispiel #4
0
 def __init__(self, size):
     self.memory = [Bloque(0) for i in range(size)]