Exemplo n.º 1
0
        public void Move_block_down() // Moving block down
        {
            try
            {
                for (int l = 0; l < block.Bottom_sensor_down().Length; l++)
                {
                    if (matrix_crate[block.Bottom_sensor_down()[l], block.Bottom_sensor_down()[l + 1]].Get_colour_name() != bgColour) // Checking if a block won't hit another block
                    {
                        stop_moving_down = true;
                    }
                    l++;
                }

                if (!stop_moving_down)                                          // Moving block down
                {
                    for (int i = 0; i < block.Return_coordinates().Length; i++) // Blanking the old positon block
                    {
                        matrix_crate[block.Return_coordinates()[i], block.Return_coordinates()[i + 1]].Change_colour(bgColour);
                        i++;
                    }

                    block.Block_coordinates_down();                             // Moving down the coordinates of falling block

                    for (int i = 0; i < block.Return_coordinates().Length; i++) // Displaying the new position block
                    {
                        matrix_crate[block.Return_coordinates()[i], block.Return_coordinates()[i + 1]].Change_colour(colour);
                        i++;
                    }
                }

                else
                {
                    Check_if_line();          // Checking if there is a colored line
                    stop_moving_down = false; // Letting a new block to fall further
                    Draw_block();             // Drawing a block
                }
            }

            catch (System.IndexOutOfRangeException) // Checking if our block won't fall out of the grid
            {
                Check_if_line();                    // Checking if there is a colored line
                Draw_block();                       // Drawing a block
            }
        }