added accuracy to display

This commit is contained in:
Alexandre 2024-12-25 20:53:30 +01:00
parent 110c20764b
commit 5483b1e6a4
23 changed files with 16 additions and 8 deletions

BIN
csts.cmi

Binary file not shown.

BIN
csts.cmx

Binary file not shown.

View File

@ -47,5 +47,6 @@ and minus_ch = ref 8
and prod_ch = ref 2 ;; and prod_ch = ref 2 ;;
let ans = ref 0 ;; let ans = ref 0 ;;
let n_ans = ref 0 ;;
let max_score = ref 1000 ;; let max_score = ref 1000 ;;

BIN
csts.o

Binary file not shown.

Binary file not shown.

Binary file not shown.

BIN
drawing.o

Binary file not shown.

Binary file not shown.

BIN
dynamic.o

Binary file not shown.

BIN
maeth.cmi

Binary file not shown.

BIN
maeth.cmx

Binary file not shown.

View File

@ -247,6 +247,7 @@ let maeth_main () =
cur := Unix.gettimeofday () ; cur := Unix.gettimeofday () ;
done ; done ;
Csts.ans := 0 ; Csts.ans := 0 ;
incr Csts.n_ans ;
if (!cur -. !Csts.start_0) > !Csts.total_time_f then if (!cur -. !Csts.start_0) > !Csts.total_time_f then
true true
else if !found then begin else if !found then begin
@ -276,24 +277,29 @@ let result_screen () =
Drawing.draw_string_centered (Csts.__width__/2) (Csts.__height__ - 60) "Press space to return to main" 22 ; Drawing.draw_string_centered (Csts.__width__/2) (Csts.__height__ - 60) "Press space to return to main" 22 ;
set_color (rgb 192 192 0) ; set_color (rgb 192 192 0) ;
Drawing.draw_string (Csts.__width__/6) (Csts.__height__/2 + 70) "Score" 20 ; Drawing.draw_string (Csts.__width__/6) (Csts.__height__/2 + 140) "Score" 20 ;
set_color (rgb 255 255 0) ; set_color (rgb 255 255 0) ;
Drawing.draw_integer_alignedleft (Csts.__width__/6+20*(5+1)*10/7) (Csts.__height__/2 + 70) !Csts.score 20 ; Drawing.draw_integer_alignedleft (Csts.__width__/6+20*(5+1)*10/7) (Csts.__height__/2 + 140) !Csts.score 20 ;
set_color (rgb 0 192 0) ; set_color (rgb 0 192 0) ;
Drawing.draw_string (Csts.__width__/6) (Csts.__height__/2) "Max Combo" 20 ; Drawing.draw_string (Csts.__width__/6) (Csts.__height__/2 + 70) "Max Combo" 20 ;
set_color (rgb 0 255 0) ; set_color (rgb 0 255 0) ;
Drawing.draw_integer_alignedleft (Csts.__width__/6+20*(9+1)*10/7) (Csts.__height__/2) !Csts.max_combo 20 ; Drawing.draw_integer_alignedleft (Csts.__width__/6+20*(9+1)*10/7) (Csts.__height__/2 + 70) !Csts.max_combo 20 ;
set_color (rgb 0 192 32) ; set_color (rgb 0 192 32) ;
Drawing.draw_string (Csts.__width__/6) (Csts.__height__/2 - 70) "Combo" 20 ; Drawing.draw_string (Csts.__width__/6) (Csts.__height__/2) "Combo" 20 ;
set_color (rgb 0 255 32) ; set_color (rgb 0 255 32) ;
Drawing.draw_integer_alignedleft (Csts.__width__/6+20*(5+1)*10/7) (Csts.__height__/2 - 70) !Csts.combo 20 ; Drawing.draw_integer_alignedleft (Csts.__width__/6+20*(5+1)*10/7) (Csts.__height__/2) !Csts.combo 20 ;
set_color (rgb 192 0 0) ; set_color (rgb 192 0 0) ;
Drawing.draw_string (Csts.__width__/6) (Csts.__height__/2 - 140) "Misses" 20 ; Drawing.draw_string (Csts.__width__/6) (Csts.__height__/2 - 70) "Misses" 20 ;
set_color (rgb 255 0 0) ; set_color (rgb 255 0 0) ;
Drawing.draw_integer_alignedleft (Csts.__width__/6+20*(6+1)*10/7) (Csts.__height__/2 - 140) !Csts.misses 20 ; Drawing.draw_integer_alignedleft (Csts.__width__/6+20*(6+1)*10/7) (Csts.__height__/2 - 70) !Csts.misses 20 ;
set_color (rgb 0 0 192) ;
Drawing.draw_string (Csts.__width__/6) (Csts.__height__/2 - 140) "Accuracy" 20 ;
set_color (rgb 0 0 192) ;
Drawing.draw_integer_alignedleft (Csts.__width__/6+20*(8+1)*10/7) (Csts.__height__/2 - 140) (int_of_float (1000. *. (float_of_int (!Csts.n_ans - !Csts.misses)) /. (float_of_int !Csts.n_ans))) 20 ;
if !Csts.misses = 0 then begin if !Csts.misses = 0 then begin
set_color (rgb 0 255 0) ; set_color (rgb 0 255 0) ;

BIN
maeth.o

Binary file not shown.

BIN
main.cmi

Binary file not shown.

BIN
main.cmx

Binary file not shown.

View File

@ -19,6 +19,7 @@ let rec mainloop () =
Csts.time_to_ans_f := float_of_int (!Csts.time_to_ans) ; Csts.time_to_ans_f := float_of_int (!Csts.time_to_ans) ;
Csts.total_time_f := float_of_int (!Csts.total_time) ; Csts.total_time_f := float_of_int (!Csts.total_time) ;
Csts.start_0 := Unix.gettimeofday () ; Csts.start_0 := Unix.gettimeofday () ;
Csts.n_ans := 0 ;
Csts.max_score := Csts.max_score :=
100 100
* !Csts.difficulty * !Csts.difficulty

BIN
main.o

Binary file not shown.

BIN
math

Binary file not shown.

BIN
math.cmx

Binary file not shown.

BIN
math.o

Binary file not shown.

BIN
menus.cmi

Binary file not shown.

BIN
menus.cmx

Binary file not shown.

BIN
menus.o

Binary file not shown.