| 1 | package Games::2048::Animation; | ||||||||||
| 2 | 4 | ▶ | use 5.012; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 3 | 4 | ▶ | use Moo; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 4 | |||||||||||
| 5 | 4 | ▶ | use POSIX qw/floor ceil/; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 6 | 4 | ▶ | use Carp qw/croak/; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 7 | |||||||||||
| 8 | 4 | has cur_frame => is => 'rw', default => 0; | |||||||||
| 9 | 4 | has duration => is => 'rw', default => 0; | |||||||||
| 10 | 4 | has first_value => is => 'rw', default => 0; | |||||||||
| 11 | 4 | has last_value => is => 'rw', default => 1; | |||||||||
| 12 | |||||||||||
| 13 | sub value { | ||||||||||
| 14 | 0 | ▶ | my $self = shift; | ||||||||
|
Subroutine
value: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||
| 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 | ▶ | my $self = shift; | ||||||||
|
Subroutine
update: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||
| 22 | 0 | ▶ | return if $self->cur_frame >= $self->frame_count; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 23 | 0 | $self->cur_frame($self->cur_frame + 1); | |||||||||
| 24 | 0 | return 1; | |||||||||
| 25 | } | ||||||||||
| 26 | |||||||||||
| 27 | sub frame_count { | ||||||||||
| 28 | 0 | ▶ | my $self = shift; | ||||||||
|
Subroutine
frame_count: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||
| 29 | 0 | return floor($self->duration / Games::2048::FRAME_TIME); | |||||||||
| 30 | } | ||||||||||
| 31 | |||||||||||
| 32 | 4 | 1; | |||||||||