Esempio n. 1
0
        public void Move_block_left() // Moving block left
        {
            try
            {
                for (int l = 0; l < block.Left_sensor_left().Length; l++)
                {
                    if (matrix_crate[block.Left_sensor_left()[l], block.Left_sensor_left()[l + 1]].Get_colour_name() != bgColour) // Checking if a block won't hit another block
                    {
                        move_left = false;
                    }
                    l++;
                }

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

                    block.Block_coordinates_left(); // Moving left the coordinates of falling block

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

            catch (System.IndexOutOfRangeException)
            {
            }
        }