/usr/share/perl5/Games/PangZero/PanicGame.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 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 | ##########################################################################
package Games::PangZero::PanicGame;
##########################################################################
@ISA = qw(Games::PangZero::PlayableGameBase);
sub new {
my ($class) = @_;
my $self = Games::PangZero::PlayableGameBase->new();
%{$self} = (%{$self},
'spawndelay' => 0,
'superballdelay' => 0,
'leveladvance' => 0,
'panicleveldesc' => undef,
);
bless $self, $class;
}
sub ResetGame {
my $self = shift;
$self->SUPER::ResetGame();
$self->{spawndelay} = 0;
$self->{superballdelay} = 2500 + $self->Rand(2500); # 25sec - 50sec
$self->{superballdelay} *= $Games::PangZero::DifficultyLevel->{superball};
}
sub SetGameSpeed {
my ($self) = @_;
$Games::PangZero::GameSpeed = $self->{leveldesc}->{gamespeed} * 0.8 * $Games::PangZero::DifficultyLevel->{speed};
}
sub SetGameLevel {
my ($self, $level) = @_;
my ($levelIndex);
$levelIndex = ($level > $#Games::PangZero::PanicLevels) ? $#Games::PangZero::PanicLevels : $level;
$self->{leveldesc} = $Games::PangZero::PanicLevels[$levelIndex];
die unless $self->{leveldesc};
$self->{leveladvance} = 0;
$self->SUPER::SetGameLevel($level);
}
sub AdvanceGame {
my ($self) = @_;
$self->SpawnBalls() if $Games::PangZero::GamePause <= 0;
$self->SUPER::AdvanceGame();
}
sub SpawnBalls {
my $self = shift;
my ($randmax, $rnd, $ballName, $balldesc, $deathBallCount, $earthquakeBallCount, $hasBonus);
--$self->{superballdelay};
if ($self->{superballdelay} <= 0) {
push @Games::PangZero::GameObjects, (
Games::PangZero::Ball::Spawn($Games::PangZero::BallDesc{sprintf('super%d', $self->Rand(2))}, -1, $self->Rand(40) < 20 ? 0 : 1) );
$self->{superballdelay} = (2500 + $self->Rand(2000)) * $Games::PangZero::DifficultyLevel->{superball}; # 25sec - 45sec
}
--$self->{spawndelay};
return if $self->{spawndelay} > 0;
$deathBallCount = $earthquakeBallCount = -1;
$randmax = 10000;
while ($self->{spawndelay} <= 0) {
if ($Games::PangZero::DifficultyLevel->{name} eq 'Miki') {
$balldesc = $Games::PangZero::BallDesc{'death'};
last;
}
$rnd = int($self->Rand($randmax));
$randmax = 0;
# We try to find the balldesc that falls at $rnd
my $ballRoulette = $self->{leveldesc}->{balls};
for (my $i = 0; $i < scalar @{$ballRoulette}; $i+=2) {
my $rouletteWeight = $ballRoulette->[$i+1];
$randmax += $rouletteWeight;
$rnd -= $rouletteWeight;
if ($rnd < 0) {
$ballName = $ballRoulette->[$i];
last;
}
}
next unless ($ballName); # $rnd too large.. We'll have a better $randmax this time!
($balldesc) = $Games::PangZero::BallDesc{$ballName};
if ($balldesc->{class} eq 'DeathBall') {
next unless $Games::PangZero::DeathBallsEnabled;
$deathBallCount = Games::PangZero::DeathBall::CountDeathBalls() if $deathBallCount < 0; # Lazy counting
next if $deathBallCount >= 2;
}
if ($balldesc->{class} eq 'EarthquakeBall') {
next unless $Games::PangZero::EarthquakeBallsEnabled;
$earthquakeBallCount = Games::PangZero::EarthquakeBall::CountEarthquakeBalls if $earthquakeBallCount < 0;
next if $earthquakeBallCount >= 1;
}
if ($balldesc->{class} eq 'WaterBall') {
next unless $Games::PangZero::WaterBallsEnabled;
}
if ($balldesc->{class} eq 'SeekerBall') {
next unless $Games::PangZero::SeekerBallsEnabled;
}
last if $balldesc;
}
$hasBonus = 1 if ($balldesc->{width} >= 32) and ($self->Rand(1) < $Games::PangZero::DifficultyLevel->{bonusprobability});
push @Games::PangZero::GameObjects, ( Games::PangZero::Ball::Spawn($balldesc, -1, $self->Rand(40) < 20 ? 0 : 1, $hasBonus) );
$self->{spawndelay} = $self->{leveldesc}->{spawndelay} * $balldesc->{spawndelay} * 50;
$self->{spawndelay} /= ($Games::PangZero::NumGuys + 1) / 2;
$self->{spawndelay} *= $Games::PangZero::DifficultyLevel->{spawnmultiplier};
}
sub OnBallPopped {
my $self = shift;
++$self->{leveladvance};
if ($self->{leveladvance} >= 18) {
Games::PangZero::Music::PlaySound('level');
$self->SetGameLevel($self->{level}+1);
}
}
sub DrawLevelIndicator {
my ($self, $x, $y) = @_;
$self->{levelIndicatorRect} = SDL::Rect->new($x, $y, 140, $self->{scoreBoardHeight}) unless $self->{levelIndicatorRect};
#SDL::Video::fill_rect( $Games::PangZero::App, $self->{levelIndicatorRect}, SDL::Color->new(0,0,0) );
SDL::Video::blit_surface($Games::PangZero::LevelIndicatorSurface2, SDL::Rect->new($x, $y, $Games::PangZero::LevelIndicatorSurface2->w, $Games::PangZero::LevelIndicatorSurface2->h),
$Games::PangZero::App, SDL::Rect->new($x, $y, 0, 0));
SDL::Video::blit_surface($Games::PangZero::LevelIndicatorSurface, SDL::Rect->new(0, 0, 130 * $self->{leveladvance} / 17, 30), $Games::PangZero::App, SDL::Rect->new($x, $y, 0, 0));
SDLx::SFont::print_text( $Games::PangZero::App, $x + 25, $y + 3, 'Level ' . ($self->{level}+1) );
SDLx::SFont::print_text( $Games::PangZero::App, $x, $y + 40, sprintf('spd: %d/%d', $Games::PangZero::GameSpeed * 100, $self->{leveldesc}->{spawndelay}) ) if $self->{scoreBoardHeight} >= 64;
}
1;
|