|
1 /**************************************************************************** |
|
2 ** |
|
3 ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). |
|
4 ** All rights reserved. |
|
5 ** Contact: Nokia Corporation (qt-info@nokia.com) |
|
6 ** |
|
7 ** This file is part of the examples of the Qt Toolkit. |
|
8 ** |
|
9 ** $QT_BEGIN_LICENSE:LGPL$ |
|
10 ** No Commercial Usage |
|
11 ** This file contains pre-release code and may not be distributed. |
|
12 ** You may use this file in accordance with the terms and conditions |
|
13 ** contained in the Technology Preview License Agreement accompanying |
|
14 ** this package. |
|
15 ** |
|
16 ** GNU Lesser General Public License Usage |
|
17 ** Alternatively, this file may be used under the terms of the GNU Lesser |
|
18 ** General Public License version 2.1 as published by the Free Software |
|
19 ** Foundation and appearing in the file LICENSE.LGPL included in the |
|
20 ** packaging of this file. Please review the following information to |
|
21 ** ensure the GNU Lesser General Public License version 2.1 requirements |
|
22 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. |
|
23 ** |
|
24 ** In addition, as a special exception, Nokia gives you certain additional |
|
25 ** rights. These rights are described in the Nokia Qt LGPL Exception |
|
26 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. |
|
27 ** |
|
28 ** If you have questions regarding the use of this file, please contact |
|
29 ** Nokia at qt-info@nokia.com. |
|
30 ** |
|
31 ** |
|
32 ** |
|
33 ** |
|
34 ** |
|
35 ** |
|
36 ** |
|
37 ** |
|
38 ** $QT_END_LICENSE$ |
|
39 ** |
|
40 ****************************************************************************/ |
|
41 |
|
42 /* |
|
43 * KAsteroids - Copyright (c) Martin R. Jones 1997 |
|
44 * |
|
45 * Part of the KDE project |
|
46 */ |
|
47 |
|
48 #ifndef __SPRITES_H__ |
|
49 #define __SPRITES_H__ |
|
50 |
|
51 #include "animateditem.h" |
|
52 |
|
53 #define ID_ROCK_LARGE 1024 |
|
54 #define ID_ROCK_MEDIUM 1025 |
|
55 #define ID_ROCK_SMALL 1026 |
|
56 |
|
57 #define ID_MISSILE 1030 |
|
58 |
|
59 #define ID_BIT 1040 |
|
60 #define ID_EXHAUST 1041 |
|
61 |
|
62 #define ID_ENERGY_POWERUP 1310 |
|
63 #define ID_TELEPORT_POWERUP 1311 |
|
64 #define ID_BRAKE_POWERUP 1312 |
|
65 #define ID_SHIELD_POWERUP 1313 |
|
66 #define ID_SHOOT_POWERUP 1314 |
|
67 |
|
68 #define ID_SHIP 1350 |
|
69 #define ID_SHIELD 1351 |
|
70 |
|
71 #define MAX_SHIELD_AGE 350 |
|
72 #define MAX_POWERUP_AGE 500 |
|
73 #define MAX_MISSILE_AGE 40 |
|
74 |
|
75 class KMissile : public AnimatedPixmapItem |
|
76 { |
|
77 public: |
|
78 KMissile( const QList<QPixmap> &s, QGraphicsScene *c ) : AnimatedPixmapItem( s, c ) |
|
79 { myAge = 0; } |
|
80 |
|
81 virtual int type() const { return ID_MISSILE; } |
|
82 |
|
83 void growOlder() { myAge++; } |
|
84 bool expired() { return myAge > MAX_MISSILE_AGE; } |
|
85 |
|
86 private: |
|
87 int myAge; |
|
88 }; |
|
89 |
|
90 class KBit : public AnimatedPixmapItem |
|
91 { |
|
92 public: |
|
93 KBit( const QList<QPixmap> &s, QGraphicsScene *c ) : AnimatedPixmapItem( s, c ) |
|
94 { death = 7; } |
|
95 |
|
96 virtual int type() const { return ID_BIT; } |
|
97 |
|
98 void setDeath( int d ) { death = d; } |
|
99 void growOlder() { death--; } |
|
100 bool expired() { return death <= 0; } |
|
101 |
|
102 private: |
|
103 int death; |
|
104 }; |
|
105 |
|
106 class KExhaust : public AnimatedPixmapItem |
|
107 { |
|
108 public: |
|
109 KExhaust( const QList<QPixmap> &s, QGraphicsScene *c ) : AnimatedPixmapItem( s, c ) |
|
110 { death = 1; } |
|
111 |
|
112 virtual int type() const { return ID_EXHAUST; } |
|
113 |
|
114 void setDeath( int d ) { death = d; } |
|
115 void growOlder() { death--; } |
|
116 bool expired() { return death <= 0; } |
|
117 |
|
118 private: |
|
119 int death; |
|
120 }; |
|
121 |
|
122 class KPowerup : public AnimatedPixmapItem |
|
123 { |
|
124 public: |
|
125 KPowerup( const QList<QPixmap> &s, QGraphicsScene *c, int t ) : AnimatedPixmapItem( s, c ), |
|
126 myAge( 0 ), _type(t) { } |
|
127 |
|
128 virtual int type() const { return _type; } |
|
129 |
|
130 void growOlder() { myAge++; } |
|
131 bool expired() const { return myAge > MAX_POWERUP_AGE; } |
|
132 |
|
133 protected: |
|
134 int myAge; |
|
135 int _type; |
|
136 }; |
|
137 |
|
138 class KRock : public AnimatedPixmapItem |
|
139 { |
|
140 public: |
|
141 KRock (const QList<QPixmap> &s, QGraphicsScene *c, int t, int sk, int st) : AnimatedPixmapItem( s, c ) |
|
142 { _type = t; skip = cskip = sk; step = st; } |
|
143 |
|
144 void nextFrame() |
|
145 { |
|
146 if (cskip-- <= 0) { |
|
147 setFrame( (frame()+step+frameCount())%frameCount() ); |
|
148 cskip = QABS(skip); |
|
149 } |
|
150 } |
|
151 |
|
152 virtual int type() const { return _type; } |
|
153 |
|
154 private: |
|
155 int _type; |
|
156 int skip; |
|
157 int cskip; |
|
158 int step; |
|
159 }; |
|
160 |
|
161 class KShield : public AnimatedPixmapItem |
|
162 { |
|
163 public: |
|
164 KShield( QList<QPixmap> &s, QGraphicsScene *c ) |
|
165 : AnimatedPixmapItem( s, c ) {} |
|
166 |
|
167 virtual int type() const { return ID_SHIELD; } |
|
168 }; |
|
169 |
|
170 #endif |