Ejemplo n.º 1
0
        public void Rotate(bool Clockwise)
        {
            if (Clockwise)
            {
                switch (Formation)
                {
                case blockState.one:
                    Formation = blockState.two;
                    UpdateFormation();
                    break;

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

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

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

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

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

                case blockState.four:
                    Formation = blockState.three;
                    UpdateFormation();
                    break;
                }
            }
        }
Ejemplo n.º 2
0
        public J(Texture2D color, Vector2 startPos)
        {
            magicFlames = new List <AnimatedObject>();

            this.color    = color;
            this.startPos = startPos;
            jMatrix       = new TetrisObject[3, 3];

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

            Formation = blockState.one;//Default formation of the J figure
            UpdateFormation();
        }