public void Rotate()
        {
            do_CopyBlocks();

            int StartX = do_GetStartX();
            int StartY = do_GetStartY();
            int EndX   = do_GetEndX();
            int EndY   = do_GetEndY();

            for (int Loop = 0; Loop < Blocks.Count; Loop++)
            {
                TBlock Block = Blocks[Loop];
                int    X     = Block.X;
                int    Y     = Block.Y;

                //To prevent shape to be of left side board.
                Block.X = StartX + (EndY - Y);
                if (Block.X >= 400)
                {
                    return;
                }

                Block.Y = X + EndY - EndX;
                //To prevent shape to be of right side board.
                if (Block.Y >= 600)
                {
                    return;
                }
            }

            do_CopyToBlockSrc();
        }
Exemplo n.º 2
0
        //T-SHAPE
        public TBlockShapeD() : base()
        {
            Blocks     = new List <TBlock>();
            MoveBlocks = new TMoveBlocks(Blocks);

            TBlock Block = new TBlock();

            Block.X = 200;
            Block.Y = 0;
            Blocks.Add(Block);

            Block   = new TBlock();
            Block.X = 200;
            Block.Y = 25;
            Blocks.Add(Block);

            Block   = new TBlock();
            Block.X = 200;
            Block.Y = 50;
            Blocks.Add(Block);

            Block   = new TBlock();
            Block.X = 225;
            Block.Y = 25;
            Blocks.Add(Block);
        }
Exemplo n.º 3
0
        public TBoard()
        {
            Cells           = new TBlock[400, 625];
            GameEnd         = false;
            _lineclearcount = 0;
            _score          = 0;


            _startX = 0;
            _endX   = 400;
            _startY = 100;
            _endY   = 600;

            for (int LoopX = 0; LoopX < 400; LoopX++)
            {
                for (int LoopY = 0; LoopY < 600; LoopY++)
                {
                    Cells [LoopX, LoopY] = null;
                }
            }

            for (int LoopX = 0; LoopX < 400; LoopX++)
            {
                for (int LoopY = 0; LoopY < 625; LoopY++)
                {
                    if (LoopY == 600)
                    {
                        TBlock Block = new TBlock();
                        Cells [LoopX, LoopY] = Block;
                    }
                }
            }
        }
 private void do_CopyBlocks()
 {
     Blocks.Clear();             //deltete all the items in Blocks
     for (int i = 0; i < BlockSrc.Count; i++)
     {
         TBlock Block = new TBlock();
         Block.X = BlockSrc[i].X;
         Block.Y = BlockSrc[i].Y;
         Blocks.Add(Block);
     }
 }
Exemplo n.º 5
0
 public void BlockLanding(List <TBlock> Blocks)
 {
     for (int Loop = 0; Loop < Blocks.Count; Loop++)
     {
         TBlock Block = Blocks[Loop];
         if (Block.Y <= 100)
         {
             //SwinGame.ClearScreen(Color.White);
             _GameEnd = true;
         }
         Cells [Block.X, Block.Y] = Block;
     }
 }
        public void MoveDown()
        {
            do_CopyBlocks();

            for (int i = 0; i < Blocks.Count; i++)
            {
                TBlock Block = Blocks[i];
                Block.Y = Block.Y + 25;
                //To prevent shape to be out of down side board.
                if (Block.Y >= 600)
                {
                    return;
                }
            }

            do_CopyToBlockSrc();
        }
        public void MoveRight()
        {
            do_CopyBlocks();

            for (int i = 0; i < Blocks.Count; i++)
            {
                TBlock Block = Blocks[i];
                Block.X = Block.X + 25;
                //To prevent shape to be out of right side board.
                if (Block.X >= 400)
                {
                    return;
                }
            }

            do_CopyToBlockSrc();
        }
Exemplo n.º 8
0
        public bool CheckLanding(List <TBlock> Blocks)
        {
            result = false;

            for (int Loop = 0; Loop < Blocks.Count; Loop++)
            {
                TBlock Block = Blocks[Loop];

                //To make able to stack shape on the drawn cells,
                //checking wheter that below cells is not null is requried

                if (Cells[Block.X, Block.Y + 25] != null)
                {
                    result = true;
                }
            }
            return(result);
        }
Exemplo n.º 9
0
        public void TestBlockErase()
        {
            TBoard        BoardCell   = new TBoard();
            List <TBlock> Blocks      = new List <TBlock> ();
            TBlockShapeA  BlockShapeA = new TBlockShapeA();

            //fill the shape on the ground with leaving two block space as a hole so that
            //when blockA landed(filled) on that hole, it clears the line

            for (int i = 0; i < 8; i++)
            {
                TBlock Block = new TBlock();
                BoardCell.BoardCells[i * 25, 550] = Block;
            }

            for (int i = 0; i < 6; i++)
            {
                int    a     = 250;
                TBlock Block = new TBlock();
                BoardCell.BoardCells[a + (i * 25), 550] = Block;
            }

            for (int row = 0; row < 22; row++)
            {
                BlockShapeA.MoveDown();
                if (BoardCell.CheckLanding(BlockShapeA.GetBlocks))
                {
                    BoardCell.BlockLanding(BlockShapeA.GetBlocks);
                    BoardCell.EraseFullLine();
                }
            }

            for (int i = 0; i < 8; i++)
            {
                Assert.IsTrue(BoardCell.BoardCells [i * 25, 550] == null);
            }

            for (int i = 0; i < 6; i++)
            {
                int a = 250;
                Assert.IsTrue(BoardCell.BoardCells [a + (i * 25), 550] == null);
            }
        }