コード例 #1
0
        private void DrawBlock(GameData data, Sprite toDraw, BlockValue blockValue, int row, int col)
        {
            int textureOffset = -1;

            switch (blockValue)
            {
            case BlockValue.IShape:
                textureOffset = 0;
                break;

            case BlockValue.LShape:
                textureOffset = 1;
                break;

            case BlockValue.JShape:
                textureOffset = 2;
                break;

            case BlockValue.SShape:
                textureOffset = 3;
                break;

            case BlockValue.ZShape:
                textureOffset = 4;
                break;

            case BlockValue.TShape:
                textureOffset = 5;
                break;

            case BlockValue.OShape:
                textureOffset = 6;
                break;

            case BlockValue.Cleared:
                textureOffset = 7;
                break;
            }

            toDraw.TextureRect = new IntRect(textureOffset * Constants.BlockSize, 0, Constants.BlockSize, Constants.BlockSize);
            toDraw.Position    = new Vector2f((5 * Constants.BlockSize) + (col * Constants.BlockSize), Constants.BlockSize + (row * Constants.BlockSize));
            data.Window.Draw(toDraw);
        }