diff options
Diffstat (limited to 'judge/morpion_rec.ml')
-rw-r--r-- | judge/morpion_rec.ml | 18 |
1 files changed, 17 insertions, 1 deletions
diff --git a/judge/morpion_rec.ml b/judge/morpion_rec.ml index a46b7f9..49e6544 100644 --- a/judge/morpion_rec.ml +++ b/judge/morpion_rec.ml @@ -195,9 +195,13 @@ module G = struct List.iter (fun p -> sdf (margin (subpos box p) 6) (getp1 mor p)) all_p1; disp_l 2 box (reduct mor) - let display_game (s, mor, q) (pn1, pn2) = + let gbox () = let cx, cy = center() in let box = cx - 200, cy - 200, cx + 200, cy + 200 in + box + + let display_game (s, mor, q) (pn1, pn2) = + let box = gbox () in disp_r (disp_r (disp_l 1)) box mor; begin match q, s with | Some p, TurnOf player -> @@ -207,6 +211,18 @@ module G = struct | _ -> () end + let in_box (x1, y1, x2, y2) (x, y) = + (x >= x1 && x <= x2 && y >= y1 && y <= y2) + + let gui_act_at g xy = + let box = gbox () in + try + let pg = List.find (fun p -> in_box (subpos box p) xy) all_p1 in + let sbox = subpos box pg in + let pp = List.find (fun p -> in_box (subpos sbox p) xy) all_p1 in + encode (pg, pp) + with Not_found -> "" + end |