forked from janestreet/learn-ocaml-workshop
-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathscaffold.mli
85 lines (69 loc) · 1.56 KB
/
scaffold.mli
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
(** The grid system:
0. The positions of all objects are snapped onto a coarse grid.
1. The frog is 1x1
2. Every car is 1x1
3. Every log is 1x1
*)
(** The playable area of the screen will be referred to as the [board]. *)
module Board : sig
(** Every row of the game board is one of these three kinds. *)
module Row : sig
type t =
| Safe_strip
| Road
| River
end
val num_cols : int
(** The first and last rows are guaranteed to be [Safe_strip]s. *)
val rows : Row.t list
end
(** This is a position in the grid system of the game, not in screen pixels. *)
module Position : sig
type t =
{ x : int
; y : int
} [@@deriving fields, sexp]
val create : x:int -> y:int -> t
end
(** All these images are 1x1. *)
module Image : sig
type t =
| Frog_up
| Frog_down
| Frog_left
| Frog_right
| Car1_left
| Car1_right
| Car2_left
| Car2_right
| Car3_left
| Car3_right
| Log1
| Log2
| Log3
| Confetti
| Skull_and_crossbones
[@@deriving sexp, variants]
end
module Display_list : sig
(** The [Display_command] [(image, pos)] represents a command to draw [image]
with its leftmost grid point at [pos].
*)
module Display_command : sig
type nonrec t = Image.t * Position.t [@@deriving sexp]
end
type t = Display_command.t list [@@deriving sexp]
end
module Key : sig
type t =
| Arrow_up
| Arrow_down
| Arrow_left
| Arrow_right
end
module Event : sig
type t =
| Tick
| Keypress of Key.t
end
val console_log : string -> unit