summaryrefslogtreecommitdiff
authorzecke <zecke>2004-11-15 14:28:50 (UTC)
committer zecke <zecke>2004-11-15 14:28:50 (UTC)
commitc9543dc4edd3ea586c04e8114e133296ad9529d9 (patch) (unidiff)
treea5031c6fed1808b69c174480430944f8377b88a2
parentf0c8746173f4cea9680b120bf823e77e7c8729b3 (diff)
downloadopie-c9543dc4edd3ea586c04e8114e133296ad9529d9.zip
opie-c9543dc4edd3ea586c04e8114e133296ad9529d9.tar.gz
opie-c9543dc4edd3ea586c04e8114e133296ad9529d9.tar.bz2
Make SFCave quick launchable
Diffstat (more/less context) (show whitespace changes)
-rw-r--r--noncore/games/sfcave/opie-sfcave.control2
-rw-r--r--noncore/games/sfcave/sfcave.cpp46
-rw-r--r--noncore/games/sfcave/sfcave.h8
-rw-r--r--noncore/games/sfcave/sfcave.pro5
4 files changed, 20 insertions, 41 deletions
diff --git a/noncore/games/sfcave/opie-sfcave.control b/noncore/games/sfcave/opie-sfcave.control
index 0ff3e2c..1d98a19 100644
--- a/noncore/games/sfcave/opie-sfcave.control
+++ b/noncore/games/sfcave/opie-sfcave.control
@@ -1,9 +1,9 @@
1Package: opie-sfcave 1Package: opie-sfcave
2Files: bin/sfcave apps/Games/sfcave.desktop pics/sfcave 2Files: plugins/applications/libsfcave.so* bin/sfcave apps/Games/sfcave.desktop pics/sfcave
3Priority: optional 3Priority: optional
4Section: opie/games 4Section: opie/games
5Maintainer: Andy Qua <andy.qua@blueyonder.co.uk> 5Maintainer: Andy Qua <andy.qua@blueyonder.co.uk>
6Architecture: arm 6Architecture: arm
7Depends: task-opie-minimal 7Depends: task-opie-minimal
8Description: SFCave for the Zaurus. Fly the dot though the cave avoiding the walls. 8Description: SFCave for the Zaurus. Fly the dot though the cave avoiding the walls.
9Version: $QPE_VERSION$EXTRAVERSION 9Version: $QPE_VERSION$EXTRAVERSION
diff --git a/noncore/games/sfcave/sfcave.cpp b/noncore/games/sfcave/sfcave.cpp
index 9b30fe6..5dca427 100644
--- a/noncore/games/sfcave/sfcave.cpp
+++ b/noncore/games/sfcave/sfcave.cpp
@@ -1,35 +1,33 @@
1#include <stdio.h> 1#include <stdio.h>
2#include <stdlib.h> 2#include <stdlib.h>
3#include <math.h> 3#include <math.h>
4#include <time.h> 4#include <time.h>
5 5
6#ifdef QWS 6#include <opie2/oapplicationfactory.h>
7#include <qpe/qpeapplication.h>
8#include <qpe/config.h> 7#include <qpe/config.h>
9#else 8
10#include <qapplication.h> 9#include <qapplication.h>
11#endif
12#include <qdir.h> 10#include <qdir.h>
13 11
14#include "helpwindow.h" 12#include "helpwindow.h"
15#include "sfcave.h" 13#include "sfcave.h"
16 14
17#define CAPTION "SFCave 1.13 by AndyQ" 15#define CAPTION "SFCave 1.13 by AndyQ"
18 16
19#define UP_THRUST 0.6 17#define UP_THRUST 0.6
20#define NO_THRUST 0.8 18#define NO_THRUST 0.8
21#define MAX_DOWN_THRUST 4.0 19#define MAX_DOWN_THRUST 4.0
22#define MAX_UP_THRUST -3.5 20#define MAX_UP_THRUST -3.5
23 21
24// States 22// States
25#define STATE_BOSS 0 23#define STATE_BOSS 0
26#define STATE_RUNNING 1 24#define STATE_RUNNING 1
27#define STATE_CRASHING 2 25#define STATE_CRASHING 2
28#define STATE_CRASHED 3 26#define STATE_CRASHED 3
29#define STATE_NEWGAME 4 27#define STATE_NEWGAME 4
30#define STATE_MENU 5 28#define STATE_MENU 5
31#define STATE_REPLAY 6 29#define STATE_REPLAY 6
32 30
33// Menus 31// Menus
34#define MENU_MAIN_MENU 0 32#define MENU_MAIN_MENU 0
35#define MENU_OPTIONS_MENU 1 33#define MENU_OPTIONS_MENU 1
@@ -111,129 +109,107 @@ int SFCave::flyEasyScores[7][3] = { { 0, 10, 5 },
111 { 50, 70, -2 }, 109 { 50, 70, -2 },
112 { 70, 300, -5 }, 110 { 70, 300, -5 },
113 { -1, -1, -1 } }; 111 { -1, -1, -1 } };
114int SFCave::flyNormalScores[7][3] = { { 0, 10, 5 }, 112int SFCave::flyNormalScores[7][3] = { { 0, 10, 5 },
115 { 10, 20, 3 }, 113 { 10, 20, 3 },
116 { 20, 30, 2 }, 114 { 20, 30, 2 },
117 { 30, 40, 1 }, 115 { 30, 40, 1 },
118 { 50, 70, -2 }, 116 { 50, 70, -2 },
119 { 70, 300, -5 }, 117 { 70, 300, -5 },
120 { -1, -1, -1 } }; 118 { -1, -1, -1 } };
121int SFCave::flyHardScores[7][3] = { { 0, 20, 5 }, 119int SFCave::flyHardScores[7][3] = { { 0, 20, 5 },
122 { 20, 40, 3 }, 120 { 20, 40, 3 },
123 { 40, 100, 1 }, 121 { 40, 100, 1 },
124 { 100, 150, -2 }, 122 { 100, 150, -2 },
125 { 150, 300, -5 }, 123 { 150, 300, -5 },
126 { -1, -1, -1 } }; 124 { -1, -1, -1 } };
127 125
128int SFCave::initialGateGaps[] = { 75, 50, 25 }; 126int SFCave::initialGateGaps[] = { 75, 50, 25 };
129 127
130 128
131#define FLYSCORES( x, y ) (*(flyScores + ((x)*3) + y)) 129#define FLYSCORES( x, y ) (*(flyScores + ((x)*3) + y))
132bool movel; 130bool movel;
133 131
134 132
135int main( int argc, char *argv[] ) 133OPIE_EXPORT_APP( Opie::Core::OApplicationFactory<SFCave> )
136{
137 movel = true;
138#ifdef QWS
139 QPEApplication a( argc, argv );
140#else
141 QApplication a( argc, argv );
142#endif
143 134
144 int speed = 3; 135SFCave :: SFCave( QWidget *w, const char *name, WFlags fl )
145 for ( int i = 0 ; i < argc ; ++i ) 136 : QMainWindow( w, name, fl )
146 {
147 if ( strcmp( argv[i], "-s" ) == 0 )
148 {
149 if ( i+1 < argc )
150 speed = atoi( argv[i+1] );
151 }
152 }
153 137
154 SFCave app( speed ); 138{
155 a.setMainWidget( &app ); 139 showMaximized();
156 app.show(); 140 movel = true;
157 app.start(); 141 int spd = 3;
158 a.exec();
159}
160 142
161SFCave :: SFCave( int spd, QWidget *w, char *name )
162 : QMainWindow( w, name )
163 143
164{
165 replayIt = 0; 144 replayIt = 0;
166#ifdef QWS
167 showMaximized();
168#else
169 resize( 240, 284 );
170#endif
171 145
172 replayFile = QDir::home().path(); 146 replayFile = QDir::home().path();
173 replayFile += "/sfcave.replay"; 147 replayFile += "/sfcave.replay";
174 printf( "%s\n", (const char *)replayFile ); 148 printf( "%s\n", (const char *)replayFile );
175 149
176 sWidth = width(); 150 sWidth = width();
177 sHeight = height(); 151 sHeight = height();
178 segSize = sWidth/(MAPSIZE-1)+1; 152 segSize = sWidth/(MAPSIZE-1)+1;
179 153
180 currentMenuNr = 0; 154 currentMenuNr = 0;
181 currentGameType = 0; 155 currentGameType = 0;
182 currentGameDifficulty = 0; 156 currentGameDifficulty = 0;
183 157
184 setCaption( CAPTION ); 158 setCaption( CAPTION );
185 showScoreZones = false; 159 showScoreZones = false;
186 160
187#ifdef QWS 161#ifdef QWS
188 Config cfg( "sfcave" ); 162 Config cfg( "sfcave" );
189 cfg.setGroup( "settings" ); 163 cfg.setGroup( "settings" );
190 QString key = "highScore_"; 164 QString key = "highScore_";
191 165
192 for ( int i = 0 ; i < 3 ; ++i ) 166 for ( int i = 0 ; i < 3 ; ++i )
193 { 167 {
194 for ( int j = 0 ; j < 3 ; ++j ) 168 for ( int j = 0 ; j < 3 ; ++j )
195 highestScore[i][j] = cfg.readNumEntry( key + gameTypes[i] + "_" + dificultyOption[j], 0 ); 169 highestScore[i][j] = cfg.readNumEntry( key + gameTypes[i] + "_" + dificultyOption[j], 0 );
196 } 170 }
197 171
198 currentGameType = cfg.readNumEntry( "gameType", 0 ); 172 currentGameType = cfg.readNumEntry( "gameType", 0 );
199 currentGameDifficulty = cfg.readNumEntry( "difficulty", 0 ); 173 currentGameDifficulty = cfg.readNumEntry( "difficulty", 0 );
200#endif 174#endif
201 speed = spd; // Change to 2 for PC 175 speed = spd; // Change to 2 for PC
202 press = false; 176 press = false;
203 showEyeCandy = false; 177 showEyeCandy = false;
204 178
205 offscreen = new QPixmap( sWidth, sHeight ); 179 offscreen = new QPixmap( sWidth, sHeight );
206 offscreen->fill( Qt::black ); 180 offscreen->fill( Qt::black );
207 181
208// setUp(); 182// setUp();
209 crashLineLength = -1; 183 crashLineLength = -1;
210 state = STATE_MENU; 184 state = STATE_MENU;
211 prevState = STATE_MENU; 185 prevState = STATE_MENU;
212 186
213 gameTimer = new QTimer( this, "game timer" ); 187 gameTimer = new QTimer( this, "game timer" );
214 connect( gameTimer, SIGNAL( timeout() ), 188 connect( gameTimer, SIGNAL( timeout() ),
215 this, SLOT( run() ) ); 189 this, SLOT( run() ) );
190
191 QTimer::singleShot(0, this, SLOT(start()));
216} 192}
217 193
218SFCave :: ~SFCave() 194SFCave :: ~SFCave()
219{ 195{
220} 196}
221 197
222void SFCave :: start() 198void SFCave :: start()
223{ 199{
224 gameTimer->start( 10 ); 200 gameTimer->start( 10 );
225 201
226} 202}
227 203
228void SFCave :: setSeed( int seed ) 204void SFCave :: setSeed( int seed )
229{ 205{
230 if ( seed == -1 ) 206 if ( seed == -1 )
231 currentSeed = ((unsigned long) time((time_t *) NULL)); 207 currentSeed = ((unsigned long) time((time_t *) NULL));
232 else 208 else
233 currentSeed = seed; 209 currentSeed = seed;
234 PutSeed( currentSeed ); 210 PutSeed( currentSeed );
235} 211}
236 212
237int SFCave :: nextInt( int range ) 213int SFCave :: nextInt( int range )
238{ 214{
239 int val = (int)(Random( ) * range); 215 int val = (int)(Random( ) * range);
diff --git a/noncore/games/sfcave/sfcave.h b/noncore/games/sfcave/sfcave.h
index b1fe819..7bdf881 100644
--- a/noncore/games/sfcave/sfcave.h
+++ b/noncore/games/sfcave/sfcave.h
@@ -74,51 +74,57 @@ public:
74 74
75 QPixmap *offscreen; 75 QPixmap *offscreen;
76 QTimer *gameTimer; 76 QTimer *gameTimer;
77 77
78 int score; 78 int score;
79 int highestScore[3][3]; 79 int highestScore[3][3];
80 80
81 int mapTop[MAPSIZE]; 81 int mapTop[MAPSIZE];
82 int mapBottom[MAPSIZE]; 82 int mapBottom[MAPSIZE];
83 QRect blocks[BLOCKSIZE]; 83 QRect blocks[BLOCKSIZE];
84 QRect user; 84 QRect user;
85 QPoint trail[TRAILSIZE]; 85 QPoint trail[TRAILSIZE];
86 86
87 int offset; 87 int offset;
88 int maxHeight; 88 int maxHeight;
89 int nrFrames; 89 int nrFrames;
90 int dir; 90 int dir;
91 91
92 bool showScoreZones; 92 bool showScoreZones;
93 93
94 bool press; 94 bool press;
95 double thrust; 95 double thrust;
96 bool running; 96 bool running;
97 97
98 SFCave( int speed = 3, QWidget *p = 0, char *name = 0 ); 98 SFCave( QWidget *p = 0, const char *name = 0, WFlags fl = 0 );
99 ~SFCave(); 99 ~SFCave();
100
101 static QString appName() { return QString::fromLatin1( QUICKAPP_NAME ); }
102
103public slots:
100 void start(); 104 void start();
105public:
106
101 void setSeed( int seed ); 107 void setSeed( int seed );
102 int nextInt( int range ); 108 int nextInt( int range );
103 void setUp(); 109 void setUp();
104 void handleGameSFCave(); 110 void handleGameSFCave();
105 void handleGameGates(); 111 void handleGameGates();
106 void handleGameFly(); 112 void handleGameFly();
107 bool checkFlyGameCollision(); 113 bool checkFlyGameCollision();
108 void moveFlyGameLandscape(); 114 void moveFlyGameLandscape();
109 void setFlyPoint( int point ); 115 void setFlyPoint( int point );
110 bool checkCollision(); 116 bool checkCollision();
111 void moveLandscape(); 117 void moveLandscape();
112 void addBlock(); 118 void addBlock();
113 void addGate(); 119 void addGate();
114 void setPoint( int point ); 120 void setPoint( int point );
115 void drawBoss(); 121 void drawBoss();
116 void draw(); 122 void draw();
117 void handleKeys(); 123 void handleKeys();
118 124
119 void handleMenuKeys( QKeyEvent * e ); 125 void handleMenuKeys( QKeyEvent * e );
120 void displayMenu(); 126 void displayMenu();
121 void dealWithMenuSelection(); 127 void dealWithMenuSelection();
122 128
123 void keyPressEvent( QKeyEvent *e ); 129 void keyPressEvent( QKeyEvent *e );
124 void keyReleaseEvent( QKeyEvent *e ); 130 void keyReleaseEvent( QKeyEvent *e );
diff --git a/noncore/games/sfcave/sfcave.pro b/noncore/games/sfcave/sfcave.pro
index a0df828..3a26a79 100644
--- a/noncore/games/sfcave/sfcave.pro
+++ b/noncore/games/sfcave/sfcave.pro
@@ -1,13 +1,10 @@
1 TEMPLATE= app 1 CONFIG += qt quick-app
2 CONFIG += qt warn_on
3 DESTDIR = $(OPIEDIR)/bin
4 SOURCES = sfcave.cpp helpwindow.cpp random.cpp 2 SOURCES = sfcave.cpp helpwindow.cpp random.cpp
5 HEADERS = sfcave.h helpwindow.h random.h 3 HEADERS = sfcave.h helpwindow.h random.h
6 TARGET = sfcave 4 TARGET = sfcave
7 INCLUDEPATH += $(OPIEDIR)/include 5 INCLUDEPATH += $(OPIEDIR)/include
8 DEPENDPATH+= $(OPIEDIR)/include 6 DEPENDPATH+= $(OPIEDIR)/include
9LIBS += -lqpe 7LIBS += -lqpe
10 8
11 9
12
13include ( $(OPIEDIR)/include.pro ) 10include ( $(OPIEDIR)/include.pro )