MathGame_V2/main.ml

45 lines
1.2 KiB
OCaml

open Graphics ;;
Random.self_init () ;;
let rec 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) ;
Csts.total_time_f := float_of_int (!Csts.total_time) ;
Csts.start_0 := Unix.gettimeofday () ;
Csts.n_ans := 0 ;
Csts.max_score :=
100
* !Csts.difficulty
* (Math.pw !Csts.calc_length 3)
* (90 / !Csts.time_to_ans) * int_of_float (Float.sqrt (float_of_int (90 / !Csts.time_to_ans))) ;
Maeth.init_odds () ;
clear_graph () ;
while Unix.gettimeofday () -. !Csts.start_0 <= !Csts.total_time_f do
ignore (Maeth.maeth_main ()) ;
done ;
Maeth.result_screen () ;
mainloop () ;;
(*
let difficulty = ref 1 ;;
let calc_length = ref 3 ;;
let time_to_ans = ref 10 ;;
let total_time = ref 60 ;;
let n_inf = ref 1 ;;
let n_sup = ref 10 ;;
*)
mainloop () ;;