/usr/share/perl5/Games/PangZero/Harpoon.pm is in pangzero 1.4-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 | ##########################################################################
package Games::PangZero::Harpoon;
##########################################################################
@ISA = qw(Games::PangZero::GameObject);
use vars qw(%Harpoons $HarpoonId);
sub Create {
return Games::PangZero::Harpoon->new(@_);
}
sub new {
my ($class, $guy) = @_;
my ($self);
$self = Games::PangZero::GameObject->new();
%{$self} = ( %{$self},
'x' => $guy->{x} + 22,
'y' => $Games::PangZero::ScreenHeight - 32,
'w' => 18,
'h' => 32,
'speedY' => -3,
'speedX' => 0,
'guy' => $guy,
'surface' => $guy->{player}->{harpoonSurface},
'popEffect' => '',
'id' => ++$HarpoonId,
);
$Harpoons{$self->{id}} = $self;
bless $self, $class;
}
sub Delete {
my $self = shift;
delete $Harpoons{$self->{id}};
--$self->{guy}->{harpoons};
$self->SUPER::Delete();
}
sub Advance {
my $self = shift;
if ($self->{y} < 0) {
$self->Delete();
return;
}
$self->{y} += $self->{speedY};
$self->{h} = $Games::PangZero::ScreenHeight - $self->{y};
}
sub GetAnimPhase {
my $self = shift;
return (int($Games::PangZero::Game->{anim} / 4) % 3) + 1;
}
sub Draw {
my $self = shift;
my ($x, $y, $h, $maxh, $dstrect, $srcrect);
$self->TransferRect();
$y = $self->{y};
$dstrect = SDL::Rect->new( $self->{x} + $Games::PangZero::ScreenMargin, 0, $self->{w}, 0 );
$srcrect = SDL::Rect->new( (0, 64, 32, 96)[ $self->GetAnimPhase() ], 0, $self->{w}, 0 );
$maxh = 160;
# The harpoon needs to be drawn from tile pieces.
# $y iterates from $self->{y} to $Games::PangZero::ScreenHeight
# We draw at most $maxh height tiles at a time.
while ($y < $Games::PangZero::ScreenHeight) {
$h = $Games::PangZero::ScreenHeight - $y;
$h = $maxh if $h > $maxh;
$dstrect->y( $y + $Games::PangZero::ScreenMargin );
$dstrect->h( $h );
$srcrect->h( $h );
SDL::Video::blit_surface($self->{surface}, $srcrect, $Games::PangZero::App, $dstrect );
# Prepare for next piece
$y += $h;
$srcrect->y( 32 ); # First piece starts at 0, rest start at 32
$maxh = 128;
}
}
1;
|