| 1 | ########################################################################## | ||
| 2 | package Games::PangZero::Hexa; | ||
| 3 | ########################################################################## | ||
| 4 | |||
| 5 | @ISA = qw(Games::PangZero::Ball); | ||
| 6 | |||
| 7 | sub new { | ||
| 8 | my $class = shift; | ||
| 9 | my $self = Games::PangZero::Ball->new(@_); | ||
| 10 | $self->{speedX} = ($Games::PangZero::Game->Rand(1.25) + 1.25) * ($self->{speedX} > 0 ? 1 : -1); | ||
| 11 | $self->{speedY} = -4 + abs($self->{speedX}); | ||
| 12 | |||
| 13 | bless $self, $class; | ||
| 14 | } | ||
| 15 | |||
| 16 | sub Draw { | ||
| 17 | my $self = shift; | ||
| 18 | my ($rect, $srcx, $phase); | ||
| 19 | |||
| 20 | return if $Games::PangZero::GamePause > 0 and $Games::PangZero::GamePause < 100 and (int($Games::PangZero::GamePause / 3) % 4) < 2; | ||
| 21 | |||
| 22 | $self->TransferRect(); | ||
| 23 | if ($self->{ismagic} and int($Games::PangZero::Game->{anim} / 3) % 3 == 0) { | ||
| 24 | SDL::Video::blit_surface($self->{surface}, $self->{desc}->{magicrect}, $Games::PangZero::App, $self->{rect}); | ||
| 25 | } else { | ||
| 26 | $rect = $self->{desc}->{rect}; | ||
| 27 | $phase = int($Games::PangZero::Game->{anim} / 5) % 3; | ||
| 28 | $phase = 2 - $phase if $self->{speedX} < 0; | ||
| 29 | $srcx = $phase * $self->{w}; | ||
| 30 | $rect->x( $rect->x + $srcx ); | ||
| 31 | SDL::Video::blit_surface($self->{surface}, $rect, $Games::PangZero::App, $self->{rect} ); | ||
| 32 | $rect->x( $rect->x - $srcx ); | ||
| 33 | } | ||
| 34 | } | ||
| 35 | |||
| 36 | sub AdjustChildren { | ||
| 37 | my ($self, $child1, $child2) = @_; | ||
| 38 | if ($self->{hasmagic}) { | ||
| 39 | $child2->GiveMagic(); | ||
| 40 | } | ||
| 41 | } | ||
| 42 | |||
| 43 | 1; |