line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Games::2048::Animation; |
2
|
4
|
|
|
4
|
|
116
|
use 5.012; |
|
4
|
|
|
|
|
15
|
|
|
4
|
|
|
|
|
198
|
|
3
|
4
|
|
|
4
|
|
23
|
use Moo; |
|
4
|
|
|
|
|
6
|
|
|
4
|
|
|
|
|
34
|
|
4
|
|
|
|
|
|
|
|
5
|
4
|
|
|
4
|
|
6578
|
use POSIX qw/floor ceil/; |
|
4
|
|
|
|
|
56884
|
|
|
4
|
|
|
|
|
31
|
|
6
|
4
|
|
|
4
|
|
7064
|
use Carp qw/croak/; |
|
4
|
|
|
|
|
10
|
|
|
4
|
|
|
|
|
1211
|
|
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
has cur_frame => is => 'rw', default => 0; |
9
|
|
|
|
|
|
|
has duration => is => 'rw', default => 0; |
10
|
|
|
|
|
|
|
has first_value => is => 'rw', default => 0; |
11
|
|
|
|
|
|
|
has last_value => is => 'rw', default => 1; |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
sub value { |
14
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
15
|
0
|
|
|
|
|
|
my $value = $self->cur_frame / ($self->frame_count - 1); |
16
|
0
|
|
|
|
|
|
my $range = $self->last_value - $self->first_value; |
17
|
0
|
|
|
|
|
|
return $value * $range + $self->first_value; |
18
|
|
|
|
|
|
|
} |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
sub update { |
21
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
22
|
0
|
0
|
|
|
|
|
return if $self->cur_frame >= $self->frame_count; |
23
|
0
|
|
|
|
|
|
$self->cur_frame($self->cur_frame + 1); |
24
|
0
|
|
|
|
|
|
return 1; |
25
|
|
|
|
|
|
|
} |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
sub frame_count { |
28
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
29
|
0
|
|
|
|
|
|
return floor($self->duration / Games::2048::FRAME_TIME); |
30
|
|
|
|
|
|
|
} |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
1; |