Exemplo n.º 1
0
 public void Test_Move_Right()
 {
     int[] prevX = PreviousXpos();
     blockShape.MoveRight();
     for (int i = 0; i < 4; i++)
     {
         Assert.AreEqual(prevX[i] + 1, blockShape.ShapeBlocks[i].GridX);
     }
 }
Exemplo n.º 2
0
        /// <summary>
        /// Method <c>KeyDown_Event(object sender, KeyEventArgs e)</c>
        /// A method that represents the controls for tetris.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        public void KeyDown_Event(object sender, KeyEventArgs e)
        {
            if (e.Key == Key.Down)
            {
                _shape.MoveDown();
            }
            if (e.Key == Key.Left)
            {
                _shape.MoveLeft();
            }
            if (e.Key == Key.Right)
            {
                _shape.MoveRight();
            }
            if (e.Key == Key.Up)
            {
                _shape.Rotate(true);
            }
            if (e.Key == Key.Space)
            {
                _shape.DropShape();
            }
            if (e.Key == Key.I)
            {
                string gridString = "";
                for (int i = 0; i < GameBoard.Grid.GetLength(0); i++)
                {
                    for (int j = 0; j < GameBoard.Grid.GetLength(1); j++)
                    {
                        gridString += GameBoard.Grid[i, j] + " ";
                    }
                    gridString += Environment.NewLine;
                }

                MessageBox.Show(gridString.ToString());
            }
            if (e.Key == Key.R)
            {
                RestartGame();
            }
            if (e.Key == Key.P)
            {
                Pause();
            }
            if (e.Key == Key.H)
            {
                HoldBlock();
            }
        }