Example #1
0
        public void Draw(VideoDriver driver, Texture cellTexture)
        {
            int th = cellTexture.Size.Height;

            Recti[] srcRect = new Recti[5] {
                new Recti(th * 0, 0, th * 1, th),                // [0] passable == -1
                new Recti(th * 1, 0, th * 2, th),                // [1] impassable == -2
                new Recti(th * 2, 0, th * 3, th),                // [2] start == -3
                new Recti(th * 3, 0, th * 4, th),                // [3] finish == -4
                new Recti(th * 4, 0, th * 5, th)                 // [4] path == -5
            };

            for (int i = 0; i < cells.GetLength(0); i++)
            {
                for (int j = 0; j < cells.GetLength(1); j++)
                {
                    int k = -1 - cells[i, j];
                    if (k >= 0 && k < srcRect.Length)
                    {
                        batchSrcRect[i * cells.GetLength(1) + j] = srcRect[k];
                    }
                }
            }

            driver.Draw2DImageBatch(cellTexture, batchDestPos, batchSrcRect);
        }
Example #2
0
		public void Draw(VideoDriver driver, Texture cellTexture)
		{
			int th = cellTexture.Size.Height;

			Recti[] srcRect = new Recti[5] {
				new Recti(th * 0, 0, th * 1, th), // [0] passable == -1
				new Recti(th * 1, 0, th * 2, th), // [1] impassable == -2
				new Recti(th * 2, 0, th * 3, th), // [2] start == -3
				new Recti(th * 3, 0, th * 4, th), // [3] finish == -4
				new Recti(th * 4, 0, th * 5, th) // [4] path == -5
			};

			for (int i = 0; i < cells.GetLength(0); i++)
			{
				for (int j = 0; j < cells.GetLength(1); j++)
				{
					int k = -1 - cells[i, j];
					if (k >= 0 && k < srcRect.Length)
						batchSrcRect[i * cells.GetLength(1) + j] = srcRect[k];
				}
			}

			driver.Draw2DImageBatch(cellTexture, batchDestPos, batchSrcRect);
		}