author | kergoth <kergoth> | 2002-01-25 22:14:26 (UTC) |
---|---|---|
committer | kergoth <kergoth> | 2002-01-25 22:14:26 (UTC) |
commit | 15318cad33835e4e2dc620d033e43cd930676cdd (patch) (unidiff) | |
tree | c2fa0399a2c47fda8e2cd0092c73a809d17f68eb /noncore/games/qasteroids/view.h | |
download | opie-15318cad33835e4e2dc620d033e43cd930676cdd.zip opie-15318cad33835e4e2dc620d033e43cd930676cdd.tar.gz opie-15318cad33835e4e2dc620d033e43cd930676cdd.tar.bz2 |
Initial revision
Diffstat (limited to 'noncore/games/qasteroids/view.h') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/games/qasteroids/view.h | 156 |
1 files changed, 156 insertions, 0 deletions
diff --git a/noncore/games/qasteroids/view.h b/noncore/games/qasteroids/view.h new file mode 100644 index 0000000..0a7902b --- a/dev/null +++ b/noncore/games/qasteroids/view.h | |||
@@ -0,0 +1,156 @@ | |||
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 __AST_VIEW_H__ | ||
26 | #define __AST_VIEW_H__ | ||
27 | |||
28 | #include <qwidget.h> | ||
29 | #include <qlist.h> | ||
30 | #include <qintdict.h> | ||
31 | #include <qtimer.h> | ||
32 | #include <qcanvas.h> | ||
33 | #include "sprites.h" | ||
34 | |||
35 | #define QPtrList QList | ||
36 | #define QPtrListIterator QListIterator | ||
37 | |||
38 | #define MAX_POWER_LEVEL 1000 | ||
39 | |||
40 | class KAsteroidsView : public QWidget | ||
41 | { | ||
42 | Q_OBJECT | ||
43 | public: | ||
44 | KAsteroidsView( QWidget *parent = 0, const char *name = 0 ); | ||
45 | virtual ~KAsteroidsView(); | ||
46 | |||
47 | int refreshRate; | ||
48 | |||
49 | void reset(); | ||
50 | void setRockSpeed( double rs ) { rockSpeed = rs; } | ||
51 | void addRocks( int num ); | ||
52 | void newGame(); | ||
53 | void endGame(); | ||
54 | void newShip(); | ||
55 | |||
56 | void rotateLeft( bool r ) { rotateL = r; rotateSlow = 5; } | ||
57 | void rotateRight( bool r ) { rotateR = r; rotateSlow = 5; } | ||
58 | void thrust( bool t ) { thrustShip = t && shipPower > 0; } | ||
59 | void shoot( bool s ) { shootShip = s; shootDelay = 0; } | ||
60 | void setShield( bool s ); | ||
61 | void teleport( bool te) { teleportShip = te && mTeleportCount; } | ||
62 | void brake( bool b ); | ||
63 | void pause( bool p); | ||
64 | |||
65 | void showText( const QString &text, const QColor &color, bool scroll=TRUE ); | ||
66 | void hideText(); | ||
67 | |||
68 | int shots() const { return shotsFired; } | ||
69 | int hits() const { return shotsHit; } | ||
70 | int power() const { return shipPower; } | ||
71 | |||
72 | int teleportCount() const { return mTeleportCount; } | ||
73 | int brakeCount() const { return mBrakeCount; } | ||
74 | int shieldCount() const { return mShieldCount; } | ||
75 | int shootCount() const { return mShootCount; } | ||
76 | |||
77 | signals: | ||
78 | void shipKilled(); | ||
79 | void rockHit( int size ); | ||
80 | void rocksRemoved(); | ||
81 | void updateVitals(); | ||
82 | |||
83 | private slots: | ||
84 | void hideShield(); | ||
85 | |||
86 | protected: | ||
87 | void readSprites(); | ||
88 | void wrapSprite( QCanvasItem * ); | ||
89 | void rockHit( QCanvasItem * ); | ||
90 | void reducePower( int val ); | ||
91 | void addExhaust( double x, double y, double dx, double dy, int count ); | ||
92 | void processMissiles(); | ||
93 | void processShip(); | ||
94 | void processPowerups(); | ||
95 | void processShield(); | ||
96 | double randDouble(); | ||
97 | int randInt( int range ); | ||
98 | |||
99 | virtual void resizeEvent( QResizeEvent *event ); | ||
100 | virtual void timerEvent( QTimerEvent * ); | ||
101 | |||
102 | private: | ||
103 | QCanvas field; | ||
104 | QCanvasView view; | ||
105 | QIntDict<QCanvasPixmapArray> animation; | ||
106 | QPtrList<QCanvasSprite> rocks; | ||
107 | QPtrList<KMissile> missiles; | ||
108 | QPtrList<KBit> bits; | ||
109 | QPtrList<KExhaust> exhaust; | ||
110 | QPtrList<KPowerup> powerups; | ||
111 | KShield *shield; | ||
112 | QCanvasSprite *ship; | ||
113 | QCanvasText *textSprite; | ||
114 | |||
115 | bool rotateL; | ||
116 | bool rotateR; | ||
117 | bool thrustShip; | ||
118 | bool shootShip; | ||
119 | bool teleportShip; | ||
120 | bool brakeShip; | ||
121 | bool pauseShip; | ||
122 | bool shieldOn; | ||
123 | |||
124 | bool vitalsChanged; | ||
125 | |||
126 | int shipAngle; | ||
127 | int rotateSlow; | ||
128 | int rotateRate; | ||
129 | int shipPower; | ||
130 | |||
131 | int shotsFired; | ||
132 | int shotsHit; | ||
133 | int shootDelay; | ||
134 | |||
135 | int mBrakeCount; | ||
136 | int mShieldCount; | ||
137 | int mTeleportCount; | ||
138 | int mShootCount; | ||
139 | |||
140 | double shipDx; | ||
141 | double shipDy; | ||
142 | |||
143 | int textDy; | ||
144 | int mFrameNum; | ||
145 | bool mPaused; | ||
146 | int mTimerId; | ||
147 | |||
148 | double rockSpeed; | ||
149 | double powerupSpeed; | ||
150 | |||
151 | bool can_destroy_powerups; | ||
152 | |||
153 | QTimer *shieldTimer; | ||
154 | }; | ||
155 | |||
156 | #endif | ||