forked from mahsu/MariOCaml
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathobject.mli
64 lines (49 loc) · 1.54 KB
/
object.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
open Sprite
open Actors
type xy = {
mutable x: float;
mutable y: float;
}
type aabb = {
center: xy;
half: xy;
}
type obj_params = {
has_gravity: bool;
speed: float;
}
type obj = {
params: obj_params;
pos: xy;
vel: xy;
id: int;
mutable jumping: bool;
mutable grounded: bool;
mutable dir: Actors.dir_1d;
mutable invuln: int;
mutable kill: bool;
}
type collidable =
| Player of sprite * obj
| Enemy of enemy_typ * sprite * obj
| Item of item_typ * sprite * obj
| Block of block_typ * sprite * obj
type noncollidable =
| Scenery of sprite * obj
(* Returns the sprite associated with the object *)
val get_sprite : collidable -> Sprite.sprite
val get_obj : collidable -> obj
(* Creates a new object with a given
* actor type on the the canvas at a given position *)
val spawn : Actors.spawn_typ -> Dom_html.canvasRenderingContext2D Js.t
-> float*float -> collidable
val equals : collidable -> collidable -> bool
val is_player : collidable -> bool
(* Destroys the object, returning a list of destruction effect objects *)
val kill : obj -> noncollidable list
val process_obj : collidable -> Dom_html.canvasRenderingContext2D Js.t -> unit
val update_player : obj -> Actors.controls list -> Dom_html.canvasRenderingContext2D Js.t -> sprite option
(* Checks whether a collision occured between two objects, returning the
* direction of the collision if one occurred. *)
val check_collision : collidable -> collidable -> Actors.dir_2d option
val process_collision : Actors.dir_2d -> collidable -> collidable -> unit