| 1 | ########################################################################## | ||
| 2 | # GLOBAL CONFIGURATION | ||
| 3 | ########################################################################## | ||
| 4 | package Games::PangZero::Globals; | ||
| 5 | |||
| 6 | use Games::PangZero::Config; | ||
| 7 | |||
| 8 | %Sounds = ( | ||
| 9 | 'pop' => 'pop.voc', | ||
| 10 | 'shoot' => 'shoot.voc', | ||
| 11 | 'death' => 'meow.voc', | ||
| 12 | 'level' => 'level.voc', | ||
| 13 | 'bonuslife' => 'magic.voc', | ||
| 14 | 'pause' => 'pop3.voc', | ||
| 15 | 'quake' => 'quake.voc', | ||
| 16 | ); | ||
| 17 | |||
| 18 | @Games::PangZero::DifficultyLevels = ( | ||
| 19 | { 'name' => 'Easy', 'spawnmultiplier' => 1.2, 'speed' => 0.8, 'harpoons' => 5, 'superball' => 0.8, 'bonusprobability' => 0.2, }, | ||
| 20 | { 'name' => 'Normal', 'spawnmultiplier' => 1.0, 'speed' => 1.0, 'harpoons' => 3, 'superball' => 1.0, 'bonusprobability' => 0.1, }, | ||
| 21 | { 'name' => 'Hard', 'spawnmultiplier' => 0.9, 'speed' => 1.2, 'harpoons' => 2, 'superball' => 1.1, 'bonusprobability' => 0.05, }, | ||
| 22 | { 'name' => 'Nightmare','spawnmultiplier' => 0.8, 'speed' => 1.4, 'harpoons' => 2, 'superball' => 1.5, 'bonusprobability' => 0.02, }, | ||
| 23 | { 'name' => 'Miki', 'spawnmultiplier' => 0.4, 'speed' => 1.0, 'harpoons' => 3, 'superball' => 1.0, 'bonusprobability' => 0.1, }, | ||
| 24 | ); | ||
| 25 | Games::PangZero::Config::SetDifficultyLevel(1); | ||
| 26 | @Games::PangZero::WeaponDurations = ( | ||
| 27 | { 'name' => 'Short (Default)', 'durationmultiplier' => 1, }, | ||
| 28 | { 'name' => 'Medium', 'durationmultiplier' => 3, }, | ||
| 29 | { 'name' => 'Long', 'durationmultiplier' => 6, }, | ||
| 30 | { 'name' => 'Very Long', 'durationmultiplier' => 12, }, | ||
| 31 | { 'name' => 'Forever', 'durationmultiplier' => 10000, }, | ||
| 32 | ); | ||
| 33 | Games::PangZero::Config::SetWeaponDuration(0); | ||
| 34 | |||
| 35 | $Games::PangZero::NumGuys = 1; | ||
| 36 | @Games::PangZero::Players = ( | ||
| 37 | { 'keys' => [SDLK_LEFT, SDLK_RIGHT, SDLK_UP], }, # blue | ||
| 38 | { 'keys' => [SDLK_a, SDLK_d, SDLK_s], }, # red | ||
| 39 | { 'keys' => [SDLK_j, SDLK_l, SDLK_k], }, # green | ||
| 40 | { 'keys' => [SDLK_KP6, SDLK_KP4, SDLK_KP5], }, # pink | ||
| 41 | { 'keys' => [SDLK_KP6, SDLK_KP4, SDLK_KP5], }, # yellow | ||
| 42 | { 'keys' => [SDLK_KP6, SDLK_KP4, SDLK_KP5], }, # cyan | ||
| 43 | { 'keys' => [SDLK_KP6, SDLK_KP4, SDLK_KP5], }, # gray | ||
| 44 | { 'keys' => [SDLK_KP6, SDLK_KP4, SDLK_KP5], }, # snot | ||
| 45 | { 'keys' => [SDLK_KP6, SDLK_KP4, SDLK_KP5], }, # purple | ||
| 46 | ); | ||
| 47 | @Games::PangZero::GuyImageFiles = ( 'guyChristmas.png', 'guy_danigm.png', 'guy_pix.png', 'guy_pux.png', 'guy_r2.png', 'guy_sonic.png' ); | ||
| 48 | @Games::PangZero::GuyColors = ( [170, 255, 'blue'], [ 0, 255, 'red'], [ 85, 255, 'green'], [212, 255, 'pink'], | ||
| 49 | [ 42, 255, 'yellow'], [128, 255, 'cyan'], [128, 0, 'gray'], [113, 128, 'snot'], [212, 64, 'purple'] ); | ||
| 50 | for (my $i=0; $i<=$#Games::PangZero::Players; ++$i) { | ||
| 51 | $Games::PangZero::Players[$i]->{number} = $i; | ||
| 52 | $Games::PangZero::Players[$i]->{colorindex} = $i; | ||
| 53 | $Games::PangZero::Players[$i]->{imagefileindex} = $i % scalar(@Games::PangZero::GuyImageFiles); | ||
| 54 | } | ||
| 55 | |||
| 56 | my %n0 = ('popIndex' => 0, 'rect' => SDL::Rect->new(0, 0, 128, 106)); | ||
| 57 | my %n1 = ('popIndex' => 1, 'rect' => SDL::Rect->new(0, 0, 96, 80)); | ||
| 58 | my %n2 = ('popIndex' => 2, 'rect' => SDL::Rect->new(0, 0, 64, 53)); | ||
| 59 | my %n3 = ('popIndex' => 3, 'rect' => SDL::Rect->new(0, 0, 32, 28)); | ||
| 60 | my %n4 = ('popIndex' => 4, 'rect' => SDL::Rect->new(0, 0, 16, 15)); | ||
| 61 | |||
| 62 | @Games::PangZero::BallDesc = ( | ||
| 63 | # Normal balls (n0 .. n4) | ||
| 64 | { 'name' => 'n0', 'class' => 'Ball', 'score' => 2000, 'spawndelay' => 1, 'speedY' => 6.5, %n0, 'surface' => 'ball0', 'nextgen' => 'n1', }, | ||
| 65 | { 'name' => 'n1', 'class' => 'Ball', 'score' => 1000, 'spawndelay' => 0.5, 'speedY' => 5.7, %n1, 'surface' => 'ball1', 'nextgen' => 'n2', }, | ||
| 66 | { 'name' => 'n2', 'class' => 'Ball', 'score' => 800, 'spawndelay' => 0.25, 'speedY' => 5, %n2, 'surface' => 'ball2', 'nextgen' => 'n3', }, | ||
| 67 | { 'name' => 'n3', 'class' => 'Ball', 'score' => 600, 'spawndelay' => 0.12, 'speedY' => 4, %n3, 'surface' => 'ball3', 'nextgen' => 'n4', }, | ||
| 68 | { 'name' => 'n4', 'class' => 'Ball', 'score' => 500, 'spawndelay' => 0.05, 'speedY' => 3, %n4, 'surface' => 'ball4', }, | ||
| 69 | # "Bouncy" balls (b0..b2) | ||
| 70 | { 'name' => 'b0', 'class' => 'Ball', 'score' => 1500, 'spawndelay' => 0.5, 'speedY' => 5.7, %n2, 'surface' => 'bouncy2', 'nextgen' => 'b1', }, | ||
| 71 | { 'name' => 'b1', 'class' => 'Ball', 'score' => 750, 'spawndelay' => 0.2, 'speedY' => 5, %n3, 'surface' => 'bouncy3', 'nextgen' => 'b2', }, | ||
| 72 | { 'name' => 'b2', 'class' => 'Ball', 'score' => 500, 'spawndelay' => 0.1, 'speedY' => 4.2, %n4, 'surface' => 'bouncy4' }, | ||
| 73 | # Hexas (h0..h2) | ||
| 74 | { 'name' => 'h0', 'class' => 'Hexa', 'score' => 1500, 'spawndelay' => 0.5, 'popIndex' => 5, 'hexa' => 1, | ||
| 75 | 'surface' => 'hexa0', 'rect' => SDL::Rect->new(0, 0, 64, 52), 'nextgen' => 'h1', }, | ||
| 76 | { 'name' => 'h1', 'class' => 'Hexa', 'score' => 1000, 'spawndelay' => 0.2, 'popIndex' => 6, 'hexa' => 1, | ||
| 77 | 'surface' => 'hexa1', 'rect' => SDL::Rect->new(0, 0, 32, 28), 'nextgen' => 'h2', }, | ||
| 78 | { 'name' => 'h2', 'class' => 'Hexa', 'score' => 500, 'spawndelay' => 0.1, 'popIndex' => 7, 'hexa' => 1, | ||
| 79 | 'surface' => 'hexa2', 'rect' => SDL::Rect->new(0, 0, 16, 14), | ||
| 80 | 'magicrect' => SDL::Rect->new(48, 0, 16, 14), }, | ||
| 81 | # Water ball | ||
| 82 | { 'name' => 'w1', 'class' => 'WaterBall', 'score' => 1500, 'spawndelay' => 0.4, 'speedY' => 5.7, %n1, 'surface' => 'blue1', 'nextgen' => 'w2', }, | ||
| 83 | { 'name' => 'w2', 'class' => 'WaterBall', 'score' => 1000, 'spawndelay' => 0.2, 'speedY' => 5, %n2, 'surface' => 'blue2', 'nextgen' => 'w3', }, | ||
| 84 | { 'name' => 'w3', 'class' => 'WaterBall', 'score' => 800, 'spawndelay' => 0.1, 'speedY' => 4, %n3, 'surface' => 'blue3', 'nextgen' => 'w4', }, | ||
| 85 | { 'name' => 'w4', 'class' => 'WaterBall', 'score' => 600, 'spawndelay' => 0.05, 'speedY' => 3, %n4, 'surface' => 'blue4', }, | ||
| 86 | # Fragile | ||
| 87 | { 'name' => 'f0', 'class' => 'FragileBall', 'score' => 1500, 'spawndelay' => 0.8, 'speedY' => 6.5, %n0, 'surface' => 'frag0', 'nextgen' => 'f1', }, | ||
| 88 | { 'name' => 'f1', 'class' => 'FragileBall', 'score' => 1500, 'spawndelay' => 0.4, 'speedY' => 5.7, %n1, 'surface' => 'frag1', 'nextgen' => 'f2', }, | ||
| 89 | { 'name' => 'f2', 'class' => 'FragileBall', 'score' => 1000, 'spawndelay' => 0.2, 'speedY' => 5, %n2, 'surface' => 'frag2', 'nextgen' => 'f3', }, | ||
| 90 | { 'name' => 'f3', 'class' => 'FragileBall', 'score' => 800, 'spawndelay' => 0.1, 'speedY' => 4, %n3, 'surface' => 'frag3', 'nextgen' => 'f4', }, | ||
| 91 | { 'name' => 'f4', 'class' => 'FragileBall', 'score' => 600, 'spawndelay' => 0.05, 'speedY' => 3, %n4, 'surface' => 'frag4', }, | ||
| 92 | # Superball | ||
| 93 | { 'name' => 'super0', 'class' => 'SuperBall', 'score' => 1000, 'spawndelay' => 0.5, 'speedY' => 5.7, %n1, 'surface' => 'green1', }, | ||
| 94 | { 'name' => 'super1', 'class' => 'SuperBall', 'score' => 800, 'spawndelay' => 0.25, 'speedY' => 5, %n2, 'surface' => 'green2', }, | ||
| 95 | { 'name' => 'xmas', 'class' => 'XmasBall', 'score' => 1000, 'spawndelay' => 0.5, 'speedY' => 6.5, %n0, 'surface' => 'xmas', }, | ||
| 96 | # Death | ||
| 97 | { 'name' => 'death', 'class' => 'DeathBall', 'score' => 0, 'spawndelay' => 0.5, 'speedY' => 5, %n2, 'surface' => 'death2', 'nextgen' => 'death', }, | ||
| 98 | # Seeker | ||
| 99 | { 'name' => 'seeker', 'class' => 'SeekerBall', 'score' => 1200, 'spawndelay' => 0.2, 'speedY' => 5.7, %n2, 'surface' => 'white2', 'nextgen' => 'seeker1', }, | ||
| 100 | { 'name' => 'seeker1', 'class' => 'SeekerBall', 'score' => 1200, 'spawndelay' => 0.1, 'speedY' => 5, %n3, 'surface' => 'white3', }, | ||
| 101 | # Quake | ||
| 102 | { 'name' => 'quake', 'class' => 'EarthquakeBall', 'score' => 1600, 'spawndelay' => 0.7, 'speedY' => 5.7, %n2, 'surface' => 'quake2', | ||
| 103 | 'quake' => 5, 'nextgen' => 'quake1', }, | ||
| 104 | { 'name' => 'quake1', 'class' => 'EarthquakeBall', 'score' => 1200, 'spawndelay' => 0.2, 'speedY' => 5, %n3, 'surface' => 'quake3', | ||
| 105 | 'quake' => 3, 'nextgen' => 'quake2', }, | ||
| 106 | { 'name' => 'quake2', 'class' => 'EarthquakeBall', 'score' => 1000, 'spawndelay' => 0.1, 'speedY' => 4.2, %n4, 'surface' => 'quake4', | ||
| 107 | 'quake' => 2, }, | ||
| 108 | # Upside down ball | ||
| 109 | { 'name' => 'u0', 'class' => 'UpsideDownBall', 'score' => 2000, 'spawndelay' => 1, 'speedY' => 5.8, %n0, 'surface' => 'upside0', 'nextgen' => 'u1', }, | ||
| 110 | { 'name' => 'u1', 'class' => 'UpsideDownBall', 'score' => 1000, 'spawndelay' => 0.5, 'speedY' => 5.8, %n1, 'surface' => 'upside1', 'nextgen' => 'u2', }, | ||
| 111 | { 'name' => 'u2', 'class' => 'UpsideDownBall', 'score' => 800, 'spawndelay' => 0.25, 'speedY' =>5.8, %n2, 'surface' => 'upside2', 'nextgen' => 'u3', }, | ||
| 112 | { 'name' => 'u3', 'class' => 'UpsideDownBall', 'score' => 600, 'spawndelay' => 0.12, 'speedY' =>5.9, %n3, 'surface' => 'upside3', 'nextgen' => 'u4', }, | ||
| 113 | { 'name' => 'u4', 'class' => 'UpsideDownBall', 'score' => 500, 'spawndelay' => 0.05, 'speedY' =>5.9, %n4, 'surface' => 'upside4', }, | ||
| 114 | |||
| 115 | { 'name' => 'credits1', 'class' => 'Ball', 'speedY' => 6.1, 'nextgen' => 'credits1', 'surface' => 'blue3', %n3 }, | ||
| 116 | { 'name' => 'credits2', 'class' => 'Ball', 'speedY' => 6.1, 'nextgen' => 'credits2', 'surface' => 'ball3', %n3 }, | ||
| 117 | ); | ||
| 118 | { | ||
| 119 | foreach my $ballDesc (@Games::PangZero::BallDesc) { | ||
| 120 | $ballDesc->{width} = $ballDesc->{rect}->w(); | ||
| 121 | $ballDesc->{height} = $ballDesc->{rect}->h(); | ||
| 122 | $Games::PangZero::BallDesc{$ballDesc->{name}} = $ballDesc; | ||
| 123 | } | ||
| 124 | foreach my $ballDesc (@Games::PangZero::BallDesc) { | ||
| 125 | my $nextgen = $ballDesc->{nextgen}; | ||
| 126 | $ballDesc->{nextgen} = $Games::PangZero::BallDesc{$nextgen} if $nextgen; | ||
| 127 | } | ||
| 128 | } | ||
| 129 | |||
| 130 | @Games::PangZero::ChallengeLevels = ( | ||
| 131 | 'n4 n4 n4 n4 xmas', | ||
| 132 | 'n3 n3 n3', | ||
| 133 | 'n2 n2', | ||
| 134 | 'b0 b0', | ||
| 135 | 'h2 h2 h2 h2 h2 h2', | ||
| 136 | 'h0 h0', | ||
| 137 | 'n1 f2', | ||
| 138 | 'w1 n2', | ||
| 139 | 'n0 b0 w1 h0', | ||
| 140 | # 10 | ||
| 141 | 'n1 quake', | ||
| 142 | 'n1 b0 quake', | ||
| 143 | 'w1 seeker u2', | ||
| 144 | 'n0 seeker seeker', | ||
| 145 | 'w1 w1', | ||
| 146 | 'f1 quake h0', | ||
| 147 | 'w1 seeker h0 h0', | ||
| 148 | 'n0 w1 w1 b0 h0', | ||
| 149 | 'u0 u0 quake', | ||
| 150 | 'quake quake w1 b0 h0', | ||
| 151 | # 20 | ||
| 152 | 'death n1 b0', | ||
| 153 | 'n4 ' x 24, | ||
| 154 | 'w1 w1 w1 f0', | ||
| 155 | 'death w1 h0', | ||
| 156 | 'n0 n0 u0 seeker h2 h2 b0', | ||
| 157 | 'n4 b2 h2 u4 ' x 6, | ||
| 158 | 'quake quake quake b0', | ||
| 159 | 'h0 h0 h0 h0 h0 h0 h0 h0', | ||
| 160 | 'quake seeker f3 n1 b0 b0', | ||
| 161 | 'death death w1 f0 n0 u2 h0', | ||
| 162 | # 30 | ||
| 163 | 'n0 n0 u0 u0', | ||
| 164 | 'death quake n1', | ||
| 165 | 'b0 h0 n2 ' x 3, | ||
| 166 | 'w1 w1 w1 w1 f1 f1', | ||
| 167 | 'n3 n3 n3 u3 ' x 4, | ||
| 168 | 'quake quake seeker seeker n0 f0', | ||
| 169 | 'seeker ' x 8, | ||
| 170 | 'n0 n1 n2 n3 n4 b0 f2 h0 h1 h2 w1 seeker', | ||
| 171 | 'quake quake quake h0 h0 h0 u2', | ||
| 172 | 'death quake seeker w1 n0 b0 h0', | ||
| 173 | # 40 | ||
| 174 | 'n0 n1 n2 ' x 3, | ||
| 175 | 'death quake seeker u2 ' x 3, | ||
| 176 | 'f0 f0', | ||
| 177 | 'death quake f0 n1 ' x 2, | ||
| 178 | 'h0 ' x 8 . ' f0 f1 ', | ||
| 179 | 'death ' x 10, | ||
| 180 | 'quake b0 ' x 5, | ||
| 181 | 'w1 w1 f0 f1 death', | ||
| 182 | 'seeker ' x 13, | ||
| 183 | 'n0 u0 w1 f0 quake death ' x 2, | ||
| 184 | ); | ||
| 185 | |||
| 186 | for ( my $i = 0; $i < 10; ++$i) { | ||
| 187 | $Games::PangZero::ChallengeLevels[$i + 49] = $Games::PangZero::ChallengeLevels[$i + 9] . ' ' . $Games::PangZero::ChallengeLevels[$i + 29]; | ||
| 188 | $Games::PangZero::ChallengeLevels[$i + 59] = $Games::PangZero::ChallengeLevels[$i + 19] . ' ' . $Games::PangZero::ChallengeLevels[$i + 39]; | ||
| 189 | } | ||
| 190 | foreach (@Games::PangZero::ChallengeLevels) { | ||
| 191 | while (/(\w+)/g) { | ||
| 192 | die "Unknown ball '$1' in challenge '$_'" unless defined $Games::PangZero::BallDesc{$1}; | ||
| 193 | } | ||
| 194 | } | ||
| 195 | |||
| 196 | my %BallMixes = ( | ||
| 197 | 'easy' => [ qw(n0 2 n1 20 n2 10 n3 3 n4 2 f0 3 f1 5 f2 5 b0 5 b1 2 b2 1 w1 10 h0 5 h1 3 h2 1 quake 1 seeker 2 u1 1 u2 2 u3 4 u4 1) ], | ||
| 198 | 'medium' => [ qw(n0 10 n1 20 n2 10 n3 3 n4 2 f0 3 f1 3 b0 10 b1 2 b2 1 w1 15 h0 15 h1 5 h2 1 death 2 quake 5 seeker 10 u0 2 u1 5 u2 5 u3 5) ], | ||
| 199 | 'bouncy' => [ qw(n0 20 n1 10 n2 5 n3 1 n4 1 f0 3 f1 3 b0 30 b1 9 b2 1 w1 10 h0 15 h1 5 death 5 quake 10 seeker 15 u0 5 u1 5 u2 1 u3 1) ], | ||
| 200 | 'hard' => [ qw(n0 20 n1 10 n2 5 n3 1 f0 5 f1 1 b0 20 b1 2 w1 20 h0 20 h1 5 death 10 quake 15 seeker 20 u0 5 u1 5 u2 1 u3 1) ], | ||
| 201 | 'watery' => [ qw(n0 20 n1 10 n2 5 n3 1 n4 1 f0 3 f1 1 b0 10 b1 5 w1 50 h0 15 h1 5 death 5 quake 10 seeker 15 u0 1 u1 5 u2 5 u3 1) ], | ||
| 202 | 'hexas' => [ qw(n0 20 n1 10 n2 5 n3 1 f0 3 f1 1 b0 15 b1 2 w1 20 h0 40 h1 15 death 5 quake 10 seeker 15 u0 1 u1 8 u2 2 u3 1) ], | ||
| 203 | 'quakes' => [ qw(n0 15 n1 10 n2 5 n3 1 f0 3 f1 1 b0 15 w1 15 h0 20 h1 5 death 5 quake 40 seeker 15 u0 8 u1 1 u2 2 u3 1) ], | ||
| 204 | ); | ||
| 205 | |||
| 206 | sub AddLevels { | ||
| 207 | my ($num, $balls, $gamespeedStart, $gamespeedEnd, $spawndelayStart, $spawndelayEnd) = @_; | ||
| 208 | my ($i, $level); | ||
| 209 | |||
| 210 | for ($i = 0; $i < $num; ++$i) { | ||
| 211 | $level = { | ||
| 212 | 'balls' => $balls, | ||
| 213 | 'gamespeed' => $gamespeedStart + ($gamespeedEnd - $gamespeedStart) * ($i) / ($num), | ||
| 214 | 'spawndelay' => $spawndelayStart + ($spawndelayEnd - $spawndelayStart) * ($i) / ($num), | ||
| 215 | }; | ||
| 216 | push @Games::PangZero::PanicLevels, ( $level ); | ||
| 217 | } | ||
| 218 | } | ||
| 219 | |||
| 220 | AddLevels( 9, $BallMixes{easy}, 0.75, 1.25, 20, 20 ); # 0-9 | ||
| 221 | AddLevels( 10, $BallMixes{medium}, 0.7 , 1.3 , 20, 15 ); # 1x | ||
| 222 | AddLevels( 10, $BallMixes{hard}, 0.7 , 1.5 , 15, 15 ); # 2x | ||
| 223 | AddLevels( 10, $BallMixes{hexas}, 1.0 , 1.5 , 15, 12 ); # 3x | ||
| 224 | AddLevels( 10, $BallMixes{watery}, 0.7 , 1.7 , 15, 17 ); # 4x | ||
| 225 | AddLevels( 10, $BallMixes{bouncy}, 1.0 , 2.0 , 12, 12 ); # 5x | ||
| 226 | AddLevels( 10, $BallMixes{quakes}, 1.5 , 2.2 , 13, 8 ); # 6x | ||
| 227 | AddLevels( 10, $BallMixes{hard}, 1.0 , 2.2 , 13, 10 ); # 7x | ||
| 228 | AddLevels( 10, $BallMixes{hexas}, 1.3 , 2.4 , 12, 9 ); # 8x | ||
| 229 | AddLevels( 10, $BallMixes{hard}, 2.0 , 3.0 , 13, 10 ); # 9x | ||
| 230 | |||
| 231 | # Set defaults | ||
| 232 | |||
| 233 | $Games::PangZero::ScreenMargin = 16; | ||
| 234 | $Games::PangZero::ScreenWidth = 800 - $Games::PangZero::ScreenMargin * 2; | ||
| 235 | $Games::PangZero::ScreenHeight = 416; | ||
| 236 | $Games::PangZero::SoundEnabled = 1; | ||
| 237 | $Games::PangZero::MusicEnabled = 1; | ||
| 238 | $Games::PangZero::DeathBallsEnabled = 1; | ||
| 239 | $Games::PangZero::EarthquakeBallsEnabled = 1; | ||
| 240 | $Games::PangZero::WaterBallsEnabled = 1; | ||
| 241 | $Games::PangZero::SeekerBallsEnabled = 1; | ||
| 242 | $Games::PangZero::FullScreen = 1; | ||
| 243 | $Games::PangZero::UnicodeMode = 0; | ||
| 244 | $Games::PangZero::Slippery = 0; | ||
| 245 | $Games::PangZero::ShowWebsite = 0; | ||
| 246 | |||
| 247 | 1; |