| 1 | ########################################################################## | ||
| 2 | package Games::PangZero::Meltdown; | ||
| 3 | ########################################################################## | ||
| 4 | |||
| 5 | @ISA = qw(Games::PangZero::GameObject); | ||
| 6 | use strict; | ||
| 7 | use warnings; | ||
| 8 | |||
| 9 | sub new { | ||
| 10 | my ($class) = @_; | ||
| 11 | my ($self, $surface); | ||
| 12 | |||
| 13 | $self = Games::PangZero::GameObject->new(); | ||
| 14 | $surface = SDL::Image::load( "$Games::PangZero::DataDir/meltdown.png" ); | ||
| 15 | %{$self} = ( %{$self}, | ||
| 16 | 'x' => ($Games::PangZero::ScreenWidth - $surface->w) / 2, | ||
| 17 | 'y' => -$surface->h, | ||
| 18 | 'w' => $surface->w, | ||
| 19 | 'h' => $surface->h, | ||
| 20 | 'speedY' => 0, | ||
| 21 | 'surface' => $surface, | ||
| 22 | 'bounce' => 0, | ||
| 23 | ); | ||
| 24 | bless $self, $class; | ||
| 25 | } | ||
| 26 | |||
| 27 | sub Advance { | ||
| 28 | my $self = shift; | ||
| 29 | $self->{speedY} += 0.1; | ||
| 30 | $self->{y} += $self->{speedY}; | ||
| 31 | |||
| 32 | if ($self->{bounce} == 0 and $self->{y} > $Games::PangZero::ScreenHeight - $self->{h}) { | ||
| 33 | $self->{bounce} = 1; | ||
| 34 | $self->{speedY} = -5; | ||
| 35 | $self->{y} = $Games::PangZero::ScreenHeight - $self->{h}; | ||
| 36 | } | ||
| 37 | |||
| 38 | if ($self->{bounce} and $self->{y} > $Games::PangZero::PhysicalScreenHeight) { | ||
| 39 | $self->Delete; | ||
| 40 | } | ||
| 41 | } | ||
| 42 | |||
| 43 | sub Draw { | ||
| 44 | my $self = shift; | ||
| 45 | |||
| 46 | $self->TransferRect(); | ||
| 47 | SDL::Video::blit_surface($self->{surface}, SDL::Rect->new(0, 0, $self->{surface}->w, $self->{surface}->h), $Games::PangZero::App, $self->{rect} ); | ||
| 48 | } | ||
| 49 | |||
| 50 | 1; |