| 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; |