1 | /* |
2 | Copyright (C) 1998-2001 Andreas Zehender <az@azweb.de> |
3 | |
4 | it under the terms of the GNU General Public License as published by |
5 | the Free Software Foundation; either version 2 of the License, or |
6 | (at your option) any later version. |
7 | |
8 | This program is distributed in the hope that it will be useful, |
9 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
10 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
11 | GNU General Public License for more details. |
12 | |
13 | You should have received a copy of the GNU General Public License |
14 | along with this program; if not, write to the Free Software |
15 | Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA |
16 | */ |
17 | |
18 | #ifndef KSPACEDUEL_SPRITES_H |
19 | #define KSPACEDUEL_SPRITES_H |
20 | |
21 | #include "defines.h" |
22 | #include "spritebase.h" |
23 | |
24 | #ifdef sun |
25 | #undef sun |
26 | #endif |
27 | |
28 | class SunSprite:public SimpleSprite |
29 | { |
30 | public: |
31 | SunSprite(QSvgRenderer* svg, const QString& element); |
32 | virtual int type() const {return S_SUN;} |
33 | }; |
34 | |
35 | class PowerupSprite:public SimpleSprite |
36 | { |
37 | public: |
38 | enum {PowerupMine=0, PowerupBullet, PowerupShield, PowerupEnergy, |
39 | PowerupNum}; |
40 | PowerupSprite(QSvgRenderer* svg, const QString& element, int t, double lifetime); |
41 | virtual int type() const {return S_POWERUP;} |
42 | |
43 | double getLifetime() {return time;} |
44 | void setLifetime(double t) {time=t;} |
45 | int getType() {return mtype;} |
46 | private: |
47 | double time; |
48 | int mtype; |
49 | }; |
50 | |
51 | class ShipSprite:public MobileSprite |
52 | { |
53 | public: |
54 | ShipSprite(QSvgRenderer* svg, const QString& element, int pn); |
55 | virtual int type() const {return S_SHIP;} |
56 | int getHitPoints() {return hitpoints;} |
57 | void setHitPoints(int hp) {hitpoints=(hp<0?0:hp);} |
58 | double getEnergy() {return energy;} |
59 | void setEnergy(double e) {energy=(e<0?0:e);} |
60 | void setWins(int w) {wins=w;} |
61 | int getWins() {return wins;} |
62 | void setExplosion(int f) {explosion=f;} |
63 | int getExplosion() {return explosion;} |
64 | void setRotation(double r); |
65 | double getRotation() {return rotation;} |
66 | void rotateRight(double rotationEnergyNeed,double rotationSpeed); |
67 | void rotateLeft(double rotationEnergyNeed,double rotationSpeed); |
68 | void bullet(double reloadTime) {reloadBulletTime=reloadTime;} |
69 | bool reloadsBullet(double t=0.0) {return reloadBulletTime>t;} |
70 | void mine(double reloadTime) {reloadMineTime=reloadTime;} |
71 | bool reloadsMine(double t=0.0) {return reloadMineTime>t;} |
72 | bool explodes() {return explosion>=0;} |
73 | void setMinePowerups(int m) {minePowerups=m;} |
74 | int getMinePowerups() {return minePowerups;} |
75 | void setBulletPowerups(int b) {bulletPowerups=b;} |
76 | int getBulletPowerups() {return bulletPowerups;} |
77 | virtual void forward(double mult); |
78 | virtual void forward(double mult,int fr); |
79 | virtual void calculateGravityAndEnergy(double gravity,double sunEnergy, |
80 | double mult); |
81 | private: |
82 | int hitpoints, wins, explosion; |
83 | double energy,rotation,reloadBulletTime,reloadMineTime; |
84 | int bulletPowerups,minePowerups; |
85 | double angle; // current rotation angle |
86 | }; |
87 | |
88 | class BulletSprite:public MobileSprite |
89 | { |
90 | public: |
91 | BulletSprite(QSvgRenderer* svg, const QString& elem, int pn,double lifetime); |
92 | virtual int type() const {return S_BULLET;} |
93 | virtual void forward(double mult); |
94 | virtual void forward(double mult,int fr); |
95 | bool timeOut() {return time<=0;} |
96 | private: |
97 | double time; |
98 | }; |
99 | |
100 | class MineSprite:public AnimatedSprite |
101 | { |
102 | public: |
103 | MineSprite(QSvgRenderer* svg, const QList<QString> &animation, const QList<QString> &exploanimation, int pn,double atime,double f); |
104 | virtual int type() const {return S_MINE;} |
105 | bool isActive() {return active;} |
106 | double getFuel() {return fuel;} |
107 | void setFuel(double f) {fuel=(f<0.0?0.0:f);} |
108 | virtual void forward(double mult); |
109 | void explode(); |
110 | bool explodes() {return expl;} |
111 | bool over() {return (expl&&(explosiontime>(timeToGo-0.1)));} |
112 | virtual void calculateGravity(double gravity,double mult); |
113 | private: |
114 | bool expl,active; |
115 | double activateTime,fuel,timeToGo,explosiontime; |
116 | QList<QString> exploframes; /* when mine explodes, we set frames to exploframes (needed because both player's mines have |
117 | the same explosion animation) */ |
118 | }; |
119 | |
120 | class ExplosionSprite:public AnimatedSprite |
121 | { |
122 | public: |
123 | explicit ExplosionSprite(QSvgRenderer* svg, const QList<QString> &animation, MobileSprite *sp = 0); |
124 | virtual int type() const {return S_EXPLOSION;} |
125 | bool isOver() {return over;} |
126 | virtual void forward(double mult); |
127 | private: |
128 | double timeToGo,time; |
129 | bool over; |
130 | MobileSprite *obj; |
131 | }; |
132 | |
133 | #endif // KSPACEDUEL_SPRITES_H |
134 | |