Diffstat (limited to 'noncore/games/qasteroids/sprites.h') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/games/qasteroids/sprites.h | 147 |
1 files changed, 147 insertions, 0 deletions
diff --git a/noncore/games/qasteroids/sprites.h b/noncore/games/qasteroids/sprites.h new file mode 100644 index 0000000..0827821 --- a/dev/null +++ b/noncore/games/qasteroids/sprites.h | |||
@@ -0,0 +1,147 @@ | |||
1 | /********************************************************************** | ||
2 | ** Copyright (C) 2000 Trolltech AS. All rights reserved. | ||
3 | ** | ||
4 | ** This file is part of Qtopia Environment. | ||
5 | ** | ||
6 | ** This file may be distributed and/or modified under the terms of the | ||
7 | ** GNU General Public License version 2 as published by the Free Software | ||
8 | ** Foundation and appearing in the file LICENSE.GPL included in the | ||
9 | ** packaging of this file. | ||
10 | ** | ||
11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | ||
12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | ||
13 | ** | ||
14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. | ||
15 | ** | ||
16 | ** Contact info@trolltech.com if any conditions of this licensing are | ||
17 | ** not clear to you. | ||
18 | ** | ||
19 | **********************************************************************//* | ||
20 | * KAsteroids - Copyright (c) Martin R. Jones 1997 | ||
21 | * | ||
22 | * Part of the KDE project | ||
23 | */ | ||
24 | |||
25 | #ifndef __SPRITES_H__ | ||
26 | #define __SPRITES_H__ | ||
27 | |||
28 | #include <qcanvas.h> | ||
29 | |||
30 | #define ID_ROCK_LARGE 1024 | ||
31 | #define ID_ROCK_MEDIUM 1025 | ||
32 | #define ID_ROCK_SMALL 1026 | ||
33 | |||
34 | #define ID_MISSILE 1030 | ||
35 | |||
36 | #define ID_BIT 1040 | ||
37 | #define ID_EXHAUST 1041 | ||
38 | |||
39 | #define ID_ENERGY_POWERUP 1310 | ||
40 | #define ID_TELEPORT_POWERUP 1311 | ||
41 | #define ID_BRAKE_POWERUP 1312 | ||
42 | #define ID_SHIELD_POWERUP 1313 | ||
43 | #define ID_SHOOT_POWERUP 1314 | ||
44 | |||
45 | #define ID_SHIP 1350 | ||
46 | #define ID_SHIELD 1351 | ||
47 | |||
48 | #define MAX_SHIELD_AGE 350 | ||
49 | #define MAX_POWERUP_AGE 500 | ||
50 | #define MAX_MISSILE_AGE 20 | ||
51 | |||
52 | class KMissile : public QCanvasSprite | ||
53 | { | ||
54 | public: | ||
55 | KMissile( QCanvasPixmapArray *s, QCanvas *c ) : QCanvasSprite( s, c ) | ||
56 | { myAge = 0; } | ||
57 | |||
58 | virtual int rtti() const { return ID_MISSILE; } | ||
59 | |||
60 | void growOlder() { myAge++; } | ||
61 | bool expired() { return myAge > MAX_MISSILE_AGE; } | ||
62 | |||
63 | private: | ||
64 | int myAge; | ||
65 | }; | ||
66 | |||
67 | class KBit : public QCanvasSprite | ||
68 | { | ||
69 | public: | ||
70 | KBit( QCanvasPixmapArray *s, QCanvas *c ) : QCanvasSprite( s, c ) | ||
71 | { death = 7; } | ||
72 | |||
73 | virtual int rtti() const { return ID_BIT; } | ||
74 | |||
75 | void setDeath( int d ) { death = d; } | ||
76 | void growOlder() { death--; } | ||
77 | bool expired() { return death <= 0; } | ||
78 | |||
79 | private: | ||
80 | int death; | ||
81 | }; | ||
82 | |||
83 | class KExhaust : public QCanvasSprite | ||
84 | { | ||
85 | public: | ||
86 | KExhaust( QCanvasPixmapArray *s, QCanvas *c ) : QCanvasSprite( s, c ) | ||
87 | { death = 1; } | ||
88 | |||
89 | virtual int rtti() const { return ID_EXHAUST; } | ||
90 | |||
91 | void setDeath( int d ) { death = d; } | ||
92 | void growOlder() { death--; } | ||
93 | bool expired() { return death <= 0; } | ||
94 | |||
95 | private: | ||
96 | int death; | ||
97 | }; | ||
98 | |||
99 | class KPowerup : public QCanvasSprite | ||
100 | { | ||
101 | public: | ||
102 | KPowerup( QCanvasPixmapArray *s, QCanvas *c, int t ) : QCanvasSprite( s, c ), | ||
103 | myAge( 0 ), type(t) { } | ||
104 | |||
105 | virtual int rtti() const { return type; } | ||
106 | |||
107 | void growOlder() { myAge++; } | ||
108 | bool expired() const { return myAge > MAX_POWERUP_AGE; } | ||
109 | |||
110 | protected: | ||
111 | int myAge; | ||
112 | int type; | ||
113 | }; | ||
114 | |||
115 | class KRock : public QCanvasSprite | ||
116 | { | ||
117 | public: | ||
118 | KRock (QCanvasPixmapArray *s, QCanvas *c, int t, int sk, int st) : QCanvasSprite( s, c ) | ||
119 | { type = t; skip = cskip = sk; step = st; } | ||
120 | |||
121 | void nextFrame() | ||
122 | { | ||
123 | if (cskip-- <= 0) { | ||
124 | setFrame( (frame()+step+frameCount())%frameCount() ); | ||
125 | cskip = QABS(skip); | ||
126 | } | ||
127 | } | ||
128 | |||
129 | virtual int rtti() const { return type; } | ||
130 | |||
131 | private: | ||
132 | int type; | ||
133 | int skip; | ||
134 | int cskip; | ||
135 | int step; | ||
136 | }; | ||
137 | |||
138 | class KShield : public QCanvasSprite | ||
139 | { | ||
140 | public: | ||
141 | KShield( QCanvasPixmapArray *s, QCanvas *c ) | ||
142 | : QCanvasSprite( s, c ) {} | ||
143 | |||
144 | virtual int rtti() const { return ID_SHIELD; } | ||
145 | }; | ||
146 | |||
147 | #endif | ||