Beispiel #1
0
        public override IndexKeeper[] GetRotationPositions()
        {
            IndexKeeper[] rotationPositions = new IndexKeeper[4];

            if (state == 0)
            {
                int i = positions[3].X;
                int j = positions[3].Y;

                rotationPositions[0] = new IndexKeeper(i + 1, j + 1);
                rotationPositions[1] = new IndexKeeper(i, j + 1);
                rotationPositions[2] = new IndexKeeper(i, j);
                rotationPositions[3] = new IndexKeeper(i - 1, j);
            }
            else
            {
                int i = positions[2].X;
                int j = positions[2].Y;

                rotationPositions[3] = new IndexKeeper(i, j);
                rotationPositions[2] = new IndexKeeper(i, j + 1);
                rotationPositions[1] = new IndexKeeper(i + 1, j - 1);
                rotationPositions[0] = new IndexKeeper(i + 1, j);
            }

            return(rotationPositions);
        }
Beispiel #2
0
        public JPiece(int width) : base(Color.FromArgb(0, 48, 185), null)
        {
            int middle = (int)Math.Floor((width - 1) * 1.0 / 2);

            positions      = new IndexKeeper[4];
            positions[3]   = new IndexKeeper(0, middle - 1);
            positions[2]   = new IndexKeeper(0, middle);
            positions[1]   = new IndexKeeper(0, middle + 1);
            positions[0]   = new IndexKeeper(1, middle + 1);
            base.positions = positions;
        }
Beispiel #3
0
        //проверува дали индексот [i, j] е во тековната форма
        public bool IsInCurrentShape(IndexKeeper index)
        {
            foreach (IndexKeeper i in currentShape.positions)
            {
                if (index.Equals(i))
                {
                    return(true);
                }
            }

            return(false);
        }
Beispiel #4
0
        //ја придвижува формата налево
        public void MoveLeft()
        {
            if (currentShape == null)
            {
                return;
            }
            if (!CanGoLeft())
            {
                return;
            }

            for (int i = currentShape.positions.Count() - 1; i >= 0; i--)
            {
                IndexKeeper index = currentShape.positions[i];
                matrix[index.X, index.Y].taken = false;
                matrix[index.X, index.Y].Color = BACKGROUND_COLOR;
                currentShape.positions[i].Y--;
                matrix[index.X, index.Y].taken = true;
                matrix[index.X, index.Y].Color = currentShape.color;
            }
            Draw();
        }
Beispiel #5
0
 public bool Equals(IndexKeeper index)
 {
     return(X == index.X && Y == index.Y);
 }