lib/Game/HeroesVsAliens/Projectile.pm

filter: Statementstmt 40.0% 14 / 35 Branchbran 0.0% 0 / 6 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 10.0% 1 / 10 Podpod 0.0% 0 / 2 totaltotal 28.3% 15 / 53 CC 4 SCAR 20.1
CC
4
Cov
34%
draw
20.0
__ANON__
2.0
__ANON__
2.0
CRAP 7.5
« lib/Game/HeroesVsAliens/Cell.pm ↑ Summary lib/Game/HeroesVsAliens.pl »
1 package Game::HeroesVsAliens::Projectile;
2  
3 1 ▶use Moo;
Subroutine BEGIN: called CC=1 SCAR=0.0
4  
5 1 with 'Game::HeroesVsAliens::Role::ResourceDirectory';
6  
7 1 has x => (
8 is => 'rw'
9 );
10  
11 1 has y => (
12 is => 'rw'
13 );
14  
15 has width => (
16 is => 'rw',
17 0 ▶ default => sub { 32 }
Subroutine __ANON__: not called CC=1 SCAR=6.9
18 1 );
19  
20 has height => (
21 is => 'rw',
22 0 ▶ default => sub { 32 }
Subroutine __ANON__: not called CC=1 SCAR=6.9
23 1 );
24  
25 has power => (
26 is => 'rw',
27 0 ▶ default => sub { 20 }
Subroutine __ANON__: not called CC=1 SCAR=6.9
28 1 );
29  
30 has speed => (
31 is => 'rw',
32 0 ▶ default => sub { 5 }
Subroutine __ANON__: not called CC=1 SCAR=6.9
33 1 );
34  
35 has sprite => (
36 is => 'rw',
37 default => sub {
38 0 ▶ my $sprite = SDLx::Sprite::Animated->new(
Subroutine __ANON__: not called CC=1 SCAR=6.9
39 image => $_[0]->resource_directory . 'resources/boy-hero-projectile.png',
40 width => 32,
41 height => 32,
42 );
43 }
44 1 );
45  
46 has explode_sprite => (
47 is => 'rw',
48 default => sub {
49 0 ▶ my $sprite = SDLx::Sprite::Animated->new(
Subroutine __ANON__: not called CC=1 SCAR=6.9
50 image => $_[0]->resource_directory . 'resources/boy-hero-explode-projectile.png',
51 width => 32,
52 height => 32,
53 );
54 }
55 1 );
56  
57 has collision => (
58 is => 'rw',
59 0 ▶ default => sub { 0 }
Subroutine __ANON__: not called CC=1 SCAR=6.9
60 1 );
61  
62 sub draw {
63 0 ▶ my ($self, $app) = @_;
Subroutine draw: not called CC=4 SCAR=30.0
Pod undocumented
64  
65 0 ▶ if ($self->collision) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->collision) { } 0 0 0
66 0 $self->explode_sprite->rect->x($self->x);
67 0 $self->explode_sprite->rect->y($self->y);
68 0 ▶ if ($app->frame % 3 == 0) {
Branch: 1 branch
BranchTrueFalseTotal
if ($app->frame % 3 == 0) 0 0 0
69 0 $self->explode_sprite->next;
70 }
71 0 $self->explode_sprite->draw($app->ctx);
72 } else {
73 0 $self->sprite->rect->x($self->x);
74 0 $self->sprite->rect->y($self->y);
75 0 ▶ if ($app->frame % 3 == 0) {
Branch: 1 branch
BranchTrueFalseTotal
if ($app->frame % 3 == 0) 0 0 0
76 0 $self->sprite->next;
77 }
78 0 $self->sprite->draw($app->ctx);
79 }
80 # $app->draw_circle($self->x, $self->y, $self->width, $self->height, [200, 100, 200, 255]);
81 }
82  
83 sub update {
84 0 ▶ my ($self, $app) = @_;
Subroutine update: not called CC=1 SCAR=6.9
Pod undocumented
85 0 $self->x($self->x + $self->speed);
86 }
87  
88  
89 1 1;
« lib/Game/HeroesVsAliens/Cell.pm ↑ Summary lib/Game/HeroesVsAliens.pl »