00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025 #ifndef __SPRITES_H__
00026 #define __SPRITES_H__
00027
00028 #include <qcanvas.h>
00029
00030 #define ID_ROCK_LARGE 1024
00031 #define ID_ROCK_MEDIUM 1025
00032 #define ID_ROCK_SMALL 1026
00033
00034 #define ID_MISSILE 1030
00035
00036 #define ID_BIT 1040
00037 #define ID_EXHAUST 1041
00038
00039 #define ID_ENERGY_POWERUP 1310
00040 #define ID_TELEPORT_POWERUP 1311
00041 #define ID_BRAKE_POWERUP 1312
00042 #define ID_SHIELD_POWERUP 1313
00043 #define ID_SHOOT_POWERUP 1314
00044
00045 #define ID_SHIP 1350
00046 #define ID_SHIELD 1351
00047
00048 #define MAX_SHIELD_AGE 350
00049 #define MAX_POWERUP_AGE 500
00050 #define MAX_MISSILE_AGE 20
00051
00052 class KMissile : public QCanvasSprite
00053 {
00054 public:
00055 KMissile( QCanvasPixmapArray *s, QCanvas *c ) : QCanvasSprite( s, c )
00056 { myAge = 0; }
00057
00058 virtual int rtti() const { return ID_MISSILE; }
00059
00060 void growOlder() { myAge++; }
00061 bool expired() { return myAge > MAX_MISSILE_AGE; }
00062
00063 private:
00064 int myAge;
00065 };
00066
00067 class KBit : public QCanvasSprite
00068 {
00069 public:
00070 KBit( QCanvasPixmapArray *s, QCanvas *c ) : QCanvasSprite( s, c )
00071 { death = 7; }
00072
00073 virtual int rtti() const { return ID_BIT; }
00074
00075 void setDeath( int d ) { death = d; }
00076 void growOlder() { death--; }
00077 bool expired() { return death <= 0; }
00078
00079 private:
00080 int death;
00081 };
00082
00083 class KExhaust : public QCanvasSprite
00084 {
00085 public:
00086 KExhaust( QCanvasPixmapArray *s, QCanvas *c ) : QCanvasSprite( s, c )
00087 { death = 1; }
00088
00089 virtual int rtti() const { return ID_EXHAUST; }
00090
00091 void setDeath( int d ) { death = d; }
00092 void growOlder() { death--; }
00093 bool expired() { return death <= 0; }
00094
00095 private:
00096 int death;
00097 };
00098
00099 class KPowerup : public QCanvasSprite
00100 {
00101 public:
00102 KPowerup( QCanvasPixmapArray *s, QCanvas *c, int t ) : QCanvasSprite( s, c ),
00103 myAge( 0 ), type(t) { }
00104
00105 virtual int rtti() const { return type; }
00106
00107 void growOlder() { myAge++; }
00108 bool expired() const { return myAge > MAX_POWERUP_AGE; }
00109
00110 protected:
00111 int myAge;
00112 int type;
00113 };
00114
00115 class KRock : public QCanvasSprite
00116 {
00117 public:
00118 KRock (QCanvasPixmapArray *s, QCanvas *c, int t, int sk, int st) : QCanvasSprite( s, c )
00119 { type = t; skip = cskip = sk; step = st; }
00120
00121 void nextFrame()
00122 {
00123 if (cskip-- <= 0) {
00124 setFrame( (frame()+step+frameCount())%frameCount() );
00125 cskip = QABS(skip);
00126 }
00127 }
00128
00129 virtual int rtti() const { return type; }
00130
00131 private:
00132 int type;
00133 int skip;
00134 int cskip;
00135 int step;
00136 };
00137
00138 class KShield : public QCanvasSprite
00139 {
00140 public:
00141 KShield( QCanvasPixmapArray *s, QCanvas *c )
00142 : QCanvasSprite( s, c ) {}
00143
00144 virtual int rtti() const { return ID_SHIELD; }
00145 };
00146
00147 #endif