Example #1
0
        //Fonction Freeze : Cette méthode va s'occuper de geler les 4 petits blocs du tetromino
        //lorsqu'il ne pourra plus descendre.

        // ppoulin
        // Paramètre incorrectement documenté
        // MCP-1
        //Paramètres rentrés : - Aucun
        //Visibilité : publique
        //
        //Aucune valeur de retour.
        public void Freeze(TetrisGame game)
        {
            game.FreezeContent(b1.GetParentRowOffset() + topLeftRowOffset, b1.GetParentColumnOffset() + topLeftColumnOffset);
            game.FreezeContent(b2.GetParentRowOffset() + topLeftRowOffset, b2.GetParentColumnOffset() + topLeftColumnOffset);
            game.FreezeContent(b3.GetParentRowOffset() + topLeftRowOffset, b3.GetParentColumnOffset() + topLeftColumnOffset);
            game.FreezeContent(b4.GetParentRowOffset() + topLeftRowOffset, b4.GetParentColumnOffset() + topLeftColumnOffset);
        }
Example #2
0
        public void TestFreezeContent01()
        {
            Tetromino  block = new Tetromino(7, TetrisGame.NB_ROWS - 1, TetrominoType.Square);
            TetrisGame game  = new TetrisGame();

            bool[,] logicalGameBoard = game.GetLogicalGameBoard();

            game.FreezeContent(TetrisGame.NB_ROWS - 1, 7);
            Assert.IsFalse(logicalGameBoard[TetrisGame.NB_ROWS - 1, 7]);
        }
 public Application(string windowTitle, int width, int height)
 {
     #region Code nécessaire pour connecter les événements avec les fonctions
     window                      = new RenderWindow(new SFML.Window.VideoMode((uint)width, (uint)height), windowTitle);
     window.Closed              += new EventHandler(OnClose);
     window.KeyPressed          += new EventHandler <KeyEventArgs>(OnKeyPressed);
     window.MouseButtonPressed  += new EventHandler <MouseButtonEventArgs>(OnMousePressed);
     window.MouseButtonReleased += new EventHandler <MouseButtonEventArgs>(OnMouseReleased);
     window.MouseMoved          += new EventHandler <MouseMoveEventArgs>(OnMouseMoved);
     window.SetFramerateLimit(30);
     #endregion
     game = new TetrisGame( );
 }
Example #4
0
        public void TestFreezeContent02()
        {
            // ppoulin
            // Test redondant avec le précédent.
            // Je ne comprends pas la situation que tu as voulu tester

            Tetromino  block = new Tetromino(9, 18, TetrominoType.Square);
            TetrisGame game  = new TetrisGame();

            bool[,] logicalGameBoard = game.GetLogicalGameBoard();
            game.FreezeContent(19, 9);
            Assert.IsFalse(logicalGameBoard[19, 9]);
        }
Example #5
0
        public void TestTetrisGameCtor()
        {
            TetrisGame game = new TetrisGame();

            bool[,] logicalGameBoard = game.GetLogicalGameBoard();

            for (int i = 0; i < logicalGameBoard.GetLength(0); i++)
            {
                for (int j = 0; j < logicalGameBoard.GetLength(1); j++)
                {
                    Assert.IsTrue(logicalGameBoard[i, j] == true);
                }
            }
        }
Example #6
0
        // ppoulin
        // Faute de français
        //Fonction CanMoveRight : Cette méthode vérifie si le tetromino peux encore descendre en bouger vers la droite,
        //                        en prenant compte de ses petits blocs.
        //Paramètres rentrés : - TetrisGame game : La partie de tetris qui est en cours.
        //Visibilité : publique
        //
        //Aucune valeur de retour.
        public bool CanMoveRight(TetrisGame game)
        {
            int potentialNextRow    = topLeftRowOffset + b1.GetParentRowOffset();
            int potentialNextColumn = topLeftColumnOffset + b1.GetParentColumnOffset() + 2;

            bool[,] logicalGameBoard = game.GetLogicalGameBoard();

            if ((potentialNextColumn < TetrisGame.NB_COLUMNS) && (topLeftColumnOffset < TetrisGame.NB_COLUMNS))
            {
                if (logicalGameBoard[potentialNextRow, potentialNextColumn] == true)
                {
                    return(true);
                }
                else
                {
                    return(false);
                }
            }
            return(false);
        }
Example #7
0
        public void TestIsRowCompleted()
        {
            TetrisGame game = new TetrisGame();

            bool[,] logicalGameBoard = game.GetLogicalGameBoard();
            //Blocs de test générés. À décommenter s'il y a lieu.
            int j = 2;

            for (j = 2; j < logicalGameBoard.GetLength(1); j++)
            {
                logicalGameBoard[TetrisGame.NB_ROWS - 1, j] = false;
                logicalGameBoard[TetrisGame.NB_ROWS - 2, j] = false;
            }
            Tetromino block = new Tetromino(0, TetrisGame.NB_ROWS - 2, TetrominoType.Square);

            for (int k = 0; k < logicalGameBoard.GetLength(1) - 1; k++)
            {
                Assert.IsFalse(logicalGameBoard[TetrisGame.NB_ROWS - 1, k]);
                Assert.IsFalse(logicalGameBoard[TetrisGame.NB_ROWS - 2, k]);
            }
            // ppoulin
            // Ce test ne teste pas la méthode IsRowCompleted
        }
Example #8
0
        // ppoulin
        // Faute de français
        //Fonction CanMoveDown : Cette méthode vérifie si le tetromino peux encore descendre en bas,
        //                       en prenant compte de ses petits blocs.
        //Paramètres rentrés : - TetrisGame game : La partie de tetris qui est en cours.
        //Visibilité : publique
        //
        //Aucune valeur de retour.
        public bool CanMoveDown(TetrisGame game)                                          //Conçu en colaborationa avec Thomas Gauthier-Cossette
        {
            int potentialNextRowB1    = topLeftRowOffset + b1.GetParentRowOffset() + 2;   //L'éventuelle rangée que le bloc pourrait atteindre.
            int potentialNextColumnB1 = topLeftColumnOffset + b1.GetParentColumnOffset(); //L'éventuelle colonne que le bloc pourrait atteindre.

            int potentialNextRowB3    = topLeftRowOffset + b3.GetParentRowOffset() + 2;
            int potentialNextColumnB3 = topLeftColumnOffset + b3.GetParentColumnOffset();

            bool[,] logicalGameBoard = game.GetLogicalGameBoard();                                                                                                  //Le tableau logique de la partie.

            if (potentialNextRowB1 < TetrisGame.NB_ROWS && topLeftRowOffset < TetrisGame.NB_ROWS)                                                                   //On s'assure de ne pas dépasser la limite inférieur de l'écran.
            {
                if ((logicalGameBoard[potentialNextRowB1, potentialNextColumnB1] == true) && (logicalGameBoard[potentialNextRowB3, potentialNextColumnB3] == true)) //On s'assure qu'il n'y a pas de bloc gelé en dessous.
                {
                    return(true);
                }
                else
                {
                    return(false);
                }
            }

            return(false);
        }