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 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180
|
package Sprites;
#/*
#* KAsteroids - Copyright (c) Martin R. Jones 1997
#*
#* Part of the KDE project
#*/
use constant {
ID_ROCK_LARGE => 1024,
ID_ROCK_MEDIUM => 1025,
ID_ROCK_SMALL => 1026,
ID_MISSILE => 1030,
ID_BIT => 1040,
ID_EXHAUST => 1041,
ID_ENERGY_POWERUP => 1310,
ID_TELEPORT_POWERUP => 1311,
ID_BRAKE_POWERUP => 1312,
ID_SHIELD_POWERUP => 1313,
ID_SHOOT_POWERUP => 1314,
ID_SHIP => 1350,
ID_SHIELD => 1351,
MAX_SHIELD_AGE => 350,
MAX_POWERUP_AGE => 500,
MAX_MISSILE_AGE => 40,
};
1;
package KMissile;
use strict;
use warnings;
use QtCore4;
use QtGui4;
use AnimatedPixmapItem;
use QtCore4::isa qw(AnimatedPixmapItem);
sub NEW
{
my ( $class, $s, $c ) = @_;
$class->SUPER::NEW($s, $c);
this->{myAge} = 0;
}
sub type() { return Sprites::ID_MISSILE; }
sub growOlder() { this->{myAge}++; }
sub expired() { return this->{myAge} > Sprites::MAX_MISSILE_AGE; }
1;
package KBit;
use strict;
use warnings;
use QtCore4;
use QtGui4;
use AnimatedPixmapItem;
use QtCore4::isa qw(AnimatedPixmapItem);
sub NEW
{
my ( $class, $s, $c ) = @_;
$class->SUPER::NEW($s, $c);
this->{death} = 7;
}
sub type() { return Sprites::ID_BIT; }
sub setDeath($) { my ( $d )= @_; this->{death} = $d; }
sub growOlder() { this->{death}--; }
sub expired() { return this->{death} <= 0; }
1;
package KExhaust;
use strict;
use warnings;
use QtCore4;
use QtGui4;
use AnimatedPixmapItem;
use QtCore4::isa qw(AnimatedPixmapItem);
sub NEW
{
my ( $class, $s, $c ) = @_;
$class->SUPER::NEW($s, $c);
this->{death} = 1;
}
sub type() { return Sprites::ID_EXHAUST; }
sub setDeath($) { my ($d) = @_; this->{death} = $d; }
sub growOlder() { this->{death}--; }
sub expired() { return this->{death} <= 0; }
1;
package KPowerup;
use strict;
use warnings;
use QtCore4;
use QtGui4;
use AnimatedPixmapItem;
use QtCore4::isa qw(AnimatedPixmapItem);
sub NEW
{
my ( $class, $s, $c, $t ) = @_;
$class->SUPER::NEW($s, $c);
this->{myAge} = 0;
this->{_type} = $t;
}
sub type() { return this->{_type}; }
sub growOlder() { this->{myAge}++; }
sub expired() { return this->{myAge} > Sprites::MAX_POWERUP_AGE; }
1;
package KRock;
use strict;
use warnings;
use QtCore4;
use QtGui4;
use AnimatedPixmapItem;
use QtCore4::isa qw(AnimatedPixmapItem);
sub NEW
{
my ( $class, $s, $c, $t, $sk, $st ) = @_;
$class->SUPER::NEW($s, $c);
this->{_type} = $t;
this->{skip} = $sk;
this->{cskip} = $sk;
this->{step} = $st;
}
sub nextFrame
{
if (this->{cskip}-- <= 0) {
setFrame( (frame()+this->{step}+frameCount()) % frameCount() );
this->{cskip} = abs(this->{skip});
}
}
sub type() { return this->{_type}; }
1;
package KShield;
use strict;
use warnings;
use QtCore4;
use QtGui4;
use AnimatedPixmapItem;
use QtCore4::isa qw(AnimatedPixmapItem);
sub NEW
{
my ( $class, $s, $c ) = @_;
$class->SUPER::NEW($s, $c);
}
sub type() { return Sprites::ID_SHIELD; }
1;
|