summaryrefslogtreecommitdiff
authordrw <drw>2005-05-18 14:28:05 (UTC)
committer drw <drw>2005-05-18 14:28:05 (UTC)
commitcb243f00d12c5fc40de02e7f9f20009b52303a66 (patch) (unidiff)
treef85e840af4db55a67a2a057d6a7f4ef59bfb4385
parent600f14a61969ec2edd6d89efecaac997b1c6464f (diff)
downloadopie-cb243f00d12c5fc40de02e7f9f20009b52303a66.zip
opie-cb243f00d12c5fc40de02e7f9f20009b52303a66.tar.gz
opie-cb243f00d12c5fc40de02e7f9f20009b52303a66.tar.bz2
Resource -> OResource
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/games/qasteroids/toplevel.cpp9
-rw-r--r--noncore/games/qasteroids/view.cpp14
2 files changed, 10 insertions, 13 deletions
diff --git a/noncore/games/qasteroids/toplevel.cpp b/noncore/games/qasteroids/toplevel.cpp
index 9053d3d..d1e1fac 100644
--- a/noncore/games/qasteroids/toplevel.cpp
+++ b/noncore/games/qasteroids/toplevel.cpp
@@ -1,78 +1,79 @@
1/********************************************************************** 1/**********************************************************************
2** Copyright (C) 2000 Trolltech AS. All rights reserved. 2** Copyright (C) 2000 Trolltech AS. All rights reserved.
3** 3**
4** This file is part of Qtopia Environment. 4** This file is part of Qtopia Environment.
5** 5**
6** This file may be distributed and/or modified under the terms of the 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 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 8** Foundation and appearing in the file LICENSE.GPL included in the
9** packaging of this file. 9** packaging of this file.
10** 10**
11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 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. 12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
13** 13**
14** See http://www.trolltech.com/gpl/ for GPL licensing information. 14** See http://www.trolltech.com/gpl/ for GPL licensing information.
15** 15**
16** Contact info@trolltech.com if any conditions of this licensing are 16** Contact info@trolltech.com if any conditions of this licensing are
17** not clear to you. 17** not clear to you.
18** 18**
19**********************************************************************//* 19**********************************************************************//*
20 * KAsteroids - Copyright (c) Martin R. Jones 1997 20 * KAsteroids - Copyright (c) Martin R. Jones 1997
21 * 21 *
22 * Part of the KDE project 22 * Part of the KDE project
23 */ 23 */
24 //--- toplevel.cpp --- 24 //--- toplevel.cpp ---
25 25
26#include "toplevel.h" 26#include "toplevel.h"
27#include "ledmeter.h" 27#include "ledmeter.h"
28 28
29#include <opie2/oresource.h>
30
29#include <qpe/qpeapplication.h> 31#include <qpe/qpeapplication.h>
30#include <qpe/resource.h>
31 32
32#include <qlabel.h> 33#include <qlabel.h>
33#include <qlayout.h> 34#include <qlayout.h>
34#include <qlcdnumber.h> 35#include <qlcdnumber.h>
35 36
36#include <sys/utsname.h> 37#include <sys/utsname.h>
37 38
38 39
39 #define SB_SCORE1 40 #define SB_SCORE1
40 #define SB_LEVEL2 41 #define SB_LEVEL2
41 #define SB_SHIPS3 42 #define SB_SHIPS3
42 43
43struct SLevel 44struct SLevel
44{ 45{
45 int nrocks; 46 int nrocks;
46 double rockSpeed; 47 double rockSpeed;
47}; 48};
48 49
49 #define MAX_LEVELS16 50 #define MAX_LEVELS16
50 51
51SLevel levels[MAX_LEVELS] = 52SLevel levels[MAX_LEVELS] =
52{ 53{
53 { 1, 0.4 }, 54 { 1, 0.4 },
54 { 1, 0.6 }, 55 { 1, 0.6 },
55 { 2, 0.5 }, 56 { 2, 0.5 },
56 { 2, 0.7 }, 57 { 2, 0.7 },
57 { 2, 0.8 }, 58 { 2, 0.8 },
58 { 3, 0.6 }, 59 { 3, 0.6 },
59 { 3, 0.7 }, 60 { 3, 0.7 },
60 { 3, 0.8 }, 61 { 3, 0.8 },
61 { 4, 0.6 }, 62 { 4, 0.6 },
62 { 4, 0.7 }, 63 { 4, 0.7 },
63 { 4, 0.8 }, 64 { 4, 0.8 },
64 { 5, 0.7 }, 65 { 5, 0.7 },
65 { 5, 0.8 }, 66 { 5, 0.8 },
66 { 5, 0.9 }, 67 { 5, 0.9 },
67 { 5, 1.0 } 68 { 5, 1.0 }
68}; 69};
69 70
70const char *soundEvents[] = 71const char *soundEvents[] =
71{ 72{
72 "ShipDestroyed", 73 "ShipDestroyed",
73 "RockDestroyed", 74 "RockDestroyed",
74 0 75 0
75}; 76};
76 77
77const char *soundDefaults[] = 78const char *soundDefaults[] =
78{ 79{
@@ -140,127 +141,127 @@ KAstTopLevel::KAstTopLevel( QWidget *parent, const char *_name, WFlags fl )
140 levelLCD = new QLCDNumber( 2, mainWin ); 141 levelLCD = new QLCDNumber( 2, mainWin );
141 levelLCD->setFrameStyle( QFrame::NoFrame ); 142 levelLCD->setFrameStyle( QFrame::NoFrame );
142 levelLCD->setSegmentStyle( QLCDNumber::Flat ); 143 levelLCD->setSegmentStyle( QLCDNumber::Flat );
143 levelLCD->setFixedHeight( 16 ); 144 levelLCD->setFixedHeight( 16 );
144 levelLCD->setPalette( pal ); 145 levelLCD->setPalette( pal );
145 hb->addWidget( levelLCD ); 146 hb->addWidget( levelLCD );
146 hb->addStretch( 1 ); 147 hb->addStretch( 1 );
147 148
148 label = new QLabel( tr("Ships"), mainWin ); 149 label = new QLabel( tr("Ships"), mainWin );
149 label->setFont( labelFont ); 150 label->setFont( labelFont );
150// label->setFixedWidth( label->sizeHint().width() ); 151// label->setFixedWidth( label->sizeHint().width() );
151 label->setPalette( pal ); 152 label->setPalette( pal );
152 hb->addWidget( label ); 153 hb->addWidget( label );
153 154
154 shipsLCD = new QLCDNumber( 1, mainWin ); 155 shipsLCD = new QLCDNumber( 1, mainWin );
155 shipsLCD->setFrameStyle( QFrame::NoFrame ); 156 shipsLCD->setFrameStyle( QFrame::NoFrame );
156 shipsLCD->setSegmentStyle( QLCDNumber::Flat ); 157 shipsLCD->setSegmentStyle( QLCDNumber::Flat );
157 shipsLCD->setFixedHeight( 16 ); 158 shipsLCD->setFixedHeight( 16 );
158 shipsLCD->setPalette( pal ); 159 shipsLCD->setPalette( pal );
159 hb->addWidget( shipsLCD ); 160 hb->addWidget( shipsLCD );
160 161
161// hb->addStrut( 14 ); 162// hb->addStrut( 14 );
162 163
163 vb->addWidget( view, 10 ); 164 vb->addWidget( view, 10 );
164 165
165// -- bottom layout: 166// -- bottom layout:
166 vb->addLayout( hbd ); 167 vb->addLayout( hbd );
167 168
168 QFont smallFont( "helvetica", 12 ); 169 QFont smallFont( "helvetica", 12 );
169 hbd->addSpacing( 5 ); 170 hbd->addSpacing( 5 );
170 171
171/* 172/*
172 label = new QLabel( tr( "T" ), mainWin ); 173 label = new QLabel( tr( "T" ), mainWin );
173 label->setFont( smallFont ); 174 label->setFont( smallFont );
174 label->setFixedWidth( label->sizeHint().width() ); 175 label->setFixedWidth( label->sizeHint().width() );
175 label->setPalette( pal ); 176 label->setPalette( pal );
176 hbd->addWidget( label ); 177 hbd->addWidget( label );
177 178
178 teleportsLCD = new QLCDNumber( 1, mainWin ); 179 teleportsLCD = new QLCDNumber( 1, mainWin );
179 teleportsLCD->setFrameStyle( QFrame::NoFrame ); 180 teleportsLCD->setFrameStyle( QFrame::NoFrame );
180 teleportsLCD->setSegmentStyle( QLCDNumber::Flat ); 181 teleportsLCD->setSegmentStyle( QLCDNumber::Flat );
181 teleportsLCD->setPalette( pal ); 182 teleportsLCD->setPalette( pal );
182 teleportsLCD->setFixedHeight( 18 ); 183 teleportsLCD->setFixedHeight( 18 );
183 hbd->addWidget( teleportsLCD ); 184 hbd->addWidget( teleportsLCD );
184 185
185 hbd->addSpacing( 10 ); 186 hbd->addSpacing( 10 );
186*/ 187*/
187 label = new QLabel( mainWin ); 188 label = new QLabel( mainWin );
188 label->setPixmap( Resource::loadPixmap("qasteroids/powerups/brake.png") ); 189 label->setPixmap( Opie::Core::OResource::loadPixmap("qasteroids/powerups/brake.png") );
189 label->setFixedWidth( 16 ); 190 label->setFixedWidth( 16 );
190 label->setPalette( pal ); 191 label->setPalette( pal );
191 hbd->addWidget( label ); 192 hbd->addWidget( label );
192 193
193 brakesLCD = new QLCDNumber( 1, mainWin ); 194 brakesLCD = new QLCDNumber( 1, mainWin );
194 brakesLCD->setFrameStyle( QFrame::NoFrame ); 195 brakesLCD->setFrameStyle( QFrame::NoFrame );
195 brakesLCD->setSegmentStyle( QLCDNumber::Flat ); 196 brakesLCD->setSegmentStyle( QLCDNumber::Flat );
196 brakesLCD->setPalette( pal ); 197 brakesLCD->setPalette( pal );
197 brakesLCD->setFixedHeight( 16 ); 198 brakesLCD->setFixedHeight( 16 );
198 hbd->addWidget( brakesLCD ); 199 hbd->addWidget( brakesLCD );
199 200
200 hbd->addSpacing( 5 ); 201 hbd->addSpacing( 5 );
201 202
202 label = new QLabel( mainWin ); 203 label = new QLabel( mainWin );
203 label->setPixmap( Resource::loadPixmap("qasteroids/powerups/shield.png") ); 204 label->setPixmap( Opie::Core::OResource::loadPixmap("qasteroids/powerups/shield.png") );
204 label->setFixedWidth( 16 ); 205 label->setFixedWidth( 16 );
205 label->setPalette( pal ); 206 label->setPalette( pal );
206 hbd->addWidget( label ); 207 hbd->addWidget( label );
207 208
208 shieldLCD = new QLCDNumber( 1, mainWin ); 209 shieldLCD = new QLCDNumber( 1, mainWin );
209 shieldLCD->setFrameStyle( QFrame::NoFrame ); 210 shieldLCD->setFrameStyle( QFrame::NoFrame );
210 shieldLCD->setSegmentStyle( QLCDNumber::Flat ); 211 shieldLCD->setSegmentStyle( QLCDNumber::Flat );
211 shieldLCD->setPalette( pal ); 212 shieldLCD->setPalette( pal );
212 shieldLCD->setFixedHeight( 16 ); 213 shieldLCD->setFixedHeight( 16 );
213 hbd->addWidget( shieldLCD ); 214 hbd->addWidget( shieldLCD );
214 215
215 hbd->addSpacing( 5 ); 216 hbd->addSpacing( 5 );
216 217
217 label = new QLabel( mainWin ); 218 label = new QLabel( mainWin );
218 label->setPixmap( Resource::loadPixmap("qasteroids/powerups/shoot.png") ); 219 label->setPixmap( Opie::Core::OResource::loadPixmap("qasteroids/powerups/shoot.png") );
219 label->setFixedWidth( 16 ); 220 label->setFixedWidth( 16 );
220 label->setPalette( pal ); 221 label->setPalette( pal );
221 hbd->addWidget( label ); 222 hbd->addWidget( label );
222 223
223 shootLCD = new QLCDNumber( 1, mainWin ); 224 shootLCD = new QLCDNumber( 1, mainWin );
224 shootLCD->setFrameStyle( QFrame::NoFrame ); 225 shootLCD->setFrameStyle( QFrame::NoFrame );
225 shootLCD->setSegmentStyle( QLCDNumber::Flat ); 226 shootLCD->setSegmentStyle( QLCDNumber::Flat );
226 shootLCD->setPalette( pal ); 227 shootLCD->setPalette( pal );
227 shootLCD->setFixedHeight( 16 ); 228 shootLCD->setFixedHeight( 16 );
228 hbd->addWidget( shootLCD ); 229 hbd->addWidget( shootLCD );
229 230
230 hbd->addStretch( 1 ); 231 hbd->addStretch( 1 );
231 232
232 label = new QLabel( tr( "Fuel" ), mainWin ); 233 label = new QLabel( tr( "Fuel" ), mainWin );
233 label->setFont( smallFont ); 234 label->setFont( smallFont );
234 label->setFixedWidth( label->sizeHint().width() + 5 ); 235 label->setFixedWidth( label->sizeHint().width() + 5 );
235 label->setPalette( pal ); 236 label->setPalette( pal );
236 hbd->addWidget( label ); 237 hbd->addWidget( label );
237 238
238 powerMeter = new KALedMeter( mainWin ); 239 powerMeter = new KALedMeter( mainWin );
239 powerMeter->setFrameStyle( QFrame::Box | QFrame::Plain ); 240 powerMeter->setFrameStyle( QFrame::Box | QFrame::Plain );
240 powerMeter->setRange( MAX_POWER_LEVEL ); 241 powerMeter->setRange( MAX_POWER_LEVEL );
241 powerMeter->addColorRange( 10, darkRed ); 242 powerMeter->addColorRange( 10, darkRed );
242 powerMeter->addColorRange( 20, QColor(160, 96, 0) ); 243 powerMeter->addColorRange( 20, QColor(160, 96, 0) );
243 powerMeter->addColorRange( 70, darkGreen ); 244 powerMeter->addColorRange( 70, darkGreen );
244 powerMeter->setCount( 15 ); 245 powerMeter->setCount( 15 );
245 powerMeter->setPalette( pal ); 246 powerMeter->setPalette( pal );
246 powerMeter->setFixedSize( 60, 12 ); 247 powerMeter->setFixedSize( 60, 12 );
247 hbd->addWidget( powerMeter ); 248 hbd->addWidget( powerMeter );
248 249
249 shipsRemain = 3; 250 shipsRemain = 3;
250 showHiscores = FALSE; 251 showHiscores = FALSE;
251 252
252 actions.insert( Qt::Key_Up, Thrust ); 253 actions.insert( Qt::Key_Up, Thrust );
253 actions.insert( Qt::Key_Left, RotateLeft ); 254 actions.insert( Qt::Key_Left, RotateLeft );
254 actions.insert( Qt::Key_Right, RotateRight ); 255 actions.insert( Qt::Key_Right, RotateRight );
255 actions.insert( Qt::Key_Enter, Shoot ); 256 actions.insert( Qt::Key_Enter, Shoot );
256 actions.insert( Qt::Key_Z, Teleport ); 257 actions.insert( Qt::Key_Z, Teleport );
257 actions.insert( Qt::Key_Down, Brake ); 258 actions.insert( Qt::Key_Down, Brake );
258 actions.insert( Qt::Key_P, Pause ); 259 actions.insert( Qt::Key_P, Pause );
259 260
260 261
261 struct utsname name; /* check for embedix kernel running on the zaurus, if 262 struct utsname name; /* check for embedix kernel running on the zaurus, if
262 lineo change string, this break 263 lineo change string, this break
263 */ 264 */
264 if (uname(&name) != -1) { 265 if (uname(&name) != -1) {
265 QString release=name.release; 266 QString release=name.release;
266 if(release.find("embedix",0,TRUE) !=-1) { 267 if(release.find("embedix",0,TRUE) !=-1) {
diff --git a/noncore/games/qasteroids/view.cpp b/noncore/games/qasteroids/view.cpp
index 3a4d410..6cab700 100644
--- a/noncore/games/qasteroids/view.cpp
+++ b/noncore/games/qasteroids/view.cpp
@@ -1,147 +1,146 @@
1/********************************************************************** 1/**********************************************************************
2** Copyright (C) 2000 Trolltech AS. All rights reserved. 2** Copyright (C) 2000 Trolltech AS. All rights reserved.
3** 3**
4** This file is part of Qtopia Environment. 4** This file is part of Qtopia Environment.
5** 5**
6** This file may be distributed and/or modified under the terms of the 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 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 8** Foundation and appearing in the file LICENSE.GPL included in the
9** packaging of this file. 9** packaging of this file.
10** 10**
11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 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. 12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
13** 13**
14** See http://www.trolltech.com/gpl/ for GPL licensing information. 14** See http://www.trolltech.com/gpl/ for GPL licensing information.
15** 15**
16** Contact info@trolltech.com if any conditions of this licensing are 16** Contact info@trolltech.com if any conditions of this licensing are
17** not clear to you. 17** not clear to you.
18** 18**
19**********************************************************************//* 19**********************************************************************//*
20 * KAsteroids - Copyright (c) Martin R. Jones 1997 20 * KAsteroids - Copyright (c) Martin R. Jones 1997
21 * 21 *
22 * Part of the KDE project 22 * Part of the KDE project
23 */ 23 */
24 24
25#include "view.h" 25#include "view.h"
26 26
27#include <qpe/resource.h> 27#include <opie2/oresource.h>
28 28#include <qpe/qpeapplication.h>
29 29
30#include <stdlib.h> 30#include <stdlib.h>
31#include <math.h> 31#include <math.h>
32 32
33#define IMG_BACKGROUND "qasteroids/bg.png" 33#define IMG_BACKGROUND "qasteroids/bg"
34 34
35#define REFRESH_DELAY 33 35#define REFRESH_DELAY 33
36#define SHIP_SPEED 0.3 36#define SHIP_SPEED 0.3
37#define MISSILE_SPEED 10.0 37#define MISSILE_SPEED 10.0
38#define SHIP_STEPS 64 38#define SHIP_STEPS 64
39#define ROTATE_RATE 2 39#define ROTATE_RATE 2
40#define SHIELD_ON_COST 1 40#define SHIELD_ON_COST 1
41#define SHIELD_HIT_COST 30 41#define SHIELD_HIT_COST 30
42#define BRAKE_ON_COST 4 42#define BRAKE_ON_COST 4
43 43
44#define MAX_ROCK_SPEED 2.5 44#define MAX_ROCK_SPEED 2.5
45#define MAX_POWERUP_SPEED 1.5 45#define MAX_POWERUP_SPEED 1.5
46 #define MAX_SHIP_SPEED 8 46 #define MAX_SHIP_SPEED 8
47#define MAX_BRAKES 5 47#define MAX_BRAKES 5
48#define MAX_SHIELDS 5 48#define MAX_SHIELDS 5
49 #define MAX_FIREPOWER 5 49 #define MAX_FIREPOWER 5
50 50
51#define TEXT_SPEED 4 51#define TEXT_SPEED 4
52 52
53#define PI_X_2 6.283185307 53#define PI_X_2 6.283185307
54#ifndef M_PI 54#ifndef M_PI
55#define M_PI 3.141592654 55#define M_PI 3.141592654
56#endif 56#endif
57 57
58struct kas_animations_t 58struct kas_animations_t
59{ 59{
60 int id; 60 int id;
61 const char *path; 61 const char *path;
62 int frames; 62 int frames;
63}; 63};
64 64
65static const kas_animations_t kas_animations [] = 65static const kas_animations_t kas_animations [] =
66{ 66{
67// { ID_ROCK_LARGE, "rock1/rock1\%1.png", 32 }, 67// { ID_ROCK_LARGE, "rock1/rock1\%1.png", 32 },
68 { ID_ROCK_MEDIUM, "rock2/rock2\%1.png", 32 }, 68 { ID_ROCK_MEDIUM, "rock2/rock2\%1.png", 32 },
69 { ID_ROCK_SMALL, "rock3/rock3\%1.png", 32 }, 69 { ID_ROCK_SMALL, "rock3/rock3\%1.png", 32 },
70 { ID_SHIP, "ship/ship\%1.png", 32 }, 70 { ID_SHIP, "ship/ship\%1.png", 32 },
71 { ID_MISSILE, "missile/missile.png", 0 }, 71 { ID_MISSILE, "missile/missile.png", 0 },
72 { ID_BIT, "bits/bits\%1.png", 16 }, 72 { ID_BIT, "bits/bits\%1.png", 16 },
73 { ID_EXHAUST, "exhaust/exhaust.png", 0 }, 73 { ID_EXHAUST, "exhaust/exhaust.png", 0 },
74 { ID_ENERGY_POWERUP, "powerups/energy.png", 0 }, 74 { ID_ENERGY_POWERUP, "powerups/energy.png", 0 },
75// { ID_TELEPORT_POWERUP, "powerups/teleport%1.png", 12 }, 75// { ID_TELEPORT_POWERUP, "powerups/teleport%1.png", 12 },
76 { ID_BRAKE_POWERUP, "powerups/brake.png", 0 }, 76 { ID_BRAKE_POWERUP, "powerups/brake.png", 0 },
77 { ID_SHIELD_POWERUP, "powerups/shield.png", 0 }, 77 { ID_SHIELD_POWERUP, "powerups/shield.png", 0 },
78 { ID_SHOOT_POWERUP, "powerups/shoot.png", 0 }, 78 { ID_SHOOT_POWERUP, "powerups/shoot.png", 0 },
79 { ID_SHIELD, "shield/shield\%1.png", 6 }, 79 { ID_SHIELD, "shield/shield\%1.png", 6 },
80 { 0, 0, 0 } 80 { 0, 0, 0 }
81}; 81};
82 82
83 83
84 84
85KAsteroidsView::KAsteroidsView( QWidget *parent, const char *name ) 85KAsteroidsView::KAsteroidsView( QWidget *parent, const char *name )
86 : QWidget( parent, name ), 86 : QWidget( parent, name ),
87 field(200, 200), 87 field(200, 200),
88 view(&field,this) 88 view(&field,this)
89{ 89{
90 view.setVScrollBarMode( QScrollView::AlwaysOff ); 90 view.setVScrollBarMode( QScrollView::AlwaysOff );
91 view.setHScrollBarMode( QScrollView::AlwaysOff ); 91 view.setHScrollBarMode( QScrollView::AlwaysOff );
92 rocks.setAutoDelete( TRUE ); 92 rocks.setAutoDelete( TRUE );
93 missiles.setAutoDelete( TRUE ); 93 missiles.setAutoDelete( TRUE );
94 bits.setAutoDelete( TRUE ); 94 bits.setAutoDelete( TRUE );
95 powerups.setAutoDelete( TRUE ); 95 powerups.setAutoDelete( TRUE );
96 exhaust.setAutoDelete( TRUE ); 96 exhaust.setAutoDelete( TRUE );
97 97
98 QPixmap pm( Resource::loadPixmap(IMG_BACKGROUND) ); 98 field.setBackgroundPixmap( Opie::Core::OResource::loadPixmap(IMG_BACKGROUND) );
99 field.setBackgroundPixmap( pm );
100 99
101 textSprite = new QCanvasText( &field ); 100 textSprite = new QCanvasText( &field );
102 QFont font( "helvetica", 14 ); 101 QFont font( "helvetica", 14 );
103 textSprite->setFont( font ); 102 textSprite->setFont( font );
104 103
105 shield = 0; 104 shield = 0;
106 shieldOn = FALSE; 105 shieldOn = FALSE;
107 refreshRate = REFRESH_DELAY; 106 refreshRate = REFRESH_DELAY;
108 107
109 readSprites(); 108 readSprites();
110 109
111 shieldTimer = new QTimer( this ); 110 shieldTimer = new QTimer( this );
112 connect( shieldTimer, SIGNAL(timeout()), this, SLOT(hideShield()) ); 111 connect( shieldTimer, SIGNAL(timeout()), this, SLOT(hideShield()) );
113 mTimerId = -1; 112 mTimerId = -1;
114 113
115 shipPower = MAX_POWER_LEVEL; 114 shipPower = MAX_POWER_LEVEL;
116 vitalsChanged = TRUE; 115 vitalsChanged = TRUE;
117 can_destroy_powerups = FALSE; 116 can_destroy_powerups = FALSE;
118 117
119 mPaused = TRUE; 118 mPaused = TRUE;
120} 119}
121 120
122// - - - 121// - - -
123 122
124KAsteroidsView::~KAsteroidsView() 123KAsteroidsView::~KAsteroidsView()
125{ 124{
126} 125}
127 126
128// - - - 127// - - -
129 128
130void KAsteroidsView::reset() 129void KAsteroidsView::reset()
131{ 130{
132 rocks.clear(); 131 rocks.clear();
133 missiles.clear(); 132 missiles.clear();
134 bits.clear(); 133 bits.clear();
135 powerups.clear(); 134 powerups.clear();
136 exhaust.clear(); 135 exhaust.clear();
137 136
138 shotsFired = 0; 137 shotsFired = 0;
139 shotsHit = 0; 138 shotsHit = 0;
140 139
141 rockSpeed = 1.0; 140 rockSpeed = 1.0;
142 powerupSpeed = 1.0; 141 powerupSpeed = 1.0;
143 mFrameNum = 0; 142 mFrameNum = 0;
144 mPaused = FALSE; 143 mPaused = FALSE;
145 144
146 ship->hide(); 145 ship->hide();
147 shield->hide(); 146 shield->hide();
@@ -203,100 +202,97 @@ void KAsteroidsView::newShip()
203 brakeShip = FALSE; 202 brakeShip = FALSE;
204 teleportShip = FALSE; 203 teleportShip = FALSE;
205 shieldOn = TRUE; 204 shieldOn = TRUE;
206 shootDelay = 0; 205 shootDelay = 0;
207 shipPower = MAX_POWER_LEVEL; 206 shipPower = MAX_POWER_LEVEL;
208 rotateRate = ROTATE_RATE; 207 rotateRate = ROTATE_RATE;
209 rotateSlow = 0; 208 rotateSlow = 0;
210 209
211 mBrakeCount = 0; 210 mBrakeCount = 0;
212 mTeleportCount = 0; 211 mTeleportCount = 0;
213 mShootCount = 0; 212 mShootCount = 0;
214 213
215 ship->show(); 214 ship->show();
216 shield->show(); 215 shield->show();
217 mShieldCount = 1; // just in case the ship appears on a rock. 216 mShieldCount = 1; // just in case the ship appears on a rock.
218 shieldTimer->start( 1000, TRUE ); 217 shieldTimer->start( 1000, TRUE );
219} 218}
220 219
221void KAsteroidsView::setShield( bool s ) 220void KAsteroidsView::setShield( bool s )
222{ 221{
223 if ( shieldTimer->isActive() && !s ) { 222 if ( shieldTimer->isActive() && !s ) {
224 shieldTimer->stop(); 223 shieldTimer->stop();
225 hideShield(); 224 hideShield();
226 } else { 225 } else {
227 shieldOn = s && mShieldCount; 226 shieldOn = s && mShieldCount;
228 } 227 }
229} 228}
230 229
231void KAsteroidsView::brake( bool b ) 230void KAsteroidsView::brake( bool b )
232{ 231{
233 if ( mBrakeCount ) 232 if ( mBrakeCount )
234 { 233 {
235 if ( brakeShip && !b ) 234 if ( brakeShip && !b )
236 { 235 {
237 rotateL = FALSE; 236 rotateL = FALSE;
238 rotateR = FALSE; 237 rotateR = FALSE;
239 thrustShip = FALSE; 238 thrustShip = FALSE;
240 rotateRate = ROTATE_RATE; 239 rotateRate = ROTATE_RATE;
241 } 240 }
242 241
243 brakeShip = b; 242 brakeShip = b;
244 } 243 }
245} 244}
246 245
247// - - - 246// - - -
248 247
249void KAsteroidsView::readSprites() 248void KAsteroidsView::readSprites()
250{ 249{
251 QString sprites_prefix = Resource::findPixmap( IMG_BACKGROUND ); 250 QString sprites_prefix = QPEApplication::qpeDir() + "pics/qasteroids";
252 int sep = sprites_prefix.findRev( "/" );
253
254 sprites_prefix.truncate( sep );
255 251
256 int i = 0; 252 int i = 0;
257 while ( kas_animations[i].id ) 253 while ( kas_animations[i].id )
258 { 254 {
259 animation.insert( kas_animations[i].id, 255 animation.insert( kas_animations[i].id,
260 new QCanvasPixmapArray( sprites_prefix + "/" + kas_animations[i].path, 256 new QCanvasPixmapArray( sprites_prefix + "/" + kas_animations[i].path,
261 kas_animations[i].frames ) ); 257 kas_animations[i].frames ) );
262 i++; 258 i++;
263 } 259 }
264 260
265 ship = new QCanvasSprite( animation[ID_SHIP], &field ); 261 ship = new QCanvasSprite( animation[ID_SHIP], &field );
266 ship->hide(); 262 ship->hide();
267 263
268 shield = new KShield( animation[ID_SHIELD], &field ); 264 shield = new KShield( animation[ID_SHIELD], &field );
269 shield->hide(); 265 shield->hide();
270} 266}
271 267
272// - - - 268// - - -
273 269
274void KAsteroidsView::addRocks( int num ) 270void KAsteroidsView::addRocks( int num )
275{ 271{
276 for ( int i = 0; i < num; i++ ) 272 for ( int i = 0; i < num; i++ )
277 { 273 {
278 KRock *rock = new KRock( animation[ID_ROCK_MEDIUM], &field, 274 KRock *rock = new KRock( animation[ID_ROCK_MEDIUM], &field,
279 ID_ROCK_MEDIUM, randInt(2), randInt(2) ? -1 : 1 ); 275 ID_ROCK_MEDIUM, randInt(2), randInt(2) ? -1 : 1 );
280 double dx = (2.0 - randDouble()*4.0) * rockSpeed; 276 double dx = (2.0 - randDouble()*4.0) * rockSpeed;
281 double dy = (2.0 - randDouble()*4.0) * rockSpeed; 277 double dy = (2.0 - randDouble()*4.0) * rockSpeed;
282 rock->setVelocity( dx, dy ); 278 rock->setVelocity( dx, dy );
283 rock->setFrame( randInt( rock->frameCount() ) ); 279 rock->setFrame( randInt( rock->frameCount() ) );
284 if ( dx > 0 ) 280 if ( dx > 0 )
285 { 281 {
286 if ( dy > 0 ) 282 if ( dy > 0 )
287 rock->move( 5, 5, 0 ); 283 rock->move( 5, 5, 0 );
288 else 284 else
289 rock->move( 5, field.height() - 25, 0 ); 285 rock->move( 5, field.height() - 25, 0 );
290 } 286 }
291 else 287 else
292 { 288 {
293 if ( dy > 0 ) 289 if ( dy > 0 )
294 rock->move( field.width() - 25, 5, 0 ); 290 rock->move( field.width() - 25, 5, 0 );
295 else 291 else
296 rock->move( field.width() - 25, field.height() - 25, 0 ); 292 rock->move( field.width() - 25, field.height() - 25, 0 );
297 } 293 }
298 rock->show( ); 294 rock->show( );
299 rocks.append( rock ); 295 rocks.append( rock );
300 } 296 }
301} 297}
302 298