| 1 | ########################################################################## | ||
| 2 | package Games::PangZero::SlowEffect; | ||
| 3 | ########################################################################## | ||
| 4 | |||
| 5 | @ISA = qw(Games::PangZero::GameObject); | ||
| 6 | use strict; | ||
| 7 | use warnings; | ||
| 8 | |||
| 9 | sub new { | ||
| 10 | my ($class) = @_; | ||
| 11 | my $self = Games::PangZero::GameObject->new(); | ||
| 12 | %{$self} = ( %{$self}, | ||
| 13 | 'timeout' => 1500, # Lasts for 15s | ||
| 14 | ); | ||
| 15 | # TODO Play a sound here | ||
| 16 | bless $self, $class; | ||
| 17 | return $self; | ||
| 18 | } | ||
| 19 | |||
| 20 | sub RemoveSlowEffects { | ||
| 21 | @Games::PangZero::GameObjects = grep { ref $_ ne 'Games::PangZero::SlowEffect' } @Games::PangZero::GameObjects; | ||
| 22 | } | ||
| 23 | |||
| 24 | sub Advance { | ||
| 25 | my ($self) = @_; | ||
| 26 | my ($timeout, $slowratio); | ||
| 27 | |||
| 28 | $timeout = --$self->{timeout}; | ||
| 29 | if ( $timeout == 256 ) { | ||
| 30 | # TODO Play a sound here | ||
| 31 | } | ||
| 32 | if ( $timeout > 256 ) { | ||
| 33 | $Games::PangZero::GameSpeed = 0.2; | ||
| 34 | } elsif ( $timeout > 0 ) { | ||
| 35 | $Games::PangZero::Game->SetGameSpeed(); | ||
| 36 | $slowratio = int(256 - $timeout) / 256; | ||
| 37 | $Games::PangZero::GameSpeed = $Games::PangZero::GameSpeed * $slowratio + 0.2 * (1.0 - $slowratio); | ||
| 38 | } else { | ||
| 39 | $Games::PangZero::Game->SetGameSpeed(); | ||
| 40 | $self->Delete(); | ||
| 41 | return; | ||
| 42 | } | ||
| 43 | } | ||
| 44 | |||
| 45 | sub Draw { | ||
| 46 | } | ||
| 47 | |||
| 48 | sub Clear { | ||
| 49 | } | ||
| 50 | |||
| 51 | 1; |