Beispiel #1
0
        private Vector2 CalculateSpriteFrameCount()
        {
            float columns = spriteMap.GetWidth() / cellSize;
            float rows    = spriteMap.GetWidth() / cellSize;

            return(new Vector2(columns, rows));
        }
Beispiel #2
0
        private Rectangle RenderCell()
        {
            int columns = image.GetWidth() / cellSize;
            int rows    = image.GetHeight() / cellSize;

            int cellSearcher = 0;

            //Run through the tiles in the TileSet until you hit the index of the given celll
            for (int row = 0; row < rows; row++)
            {
                for (int col = 0; col < columns; col++)
                {
                    cellSearcher++;

                    if (cellSearcher == cellIndex)
                    {
                        Rectangle rendercell = new Rectangle(cellSize * col, cellSize * row, cellSize, cellSize);
                        return(rendercell);
                    }
                }
            }

            throw new CellNotFoundException();
        }