예제 #1
0
    def __init__(self, width, height, mapFile):
        super().__init__(width, height)
        self.logger = Logger.Logger(pos = Main.WIDTH, width = Main.LOGWIDTH, height = Main.SCREEN_HEIGHT)
        path1 = Main.getPath("res/TileSheet.png")
        path2 = Main.getPath("res/AnimTileSheet.png")
        self.map = Mapper.Map(mapFile, path1, path2)

        self.CELLMAP = True

        if self.CELLMAP:
            self.tileMap, caverns = self.map.getCavernTileMap()
            playerLocationY, playerLocationX = random.choice(caverns[0])
            playerLocation = (playerLocationX, playerLocationY)
            self.player = Entities.Player(playerLocation[0],playerLocation[1],"res/playerSheet.png",self.tileMap,3,10, self.logger)
            enemyLocations = self.calculateEnemyPlacements(caverns, playerLocation)
            self.Entities = [self.player]
            for each in enemyLocations:
                seed = random.randint(0,3)
                if not seed == 1:
                    self.Entities.append(Entities.TestEnemy(each[0],each[1],self.tileMap))
                else:
                    self.Entities.append(Entities.Goblin(each[0], each[1], self.tileMap))
        else:
            self.tileMap = self.map.getTileMap()
            playerLocationY, playerLocationX = (2,2)
            playerLocation = (playerLocationY, playerLocationX)
            self.player = Entities.Player(playerLocationY,playerLocationX, "res/playerSheet.png", self.tileMap, 3, 10, self.logger)
            self.Entities = [self.player]
            #Will need to make a system of entity placement that isn't hard coded, but Im not entirely sure how other than random generation or messing around with alpha channels.
            # ^ IGNORE ALREADY DONE WITH RANDOM GEN
            self.DummyEnemies = [Entities.TestEnemy(5,5,self.tileMap, 100),
                                Entities.TestEnemy(5,7,self.tileMap, 100),
                                Entities.TestEnemy(4,6,self.tileMap, 100),
                                Entities.TestEnemy(6,6,self.tileMap, 100)]
            self.Entities.extend(self.DummyEnemies)
        self.graph = Pathing.Graph(self.tileMap)

        self.animTiles = []
        self.renderedBack = False
        self.CameraX = -(playerLocation[0] * Tiles.TILESIZE - Main.WIDTH/2)
        self.CameraY = -(playerLocation[1] * Tiles.TILESIZE - Main.HEIGHT/2)