forked from mahsu/MariOCaml
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathobject.mli
61 lines (48 loc) · 1.34 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
open Sprite
open Actors
type xy = {
mutable x: float;
mutable y: float;
}
type direction = | Up | Down | Right | Left
type aabb = {
center: xy;
half: xy;
}
type obj_params = {
has_gravity: bool;
max_speed: bool;
}
type obj = {
params: obj_params;
pos: xy;
speed: float;
vel: xy;
jumping: bool;
grounded: bool;
dir: direction;
invuln: int;
}
type collidable =
| Player of player_typ * 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
(* Destroys the object, returning a list of destruction effect objects *)
val kill : obj -> noncollidable list
(* Updates the velocity of the object *)
val update_vel : obj -> obj
(* Updates the position of the object *)
val update_pos : obj -> obj
(* Checks whether a collision occured between two objects, returning the
* direction of the collision if one occurred. *)
val check_collision : collidable -> collidable -> direction option