Beispiel #1
0
        public static void Main2(string[] args)
        {
            Console.SetWindowSize(12,22);
            TetrisBoard board = new TetrisBoard(10,20);
            board.SetBlock(0,0,new int[,]{
                      	{1,1,1,1},
                      	{0,0,0,1},
                      });
            do {
                for (int x = 0; x < board.Width; x++) {
                    for (int y = 0; y < board.Height; y++) {
                        if (board.HasTileAt(x, y)) {
                            Console.SetCursorPosition(y, x);
                            Console.Write('#');
                        }
                    }
                }
                //ConsoleKeyInfo key = Console.ReadKey(true);

            } while(true);
        }
Beispiel #2
0
        public void TestSimpleGame()
        {
            TetrisBoard board = new TetrisBoard(10, 5);
            bool success = board.SetBlock(0, 0, new int[,]{
                      	{1,1,1},
                      	{1,1,1}
                      });
            Assert.IsTrue(success);

            while (board.MoveDown());

            board.MergeBlock();

            success = board.SetBlock(0, 0, new int[,]{
                      	{1,1},
                      	{1,1},
                      });
            Assert.IsTrue(success);

            while(board.MoveRight());
            while(board.MoveDown());

            Assert.True(board.HasTileAt(9,0));

            board.MergeBlock();
            int lines = board.RemoveLines();
            Assert.AreEqual(2, lines);

            Assert.False(board.HasTileAt(9,0));
        }