コード例 #1
0
        public void Rotate(bool Clockwise)
        {
            if (Clockwise)
            {
                switch (Formation)
                {
                case IblockState.one:
                    Formation = IblockState.two;
                    UpdateFormation();
                    break;

                case IblockState.two:
                    Formation = IblockState.three;
                    UpdateFormation();
                    break;

                case IblockState.three:
                    Formation = IblockState.four;
                    UpdateFormation();
                    break;

                case IblockState.four:
                    Formation = IblockState.one;
                    UpdateFormation();
                    break;
                }
            }
            else if (!Clockwise)
            {
                switch (Formation)
                {
                case IblockState.one:
                    Formation = IblockState.four;
                    UpdateFormation();
                    break;

                case IblockState.two:
                    Formation = IblockState.one;
                    UpdateFormation();
                    break;

                case IblockState.three:
                    Formation = IblockState.two;
                    UpdateFormation();
                    break;

                case IblockState.four:
                    Formation = IblockState.three;
                    UpdateFormation();
                    break;
                }
            }
        }
コード例 #2
0
        public I(Texture2D color, Vector2 startPos)
        {
            magicFlames = new List <AnimatedObject>();

            Color = color;

            iMatrix = new TetrisObject[4, 4];

            //Contents of the I, looping through the matrix setting positions and textures
            for (int i = 0; i < iMatrix.GetLength(0); i++)
            {
                for (int j = 0; j < iMatrix.GetLength(1); j++)
                {
                    iMatrix[i, j] = new TetrisObject(Vector2.Zero, color)
                    {
                        PosX = startPos.X + i * color.Width,
                        PosY = startPos.Y + j * color.Height
                    };
                }
            }
            Formation = IblockState.one;//Default Formation of the I figure
            UpdateFormation();
        }