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
@@ -5,50 +5,51 @@
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 },
@@ -164,79 +165,79 @@ KAstTopLevel::KAstTopLevel( QWidget *parent, const char *_name, WFlags fl )
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) );
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
@@ -3,55 +3,55 @@
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
@@ -74,50 +74,49 @@ static const kas_animations_t kas_animations [] =
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
@@ -227,52 +226,49 @@ void KAsteroidsView::setShield( bool s )
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,