Пример #1
0
    def test3(self):
        #logging.basicConfig(level = logging.DEBUG)

        worldMap = [
            [1, 1, 2, 2, 2, 3, 2, 1, 4, 1, 3, 1, 1, 1, 1, 1, 1],
            [1, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1],
            [1, 0, 2, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1],
            [1, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1],
            [1, 0, 2, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1],
            [1, 0, 2, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1],
            [1, 0, 2, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1],
            [1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1],
            [1, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1],
            [1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1],
            [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],
        ]

        lay = MatrixSceneLayer(None, worldMap)

        # load Texture
        lay.texmapping[1] = StrechedTexture("wolfenscii/asset/test/tex2")

        line = 34
        cols = 41
        canvas = [[Pixel() for i in range(cols)] for j in range(line)]

        res = lay.update(canvas)
        printCanvas(canvas)
Пример #2
0
    def test_rotate1(self):
        logging.basicConfig(level=logging.DEBUG)

        worldMap = []

        lay = MatrixSceneLayer(None, worldMap)

        lay.playerTurnRight()
Пример #3
0
    def __init__(self, rows, cols):
        self.canvas = []
        self.rows = rows
        self.cols = cols

        self.debugLayer = DebugLayer()

        worldMap = [
            [1, 1, 1, 1, 1, 1, 2, 1, 3, 1, 3, 1, 1, 1, 1, 1, 1],
            [3, 0, 0, 0, 0, 0, 0, 0, 3, 2, 0, 0, 0, 0, 0, 0, 1],
            [3, 0, 0, 0, 2, 0, 0, 0, 3, 2, 0, 0, 0, 0, 0, 0, 1],
            [3, 0, 0, 0, 0, 0, 0, 0, 3, 2, 0, 0, 0, 0, 0, 0, 1],
            [3, 0, 0, 0, 0, 0, 0, 0, 3, 2, 0, 0, 0, 0, 0, 0, 1],
            [3, 0, 0, 0, 0, 0, 0, 0, 3, 2, 0, 0, 8, 8, 8, 8, 1],
            [3, 0, 0, 0, 0, 0, 0, 0, 4, 2, 0, 0, 0, 0, 0, 0, 1],
            [3, 0, 0, 0, 0, 0, 0, 0, 4, 2, 0, 0, 0, 0, 0, 0, 1],
            [3, 0, 0, 0, 0, 0, 0, 0, 4, 2, 0, 0, 0, 0, 0, 0, 1],
            [3, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 1],
            [3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1],
            [3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1],
            [3, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 1],
            [3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1],
            [3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1],
            [3, 0, 0, 0, 0, 0, 0, 0, 0, 6, 0, 0, 0, 0, 0, 0, 1],
            [3, 0, 0, 0, 0, 0, 0, 0, 0, 6, 0, 0, 0, 0, 0, 0, 1],
            [3, 0, 0, 0, 0, 0, 0, 0, 0, 6, 0, 0, 0, 0, 0, 0, 1],
            [3, 0, 0, 0, 0, 0, 0, 0, 0, 6, 0, 0, 0, 0, 0, 0, 1],
            [3, 0, 0, 0, 0, 0, 0, 0, 0, 6, 0, 0, 0, 0, 0, 0, 1],
            [3, 0, 0, 0, 0, 0, 0, 0, 0, 6, 0, 0, 0, 0, 0, 0, 1],
            [3, 0, 0, 0, 0, 0, 0, 0, 0, 6, 0, 0, 0, 0, 0, 0, 1],
            [3, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],
        ]

        self.sceneLayer = MatrixSceneLayer(self.debugLayer, worldMap)

        # load Texture
        self.sceneLayer.texmapping[1] = StrechedTexture(
            "wolfenscii/asset/test/tex1")
        self.sceneLayer.texmapping[2] = StrechedTexture(
            "wolfenscii/asset/test/tex2")
        self.sceneLayer.texmapping[3] = StrechedTexture(
            "wolfenscii/asset/test/tex3")
        self.sceneLayer.texmapping[4] = StrechedTexture(
            "wolfenscii/asset/test/tex4")
        self.sceneLayer.texmapping[5] = StrechedTexture(
            "wolfenscii/asset/test/tex3")
        self.sceneLayer.texmapping[6] = StrechedTexture(
            "wolfenscii/asset/test/tex3")
        self.sceneLayer.texmapping[7] = StrechedTexture(
            "wolfenscii/asset/test/tex3")
        self.sceneLayer.texmapping[8] = StrechedTexture(
            "wolfenscii/asset/test/tex3")
        self.sceneLayer.texmapping[9] = StrechedTexture(
            "wolfenscii/asset/test/tex3")

        self.layers = [ClearCanvas(), self.sceneLayer, self.debugLayer]
        self.lastKey = ""
        self.__populateCanvas()
Пример #4
0
    def test_setAutoMove(self):
        #logging.basicConfig(level = logging.DEBUG)

        worldMap = [
            [1, 1, 2, 2, 2, 3, 2, 1, 4, 1, 3, 1, 1, 1, 1, 1, 1],
            [1, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1],
            [1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1],
            [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],
        ]

        lay = MatrixSceneLayer(None, worldMap)
        lay.posX = 1
        lay.posY = 1
        for i in range(1000):
            lay.setAutoMove(True)
            for x, y in lay.apmRoute:
                worldMap[x][y]
Пример #5
0
    def test1(self):
        logging.basicConfig(level=logging.DEBUG)

        worldMap = [
            [1, 1, 1, 1, 1, 1, 2, 1, 3, 1, 3, 1, 1, 1, 1, 1, 1],
            [1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1],
            [1, 0, 2, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1],
            [1, 0, 0, 0, 0, 0, 0, 0, 0, 6, 0, 0, 0, 0, 0, 0, 1],
            [1, 0, 2, 0, 0, 0, 0, 0, 0, 6, 0, 0, 0, 0, 0, 0, 1],
            [1, 0, 2, 0, 0, 0, 0, 0, 0, 6, 0, 0, 8, 8, 8, 8, 1],
            [1, 0, 2, 0, 0, 0, 0, 0, 0, 6, 0, 0, 0, 0, 0, 0, 1],
            [1, 0, 0, 0, 0, 0, 0, 0, 0, 6, 0, 0, 0, 0, 0, 0, 1],
            [1, 0, 2, 0, 0, 0, 0, 0, 0, 6, 0, 0, 0, 0, 0, 0, 1],
            [1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1],
            [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],
        ]

        lay = MatrixSceneLayer(None, worldMap)

        res = lay.raycast(10)
        print res
Пример #6
0
    def test_randomPoint(self):
        #logging.basicConfig(level = logging.DEBUG)

        worldMap = [
            [1, 1, 2, 2, 2, 3, 2, 1, 4, 1, 3, 1, 1, 1, 1, 1, 1],
            [1, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1],
            [1, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1],
            [1, 0, 2, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1],
            [1, 0, 2, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1],
            [1, 0, 2, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1],
            [1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1],
            [1, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1],
            [1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1],
            [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],
        ]

        lay = MatrixSceneLayer(None, worldMap)

        for i in range(1000):
            x, y = lay._randomPointInMap()

            self.assertTrue(worldMap[x][y] == 0)
Пример #7
0
    def test2(self):
        logging.basicConfig(level=logging.DEBUG)

        worldMap = [
            [1, 1, 1, 1, 1, 3, 2, 1, 4, 1, 3, 1, 1, 1, 1, 1, 1],
            [1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1],
            [1, 0, 2, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1],
            [1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1],
            [1, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1],
            [1, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1],
            [1, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1],
            [1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1],
            [1, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1],
            [1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1],
            [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],
        ]

        lay = MatrixSceneLayer(None, worldMap)

        line = 34
        cols = 41
        canvas = [[Pixel() for i in range(cols)] for j in range(line)]

        res = lay.update(canvas)