open Graphics ;;
Random.self_init () ;;

let mainloop () =
  open_graph Csts.open_string ;
  set_window_title "Maeth";
  try
    while true do 
      auto_synchronize false ;
      clear_graph () ;
      Menus.print_current_interface () ;
      auto_synchronize true ;
      Menus.action_on_interface () ;
      Unix.sleepf Csts.sleep_d
    done ;
    ()
  with
    | Menus.MenuStart ->
      Csts.time_to_ans_f := float_of_int (!Csts.time_to_ans) ;
      clear_graph () ;
      Maeth.print_calc (Maeth.generate_random_calc 8 1 20) (10) (Csts.__height__/2) 20 ;
      while true do
        Unix.sleepf Csts.sleep_d
      done ;;


mainloop () ;;