-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathanimation.ml
More file actions
41 lines (31 loc) · 937 Bytes
/
animation.ml
File metadata and controls
41 lines (31 loc) · 937 Bytes
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
open ANSITerminal
type animation = Nothing
| LineClear of Board.line_clear
type t = {
active_animation : animation;
elapsed : float;
duration : float;
}
let init () = {
active_animation = Nothing;
elapsed = 0.;
duration = 0.;
}
let active_animation animation = animation.active_animation
let elapsed animation = animation.elapsed
let duration animation = animation.duration
let pct_complete animation = animation.elapsed /. animation.duration
let reset_elapsed animation =
{ animation with elapsed = 0. }
let tick_elapsed animation dt =
{ animation with elapsed = animation.elapsed +. dt }
let animation_over animation =
animation.elapsed >= animation.duration
let reset_animation animation =
init ()
let do_line_clear_animation animation (line_clear : Board.line_clear) duration =
{
animation with
active_animation = LineClear line_clear;
duration;
} |> reset_elapsed