PangZero/FragileBall.pm untested

filter: Statementstmt 0.0% 0 / 30 Branchbran 0.0% 0 / 6 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 0.0% 0 / 4 Podpod 0.0% 0 / 2 totaltotal 0.0% 0 / 42 CC 4 SCAR 20.1
CC
4
Cov
0%
Bounce
12.0
SpawnChildren
6.0
BEGIN
2.0
CRAP 7.4
1 ##########################################################################
2 package Games::PangZero::FragileBall;
3 ##########################################################################
4  
5 @ISA = qw( Games::PangZero::Ball );
6 use strict;
7 use warnings;
8  
9 sub Bounce {
10 my $self = shift;
11 if ($self->{desc}->{nextgen}) {
12 $self->{bonus} = 0;
13 $self->Pop(undef, '');
14 }
15 $self->{speedX} = ($self->{speedX} > 0) ? 1.3 : -1.3;
16 }
17  
18 sub SpawnChildren {
19 my $self = shift;
20 my (@children, $child, $i);
21
22 my $nextgen = $self->{desc}->{nextgen};
23 die caller unless $nextgen->{class};
24 my $numchildren = 2;
25 while ($nextgen->{nextgen}) {
26 $nextgen = $nextgen->{nextgen};
27 $numchildren *= 2;
28 }
29
30 my $y = $self->{y} + ($self->{h} - $nextgen->{height}) / 2;
31 for ($i = 0; $i < $numchildren; ++$i) {
32 $child = Games::PangZero::Ball::Create($nextgen, $self->{x}, $y, 0);
33 $child->{speedX} = -1.5 + ($i / ($numchildren-1) * 3);
34 $child->{x} = $self->{x} + ($self->{w} - $child->{w}) * ($i / ($numchildren-1));
35 push @children, $child;
36 }
37
38 return @children;
39 }
40  
41 1;