private void Start_Again() { ball_real_cord_y = 0; // lets try this RandomXLocation location = new RandomXLocation(); //new thread ball_real_cord_x = location.get_ball_x_start_coord(); ball_int_y_cord = (int)(ball_real_cord_y); ////////// this back to 0 ball_int_x_cord = (int)(ball_real_cord_x); ball_refresh_clock.Enabled = false; // ball direction logic Logic algorithm = new Logic(); ball_radians = algorithm.get_direction_for_ball(); ball_horizontal_delta = distance_move_per_refresh * Math.Cos(ball_radians); ball_vertical_delta = distance_move_per_refresh * Math.Sin(ball_radians); // end of lets try this distance_move_per_refresh += .25; ball_clock_active = false; graphical_area_refresh_clock.Close(); ball_refresh_clock.Close(); //CreateGraphics().Clear(ActiveForm.BackColor); UpdateFrom(); ball_clock_active = true; ball_refresh_clock.Enabled = true; graphical_area_refresh_clock.Enabled = true; Start_a_clock(ball_update_rate); Start_graphic_clock(graphicalarearefresh); }
public const double ball_update_rate = 60; //TRIAL AND ERROR public ObjectFrame() { //ball_refresh_clock.Close(); //graphical_area_refresh_clock.Dispose(); //This is not how you should do it...// but oh well!!! formwidth = res.sizeOfScreen().Width; formheight = res.sizeOfScreen().Height; InitializeComponent(); //this.BackColor = Color.AliceBlue; //Return a random location for the x axis of the ball RandomXLocation location = new RandomXLocation(); ball_real_cord_x = location.get_ball_x_start_coord(); ball_int_y_cord = (int)(ball_real_cord_y); ball_int_x_cord = (int)(ball_real_cord_x); ball_refresh_clock.Enabled = false; // ball direction logic Logic algorithm = new Logic(); ball_radians = algorithm.get_direction_for_ball(); ball_horizontal_delta = distance_move_per_refresh * Math.Cos(ball_radians); ball_vertical_delta = distance_move_per_refresh * Math.Sin(ball_radians); // graphical refresh setting graphical_area_refresh_clock.Enabled = false; //Threads // event handlers graphical_area_refresh_clock.Elapsed += Graphical_area_refresh_clock_Elapsed; ball_refresh_clock.Elapsed += Ball_control_clock_Elapsed; KeyDown += ObjectFrame_KeyDown1; // functions //Start_a_clock(ball_update_rate); //Start_graphic_clock(graphicalarearefresh); }