summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/games/sfcave/opie-sfcave.control2
-rw-r--r--noncore/games/sfcave/sfcave.cpp48
-rw-r--r--noncore/games/sfcave/sfcave.h8
-rw-r--r--noncore/games/sfcave/sfcave.pro5
4 files changed, 21 insertions, 42 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,727 +1,703 @@
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
36#define MENU_REPLAY_MENU 2 34#define MENU_REPLAY_MENU 2
37 35
38// Main Menu Options 36// Main Menu Options
39#define MENU_START_GAME 0 37#define MENU_START_GAME 0
40#define MENU_REPLAY 1 38#define MENU_REPLAY 1
41#define MENU_OPTIONS 2 39#define MENU_OPTIONS 2
42#define MENU_HELP 3 40#define MENU_HELP 3
43#define MENU_QUIT 4 41#define MENU_QUIT 4
44 42
45// Option Menu Options 43// Option Menu Options
46#define MENU_GAME_TYPE 0 44#define MENU_GAME_TYPE 0
47#define MENU_GAME_DIFFICULTY 1 45#define MENU_GAME_DIFFICULTY 1
48#define MENU_CLEAR_HIGHSCORES 2 46#define MENU_CLEAR_HIGHSCORES 2
49#define MENU_BACK 3 47#define MENU_BACK 3
50 48
51// Replay Menu Options 49// Replay Menu Options
52#define MENU_REPLAY_START 0 50#define MENU_REPLAY_START 0
53#define MENU_REPLAY_LOAD 1 51#define MENU_REPLAY_LOAD 1
54#define MENU_REPLAY_SAVE 2 52#define MENU_REPLAY_SAVE 2
55#define MENU_REPLAY_BACK 3 53#define MENU_REPLAY_BACK 3
56 54
57 55
58#define NR_GAME_DIFFICULTIES 3 56#define NR_GAME_DIFFICULTIES 3
59#define NR_GAME_TYPES 3 57#define NR_GAME_TYPES 3
60 58
61#define DIFICULTY_EASY 0 59#define DIFICULTY_EASY 0
62#define DIFICULTY_NORMAL 1 60#define DIFICULTY_NORMAL 1
63#define DIFICULTY_HARD 2 61#define DIFICULTY_HARD 2
64#define EASY "Easy" 62#define EASY "Easy"
65#define NORMAL "Normal" 63#define NORMAL "Normal"
66#define HARD "Hard" 64#define HARD "Hard"
67 65
68#define SFCAVE_GAME_TYPE 0 66#define SFCAVE_GAME_TYPE 0
69#define GATES_GAME_TYPE 1 67#define GATES_GAME_TYPE 1
70#define FLY_GAME_TYPE 2 68#define FLY_GAME_TYPE 2
71#define SFCAVE_GAME "SFCave" 69#define SFCAVE_GAME "SFCave"
72#define GATES_GAME "Gates" 70#define GATES_GAME "Gates"
73#define FLY_GAME "Fly" 71#define FLY_GAME "Fly"
74#define CURRENT_GAME_TYPE gameTypes[currentGameType] 72#define CURRENT_GAME_TYPE gameTypes[currentGameType]
75#define CURRENT_GAME_DIFFICULTY difficultyOption[currentGameDifficulty]; 73#define CURRENT_GAME_DIFFICULTY difficultyOption[currentGameDifficulty];
76 74
77QString SFCave::dificultyOption[] = { EASY, NORMAL, HARD }; 75QString SFCave::dificultyOption[] = { EASY, NORMAL, HARD };
78QString SFCave::gameTypes[] = { SFCAVE_GAME, GATES_GAME, FLY_GAME }; 76QString SFCave::gameTypes[] = { SFCAVE_GAME, GATES_GAME, FLY_GAME };
79 77
80QString SFCave::menuOptions[NR_MENUS][MAX_MENU_OPTIONS] = { { "Start Game", "Replays", "Options", "Help", "Quit", "", "", "" }, 78QString SFCave::menuOptions[NR_MENUS][MAX_MENU_OPTIONS] = { { "Start Game", "Replays", "Options", "Help", "Quit", "", "", "" },
81 { "Game Type - %s", "Game Difficulty - %s", "Clear High Scores for this game", "Back", "", "", "", "" }, 79 { "Game Type - %s", "Game Difficulty - %s", "Clear High Scores for this game", "Back", "", "", "", "" },
82 { "Play Reply", "Load Replay", "Save Replay", "Back", "", "", "", "" } }; 80 { "Play Reply", "Load Replay", "Save Replay", "Back", "", "", "", "" } };
83 81
84int SFCave::nrMenuOptions[NR_MENUS] = { 5, 4, 4 }; 82int SFCave::nrMenuOptions[NR_MENUS] = { 5, 4, 4 };
85int SFCave ::currentMenuOption[NR_MENUS] = { 0, 0, 0 }; 83int SFCave ::currentMenuOption[NR_MENUS] = { 0, 0, 0 };
86 84
87#define UP_THRUST 0.6 85#define UP_THRUST 0.6
88#define NO_THRUST 0.8 86#define NO_THRUST 0.8
89#define MAX_DOWN_THRUST 4.0 87#define MAX_DOWN_THRUST 4.0
90#define MAX_UP_THRUST -3.5 88#define MAX_UP_THRUST -3.5
91double SFCave::UpThrustVals[3][3] = {{ 0.6, 0.6, 0.6 }, // SFCave 89double SFCave::UpThrustVals[3][3] = {{ 0.6, 0.6, 0.6 }, // SFCave
92 { 0.6, 0.6, 0.8 }, // Gates 90 { 0.6, 0.6, 0.8 }, // Gates
93 { 0.4, 0.7, 1.0 } }; // Fly 91 { 0.4, 0.7, 1.0 } }; // Fly
94 92
95double SFCave::DownThrustVals[3][3] = {{ 0.8, 0.8, 0.8 }, // SFCave 93double SFCave::DownThrustVals[3][3] = {{ 0.8, 0.8, 0.8 }, // SFCave
96 { 0.8, 0.8, 1.0 }, // Gates 94 { 0.8, 0.8, 1.0 }, // Gates
97 { 0.4, 0.7, 1.0 } }; // Fly 95 { 0.4, 0.7, 1.0 } }; // Fly
98 96
99double SFCave::MaxUpThrustVals[3][3] = {{ -3.5, -3.5, -3.5 }, // SFCave 97double SFCave::MaxUpThrustVals[3][3] = {{ -3.5, -3.5, -3.5 }, // SFCave
100 { -3.5, -4.0, -5.0 }, // Gates 98 { -3.5, -4.0, -5.0 }, // Gates
101 { -3.5, -4.0, -5.0 } }; // Fly 99 { -3.5, -4.0, -5.0 } }; // Fly
102 100
103double SFCave::MaxDownThrustVals[3][3] = {{ 4.0, 4.0, 4.0 }, // SFCave 101double SFCave::MaxDownThrustVals[3][3] = {{ 4.0, 4.0, 4.0 }, // SFCave
104 { 4.0, 5.0, 5.5 }, // Gates 102 { 4.0, 5.0, 5.5 }, // Gates
105 { 3.5, 4.0, 5.0 } }; // Fly 103 { 3.5, 4.0, 5.0 } }; // Fly
106 104
107int SFCave::flyEasyScores[7][3] = { { 0, 10, 5 }, 105int SFCave::flyEasyScores[7][3] = { { 0, 10, 5 },
108 { 10, 20, 3 }, 106 { 10, 20, 3 },
109 { 20, 30, 2 }, 107 { 20, 30, 2 },
110 { 30, 40, 1 }, 108 { 30, 40, 1 },
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
154 SFCave app( speed );
155 a.setMainWidget( &app );
156 app.show();
157 app.start();
158 a.exec();
159}
160
161SFCave :: SFCave( int spd, QWidget *w, char *name )
162 : QMainWindow( w, name )
163 137
164{ 138{
165 replayIt = 0;
166#ifdef QWS
167 showMaximized(); 139 showMaximized();
168#else 140 movel = true;
169 resize( 240, 284 ); 141 int spd = 3;
170#endif 142
143
144 replayIt = 0;
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);
240 216
241 return val; 217 return val;
242 218
243} 219}
244 220
245void SFCave :: setUp() 221void SFCave :: setUp()
246{ 222{
247 score = 0; 223 score = 0;
248 offset = 0; 224 offset = 0;
249 nrFrames = 0; 225 nrFrames = 0;
250 dir = 1; 226 dir = 1;
251 thrust = 0; 227 thrust = 0;
252 startScoring = false; 228 startScoring = false;
253 press = false; 229 press = false;
254 230
255 if ( CURRENT_GAME_TYPE == SFCAVE_GAME ) 231 if ( CURRENT_GAME_TYPE == SFCAVE_GAME )
256 { 232 {
257 thrustUp = UpThrustVals[SFCAVE_GAME_TYPE][currentGameDifficulty];; 233 thrustUp = UpThrustVals[SFCAVE_GAME_TYPE][currentGameDifficulty];;
258 noThrust = DownThrustVals[SFCAVE_GAME_TYPE][currentGameDifficulty];; 234 noThrust = DownThrustVals[SFCAVE_GAME_TYPE][currentGameDifficulty];;
259 maxUpThrust = MaxUpThrustVals[SFCAVE_GAME_TYPE][currentGameDifficulty];; 235 maxUpThrust = MaxUpThrustVals[SFCAVE_GAME_TYPE][currentGameDifficulty];;
260 maxDownThrust = MaxDownThrustVals[SFCAVE_GAME_TYPE][currentGameDifficulty];; 236 maxDownThrust = MaxDownThrustVals[SFCAVE_GAME_TYPE][currentGameDifficulty];;
261 237
262 if ( currentGameDifficulty == DIFICULTY_EASY ) 238 if ( currentGameDifficulty == DIFICULTY_EASY )
263 gateDistance = 100; 239 gateDistance = 100;
264 else if ( currentGameDifficulty == DIFICULTY_NORMAL ) 240 else if ( currentGameDifficulty == DIFICULTY_NORMAL )
265 gateDistance = 60; 241 gateDistance = 60;
266 else 242 else
267 gateDistance = 40; 243 gateDistance = 40;
268 } 244 }
269 else if ( CURRENT_GAME_TYPE == GATES_GAME ) 245 else if ( CURRENT_GAME_TYPE == GATES_GAME )
270 { 246 {
271 thrustUp = UpThrustVals[GATES_GAME_TYPE][currentGameDifficulty];; 247 thrustUp = UpThrustVals[GATES_GAME_TYPE][currentGameDifficulty];;
272 noThrust = DownThrustVals[GATES_GAME_TYPE][currentGameDifficulty];; 248 noThrust = DownThrustVals[GATES_GAME_TYPE][currentGameDifficulty];;
273 maxUpThrust = MaxUpThrustVals[GATES_GAME_TYPE][currentGameDifficulty];; 249 maxUpThrust = MaxUpThrustVals[GATES_GAME_TYPE][currentGameDifficulty];;
274 maxDownThrust = MaxDownThrustVals[GATES_GAME_TYPE][currentGameDifficulty];; 250 maxDownThrust = MaxDownThrustVals[GATES_GAME_TYPE][currentGameDifficulty];;
275 gateDistance = 75; 251 gateDistance = 75;
276 nextGate = nextInt( 50 ) + gateDistance; 252 nextGate = nextInt( 50 ) + gateDistance;
277 } 253 }
278 else 254 else
279 { 255 {
280 thrustUp = UpThrustVals[FLY_GAME_TYPE][currentGameDifficulty]; 256 thrustUp = UpThrustVals[FLY_GAME_TYPE][currentGameDifficulty];
281 noThrust = DownThrustVals[FLY_GAME_TYPE][currentGameDifficulty]; 257 noThrust = DownThrustVals[FLY_GAME_TYPE][currentGameDifficulty];
282 maxUpThrust = MaxUpThrustVals[FLY_GAME_TYPE][currentGameDifficulty]; 258 maxUpThrust = MaxUpThrustVals[FLY_GAME_TYPE][currentGameDifficulty];
283 maxDownThrust = MaxDownThrustVals[FLY_GAME_TYPE][currentGameDifficulty]; 259 maxDownThrust = MaxDownThrustVals[FLY_GAME_TYPE][currentGameDifficulty];
284 260
285 if ( currentGameDifficulty == DIFICULTY_EASY ) 261 if ( currentGameDifficulty == DIFICULTY_EASY )
286 flyScores = (int*)flyEasyScores; 262 flyScores = (int*)flyEasyScores;
287 else if ( currentGameDifficulty == DIFICULTY_NORMAL ) 263 else if ( currentGameDifficulty == DIFICULTY_NORMAL )
288 flyScores = (int*)flyNormalScores; 264 flyScores = (int*)flyNormalScores;
289 else 265 else
290 flyScores = (int*)flyHardScores; 266 flyScores = (int*)flyHardScores;
291 } 267 }
292 268
293 crashLineLength = 0; 269 crashLineLength = 0;
294 lastGateBottomY = 0; 270 lastGateBottomY = 0;
295 271
296 user.setRect( 50, sWidth/2, 4, 4 ); 272 user.setRect( 50, sWidth/2, 4, 4 );
297 273
298 blockWidth = 20; 274 blockWidth = 20;
299 blockHeight = 70; 275 blockHeight = 70;
300 gapHeight = initialGateGaps[currentGameDifficulty]; 276 gapHeight = initialGateGaps[currentGameDifficulty];
301 277
302 for ( int i = 0 ; i < TRAILSIZE ; ++i ) 278 for ( int i = 0 ; i < TRAILSIZE ; ++i )
303 { 279 {
304 trail[i].setX( -1 ); 280 trail[i].setX( -1 );
305 trail[i].setY( 0 ); 281 trail[i].setY( 0 );
306 } 282 }
307 283
308 if ( CURRENT_GAME_TYPE != FLY_GAME ) 284 if ( CURRENT_GAME_TYPE != FLY_GAME )
309 { 285 {
310 maxHeight = 50; 286 maxHeight = 50;
311 287
312 mapTop[0] = (int)(nextInt(50)) + 5; 288 mapTop[0] = (int)(nextInt(50)) + 5;
313 mapBottom[0] = (int)(nextInt(50)) + 5; 289 mapBottom[0] = (int)(nextInt(50)) + 5;
314 for ( int i = 1 ; i < MAPSIZE ; ++i ) 290 for ( int i = 1 ; i < MAPSIZE ; ++i )
315 setPoint( i ); 291 setPoint( i );
316 } 292 }
317 else 293 else
318 { 294 {
319 maxHeight = 100; 295 maxHeight = 100;
320 296
321 for ( int i = 0 ; i < MAPSIZE ; ++i ) 297 for ( int i = 0 ; i < MAPSIZE ; ++i )
322 mapBottom[i] = sHeight - 10; 298 mapBottom[i] = sHeight - 10;
323 } 299 }
324 for ( int i = 0 ; i < BLOCKSIZE ; ++i ) 300 for ( int i = 0 ; i < BLOCKSIZE ; ++i )
325 blocks[i].setY( -1 ); 301 blocks[i].setY( -1 );
326 302
327} 303}
328 304
329void SFCave :: run() 305void SFCave :: run()
330{ 306{
331 switch ( state ) 307 switch ( state )
332 { 308 {
333 case STATE_MENU: 309 case STATE_MENU:
334 displayMenu(); 310 displayMenu();
335 break; 311 break;
336 case STATE_NEWGAME: 312 case STATE_NEWGAME:
337 setSeed( -1 ); 313 setSeed( -1 );
338 setUp(); 314 setUp();
339 draw(); 315 draw();
340 state = STATE_RUNNING; 316 state = STATE_RUNNING;
341 replay = false; 317 replay = false;
342 replayList.clear(); 318 replayList.clear();
343 break; 319 break;
344 case STATE_REPLAY: 320 case STATE_REPLAY:
345 setSeed( currentSeed ); 321 setSeed( currentSeed );
346 setUp(); 322 setUp();
347 draw(); 323 draw();
348 state = STATE_RUNNING; 324 state = STATE_RUNNING;
349 replay = true; 325 replay = true;
350 if ( replayIt ) 326 if ( replayIt )
351 delete replayIt; 327 delete replayIt;
352 replayIt = new QListIterator<int>( replayList ); 328 replayIt = new QListIterator<int>( replayList );
353 break; 329 break;
354 case STATE_BOSS: 330 case STATE_BOSS:
355 drawBoss(); 331 drawBoss();
356 break; 332 break;
357 333
358 case STATE_CRASHING: 334 case STATE_CRASHING:
359 case STATE_CRASHED: 335 case STATE_CRASHED:
360 press = false; 336 press = false;
361 draw(); 337 draw();
362 break; 338 break;
363 339
364 case STATE_RUNNING: 340 case STATE_RUNNING:
365 { 341 {
366 if ( nrFrames % 2 == 0 ) 342 if ( nrFrames % 2 == 0 )
367 handleKeys(); 343 handleKeys();
368 344
369 // Apply Game rules 345 // Apply Game rules
370 nrFrames ++; 346 nrFrames ++;
371 347
372 if ( replay ) 348 if ( replay )
373 { 349 {
374 while( replayIt->current() && *(replayIt->current()) == nrFrames ) 350 while( replayIt->current() && *(replayIt->current()) == nrFrames )
375 { 351 {
376 press = !press; 352 press = !press;
377 ++(*replayIt); 353 ++(*replayIt);
378 } 354 }
379 } 355 }
380 356
381 if ( CURRENT_GAME_TYPE == SFCAVE_GAME ) 357 if ( CURRENT_GAME_TYPE == SFCAVE_GAME )
382 handleGameSFCave(); 358 handleGameSFCave();
383 else if ( CURRENT_GAME_TYPE == GATES_GAME ) 359 else if ( CURRENT_GAME_TYPE == GATES_GAME )
384 handleGameGates(); 360 handleGameGates();
385 else if ( CURRENT_GAME_TYPE == FLY_GAME ) 361 else if ( CURRENT_GAME_TYPE == FLY_GAME )
386 handleGameFly(); 362 handleGameFly();
387 363
388 draw(); 364 draw();
389 break; 365 break;
390 } 366 }
391 } 367 }
392} 368}
393 369
394void SFCave :: handleGameSFCave() 370void SFCave :: handleGameSFCave()
395{ 371{
396 // Update score 372 // Update score
397 if ( nrFrames % 5 == 0 ) 373 if ( nrFrames % 5 == 0 )
398 score ++; 374 score ++;
399 375
400 if ( nrFrames % 500 == 0 ) 376 if ( nrFrames % 500 == 0 )
401 { 377 {
402 if ( maxHeight < sHeight - 100 ) 378 if ( maxHeight < sHeight - 100 )
403 { 379 {
404 maxHeight += 10; 380 maxHeight += 10;
405 381
406 // Reduce block height 382 // Reduce block height
407 if ( maxHeight > sHeight - 150 ) 383 if ( maxHeight > sHeight - 150 )
408 blockHeight -= 5; 384 blockHeight -= 5;
409 } 385 }
410 } 386 }
411 387
412 if ( nrFrames % gateDistance == 0 ) 388 if ( nrFrames % gateDistance == 0 )
413 addBlock(); 389 addBlock();
414 390
415 if ( checkCollision() ) 391 if ( checkCollision() )
416 { 392 {
417 if ( score > highestScore[currentGameType][currentGameDifficulty] ) 393 if ( score > highestScore[currentGameType][currentGameDifficulty] )
418 { 394 {
419 highestScore[currentGameType][currentGameDifficulty] = score; 395 highestScore[currentGameType][currentGameDifficulty] = score;
420 saveScore(); 396 saveScore();
421 } 397 }
422 state = STATE_CRASHING; 398 state = STATE_CRASHING;
423 } 399 }
424 else 400 else
425 { 401 {
426 moveLandscape(); 402 moveLandscape();
427 } 403 }
428 404
429} 405}
430 406
431 407
432void SFCave :: handleGameGates() 408void SFCave :: handleGameGates()
433{ 409{
434 // Update score 410 // Update score
435 if ( nrFrames % 5 == 0 ) 411 if ( nrFrames % 5 == 0 )
436 score ++; 412 score ++;
437 413
438 // Slightly random gap distance 414 // Slightly random gap distance
439 if ( nrFrames >= nextGate ) 415 if ( nrFrames >= nextGate )
440 { 416 {
441 nextGate = nrFrames + nextInt( 50 ) + gateDistance; 417 nextGate = nrFrames + nextInt( 50 ) + gateDistance;
442 addGate(); 418 addGate();
443 } 419 }
444 420
445 if ( nrFrames % 500 == 0 ) 421 if ( nrFrames % 500 == 0 )
446 { 422 {
447 if ( gapHeight > 75 ) 423 if ( gapHeight > 75 )
448 gapHeight -= 5; 424 gapHeight -= 5;
449 } 425 }
450 426
451 if ( checkCollision() ) 427 if ( checkCollision() )
452 { 428 {
453 if ( score > highestScore[currentGameType][currentGameDifficulty] ) 429 if ( score > highestScore[currentGameType][currentGameDifficulty] )
454 { 430 {
455 highestScore[currentGameType][currentGameDifficulty] = score; 431 highestScore[currentGameType][currentGameDifficulty] = score;
456 saveScore(); 432 saveScore();
457 } 433 }
458 state = STATE_CRASHING; 434 state = STATE_CRASHING;
459 } 435 }
460 else 436 else
461 { 437 {
462 moveLandscape(); 438 moveLandscape();
463 } 439 }
464 440
465} 441}
466 442
467void SFCave :: handleGameFly() 443void SFCave :: handleGameFly()
468{ 444{
469 int diff = mapBottom[10] - user.y(); 445 int diff = mapBottom[10] - user.y();
470 446
471 if ( nrFrames % 4 == 0 ) 447 if ( nrFrames % 4 == 0 )
472 { 448 {
473 if ( !startScoring ) 449 if ( !startScoring )
474 { 450 {
475 if ( diff < 40 ) 451 if ( diff < 40 )
476 startScoring = true; 452 startScoring = true;
477 } 453 }
478 454
479 if ( startScoring ) 455 if ( startScoring )
480 { 456 {
481 // Update score 457 // Update score
482 // get distance between landscape and ship 458 // get distance between landscape and ship
483 459
484 // the closer the difference is to 0 means more points 460 // the closer the difference is to 0 means more points
485 for ( int i = 0 ; i < 10 && FLYSCORES( i, 0 ) != -1 ; ++i ) 461 for ( int i = 0 ; i < 10 && FLYSCORES( i, 0 ) != -1 ; ++i )
486 { 462 {
487 if ( FLYSCORES( i, 0 ) <= diff && FLYSCORES(i, 1 ) > diff ) 463 if ( FLYSCORES( i, 0 ) <= diff && FLYSCORES(i, 1 ) > diff )
488 { 464 {
489 score += FLYSCORES( i, 2 ); 465 score += FLYSCORES( i, 2 );
490 break; 466 break;
491 } 467 }
492 } 468 }
493 } 469 }
494 } 470 }
495 471
496 if ( checkFlyGameCollision() ) 472 if ( checkFlyGameCollision() )
497 { 473 {
498 if ( score > highestScore[currentGameType][currentGameDifficulty] ) 474 if ( score > highestScore[currentGameType][currentGameDifficulty] )
499 { 475 {
500 highestScore[currentGameType][currentGameDifficulty] = score; 476 highestScore[currentGameType][currentGameDifficulty] = score;
501 saveScore(); 477 saveScore();
502 } 478 }
503 state = STATE_CRASHING; 479 state = STATE_CRASHING;
504 } 480 }
505 else 481 else
506 { 482 {
507 moveFlyGameLandscape(); 483 moveFlyGameLandscape();
508 } 484 }
509} 485}
510 486
511bool SFCave :: checkFlyGameCollision() 487bool SFCave :: checkFlyGameCollision()
512{ 488{
513 if ( (user.y() + user.width()) >= mapBottom[11] ) 489 if ( (user.y() + user.width()) >= mapBottom[11] )
514 return true; 490 return true;
515 491
516 return false; 492 return false;
517} 493}
518 494
519void SFCave :: moveFlyGameLandscape() 495void SFCave :: moveFlyGameLandscape()
520{ 496{
521 offset++; 497 offset++;
522 498
523 if ( offset >= segSize ) 499 if ( offset >= segSize )
524 { 500 {
525 offset = 0; 501 offset = 0;
526 for ( int i = 0 ; i < MAPSIZE-speed ; ++i ) 502 for ( int i = 0 ; i < MAPSIZE-speed ; ++i )
527 mapBottom[i] = mapBottom[i+speed]; 503 mapBottom[i] = mapBottom[i+speed];
528 504
529 for ( int i = speed ; i > 0 ; --i ) 505 for ( int i = speed ; i > 0 ; --i )
530 setFlyPoint( MAPSIZE-i ); 506 setFlyPoint( MAPSIZE-i );
531 } 507 }
532} 508}
533 509
534void SFCave :: setFlyPoint( int point ) 510void SFCave :: setFlyPoint( int point )
535{ 511{
536 static int fly_difficulty_levels[] = { 5, 10, 15 }; 512 static int fly_difficulty_levels[] = { 5, 10, 15 };
537 if ( nextInt(100) >= 75 ) 513 if ( nextInt(100) >= 75 )
538 dir *= -1; 514 dir *= -1;
539 515
540 int prevPoint = mapBottom[point-1]; 516 int prevPoint = mapBottom[point-1];
541 517
542 int nextPoint = prevPoint + (dir * nextInt( fly_difficulty_levels[currentGameDifficulty] ) ); 518 int nextPoint = prevPoint + (dir * nextInt( fly_difficulty_levels[currentGameDifficulty] ) );
543 519
544 if ( nextPoint > sHeight ) 520 if ( nextPoint > sHeight )
545 { 521 {
546 nextPoint = sHeight; 522 nextPoint = sHeight;
547 dir *= -1; 523 dir *= -1;
548 } 524 }
549 else if ( nextPoint < maxHeight ) 525 else if ( nextPoint < maxHeight )
550 { 526 {
551 nextPoint = maxHeight; 527 nextPoint = maxHeight;
552 dir *= 1; 528 dir *= 1;
553 } 529 }
554 530
555 mapBottom[point] = nextPoint; 531 mapBottom[point] = nextPoint;
556} 532}
557 533
558bool SFCave :: checkCollision() 534bool SFCave :: checkCollision()
559{ 535{
560 if ( (user.y() + user.width()) >= mapBottom[11] || user.y() <= mapTop[11] ) 536 if ( (user.y() + user.width()) >= mapBottom[11] || user.y() <= mapTop[11] )
561 return true; 537 return true;
562 538
563 for ( int i = 0 ; i < BLOCKSIZE ; ++i ) 539 for ( int i = 0 ; i < BLOCKSIZE ; ++i )
564 { 540 {
565 if ( blocks[i].y() != -1 ) 541 if ( blocks[i].y() != -1 )
566 { 542 {
567 if ( blocks[i].intersects( user ) ) 543 if ( blocks[i].intersects( user ) )
568 return true; 544 return true;
569 } 545 }
570 } 546 }
571 return false; 547 return false;
572} 548}
573 549
574void SFCave :: moveLandscape() 550void SFCave :: moveLandscape()
575{ 551{
576 offset++; 552 offset++;
577 553
578 if ( offset >= segSize ) 554 if ( offset >= segSize )
579 { 555 {
580 offset = 0; 556 offset = 0;
581 for ( int i = 0 ; i < MAPSIZE-speed ; ++i ) 557 for ( int i = 0 ; i < MAPSIZE-speed ; ++i )
582 { 558 {
583 mapTop[i] = mapTop[i+speed]; 559 mapTop[i] = mapTop[i+speed];
584 mapBottom[i] = mapBottom[i+speed]; 560 mapBottom[i] = mapBottom[i+speed];
585 } 561 }
586 562
587 for ( int i = speed ; i > 0 ; --i ) 563 for ( int i = speed ; i > 0 ; --i )
588 setPoint( MAPSIZE-i ); 564 setPoint( MAPSIZE-i );
589 } 565 }
590 566
591 for ( int i = 0 ; i < BLOCKSIZE ; ++i ) 567 for ( int i = 0 ; i < BLOCKSIZE ; ++i )
592 { 568 {
593 if ( blocks[i].y() != -1 ) 569 if ( blocks[i].y() != -1 )
594 { 570 {
595 blocks[i].moveBy( -speed, 0 ); 571 blocks[i].moveBy( -speed, 0 );
596 if ( blocks[i].x() + blocks[i].width() < 0 ) 572 if ( blocks[i].x() + blocks[i].width() < 0 )
597 blocks[i].setY( -1 ); 573 blocks[i].setY( -1 );
598 } 574 }
599 } 575 }
600} 576}
601 577
602void SFCave :: addBlock() 578void SFCave :: addBlock()
603{ 579{
604 for ( int i = 0 ; i < BLOCKSIZE ; ++i ) 580 for ( int i = 0 ; i < BLOCKSIZE ; ++i )
605 { 581 {
606 if ( blocks[i].y() == -1 ) 582 if ( blocks[i].y() == -1 )
607 { 583 {
608 int x = sWidth; 584 int x = sWidth;
609 585
610 int y = mapTop[50] + (int)(nextInt(mapBottom[50] - mapTop[50] - blockHeight)); 586 int y = mapTop[50] + (int)(nextInt(mapBottom[50] - mapTop[50] - blockHeight));
611 587
612 blocks[i].setRect( x, y, blockWidth, blockHeight ); 588 blocks[i].setRect( x, y, blockWidth, blockHeight );
613 589
614 break; 590 break;
615 } 591 }
616 } 592 }
617} 593}
618 594
619void SFCave :: addGate() 595void SFCave :: addGate()
620{ 596{
621 for ( int i = 0 ; i < BLOCKSIZE ; ++i ) 597 for ( int i = 0 ; i < BLOCKSIZE ; ++i )
622 { 598 {
623 if ( blocks[i].y() == -1 ) 599 if ( blocks[i].y() == -1 )
624 { 600 {
625 int x1 = sWidth; 601 int x1 = sWidth;
626 int y1 = mapTop[50]; 602 int y1 = mapTop[50];
627 int b1Height = nextInt(mapBottom[50] - mapTop[50] - gapHeight); 603 int b1Height = nextInt(mapBottom[50] - mapTop[50] - gapHeight);
628 604
629 // See if height between last gate and this one is too big 605 // See if height between last gate and this one is too big
630 if ( b1Height - 100 > lastGateBottomY ) 606 if ( b1Height - 100 > lastGateBottomY )
631 b1Height -= 25; 607 b1Height -= 25;
632 else if ( b1Height + 100 < lastGateBottomY ) 608 else if ( b1Height + 100 < lastGateBottomY )
633 b1Height += 25; 609 b1Height += 25;
634 lastGateBottomY = b1Height; 610 lastGateBottomY = b1Height;
635 611
636 612
637 int x2 = sWidth; 613 int x2 = sWidth;
638 int y2 = y1 + b1Height + gapHeight; 614 int y2 = y1 + b1Height + gapHeight;
639 int b2Height = mapBottom[50] - y2; 615 int b2Height = mapBottom[50] - y2;
640 616
641 617
642 blocks[i].setRect( x1, y1, blockWidth, b1Height ); 618 blocks[i].setRect( x1, y1, blockWidth, b1Height );
643 blocks[i+1].setRect( x2, y2, blockWidth, b2Height ); 619 blocks[i+1].setRect( x2, y2, blockWidth, b2Height );
644 620
645 break; 621 break;
646 } 622 }
647 } 623 }
648} 624}
649 625
650void SFCave :: setPoint( int point ) 626void SFCave :: setPoint( int point )
651{ 627{
652 if ( nextInt(100) >= 80 ) 628 if ( nextInt(100) >= 80 )
653 dir *= -1; 629 dir *= -1;
654 630
655 mapTop[point] = mapTop[point-1] + (dir * nextInt( 5 ) ); 631 mapTop[point] = mapTop[point-1] + (dir * nextInt( 5 ) );
656 if ( mapTop[point] < 0 ) 632 if ( mapTop[point] < 0 )
657 { 633 {
658 mapTop[point] = 0; 634 mapTop[point] = 0;
659 dir *= -1; 635 dir *= -1;
660 } 636 }
661 else if ( mapTop[point] >= maxHeight ) 637 else if ( mapTop[point] >= maxHeight )
662 { 638 {
663 mapTop[point] = maxHeight; 639 mapTop[point] = maxHeight;
664 dir *= -1; 640 dir *= -1;
665 } 641 }
666 642
667// mapBottom[point] = sHeight - (maxHeight - mapBottom[point]); 643// mapBottom[point] = sHeight - (maxHeight - mapBottom[point]);
668 mapBottom[point] = sHeight - (maxHeight - mapTop[point]); 644 mapBottom[point] = sHeight - (maxHeight - mapTop[point]);
669} 645}
670 646
671void SFCave :: drawBoss() 647void SFCave :: drawBoss()
672{ 648{
673 offscreen->fill( Qt::black ); 649 offscreen->fill( Qt::black );
674 650
675 bitBlt( this, 0, 0, offscreen, 0, 0, sWidth, sHeight, Qt::CopyROP, true ); 651 bitBlt( this, 0, 0, offscreen, 0, 0, sWidth, sHeight, Qt::CopyROP, true );
676} 652}
677 653
678void SFCave :: draw() 654void SFCave :: draw()
679{ 655{
680 //printf( "Paint\n" ); 656 //printf( "Paint\n" );
681 offscreen->fill( Qt::black ); 657 offscreen->fill( Qt::black );
682 658
683 QPainter p( offscreen ); 659 QPainter p( offscreen );
684 QFontMetrics fm = p.fontMetrics(); 660 QFontMetrics fm = p.fontMetrics();
685 p.setPen( Qt::white ); 661 p.setPen( Qt::white );
686 662
687 for ( int i = 0 ; i < MAPSIZE -3; ++i ) 663 for ( int i = 0 ; i < MAPSIZE -3; ++i )
688 { 664 {
689 // Only display top landscape if not running FLY_GAME 665 // Only display top landscape if not running FLY_GAME
690 if ( CURRENT_GAME_TYPE != FLY_GAME ) 666 if ( CURRENT_GAME_TYPE != FLY_GAME )
691 p.drawLine( (i*segSize) - (offset*speed), mapTop[i], ((i+1)*segSize)-(offset*speed), mapTop[i+1] ); 667 p.drawLine( (i*segSize) - (offset*speed), mapTop[i], ((i+1)*segSize)-(offset*speed), mapTop[i+1] );
692 668
693 p.drawLine( (i*segSize) - (offset*speed), mapBottom[i], ((i+1)*segSize)-(offset*speed), mapBottom[i+1] ); 669 p.drawLine( (i*segSize) - (offset*speed), mapBottom[i], ((i+1)*segSize)-(offset*speed), mapBottom[i+1] );
694 670
695 if ( CURRENT_GAME_TYPE == FLY_GAME && showScoreZones ) 671 if ( CURRENT_GAME_TYPE == FLY_GAME && showScoreZones )
696 { 672 {
697 p.setPen( Qt::blue ); 673 p.setPen( Qt::blue );
698 for ( int j = 1 ; j < 10 && FLYSCORES( j, 0 ) != -1 ; ++j ) 674 for ( int j = 1 ; j < 10 && FLYSCORES( j, 0 ) != -1 ; ++j )
699 { 675 {
700 if ( FLYSCORES( j, 2 ) < 0 ) 676 if ( FLYSCORES( j, 2 ) < 0 )
701 p.setPen( Qt::red ); 677 p.setPen( Qt::red );
702 678
703 p.drawLine( (i*segSize) - (offset*speed), mapBottom[i]-FLYSCORES( j, 0 ), ((i+1)*segSize)-(offset*speed), mapBottom[i+1]-FLYSCORES( j, 0 ) ); 679 p.drawLine( (i*segSize) - (offset*speed), mapBottom[i]-FLYSCORES( j, 0 ), ((i+1)*segSize)-(offset*speed), mapBottom[i+1]-FLYSCORES( j, 0 ) );
704 } 680 }
705 681
706 p.setPen( Qt::white ); 682 p.setPen( Qt::white );
707 } 683 }
708 } 684 }
709 685
710 // Uncomment this to show user segment (usful for checking collision boundary with landscape 686 // Uncomment this to show user segment (usful for checking collision boundary with landscape
711// p.setPen( Qt::red ); 687// p.setPen( Qt::red );
712// p.drawLine( (11*segSize) - (offset*speed), 0, ((11)*segSize)-(offset*speed), sHeight ); 688// p.drawLine( (11*segSize) - (offset*speed), 0, ((11)*segSize)-(offset*speed), sHeight );
713// p.setPen( Qt::white ); 689// p.setPen( Qt::white );
714 690
715 // Draw user 691 // Draw user
716 p.drawRect( user ); 692 p.drawRect( user );
717 693
718 // Draw trails 694 // Draw trails
719 for ( int i = 0 ; i < TRAILSIZE ; ++i ) 695 for ( int i = 0 ; i < TRAILSIZE ; ++i )
720 if ( trail[i].x() >= 0 ) 696 if ( trail[i].x() >= 0 )
721 { 697 {
722 if ( showEyeCandy ) 698 if ( showEyeCandy )
723 p.setPen( Qt::white.light((int)(100.0-3*(user.x()/100.0)* (user.x()-trail[i].x())) ) ); 699 p.setPen( Qt::white.light((int)(100.0-3*(user.x()/100.0)* (user.x()-trail[i].x())) ) );
724 p.drawRect( trail[i].x(), trail[i].y(), 2, 2 ); 700 p.drawRect( trail[i].x(), trail[i].y(), 2, 2 );
725 } 701 }
726 702
727 p.setPen( Qt::white ); 703 p.setPen( Qt::white );
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
@@ -1,131 +1,137 @@
1#include <qmainwindow.h> 1#include <qmainwindow.h>
2#include <qpainter.h> 2#include <qpainter.h>
3#include <qpixmap.h> 3#include <qpixmap.h>
4#include <qpoint.h> 4#include <qpoint.h>
5#include <qrect.h> 5#include <qrect.h>
6#include <qtimer.h> 6#include <qtimer.h>
7#include <qlist.h> 7#include <qlist.h>
8 8
9#include "random.h" 9#include "random.h"
10 10
11#define MAPSIZE 52 11#define MAPSIZE 52
12#define BLOCKSIZE 6 12#define BLOCKSIZE 6
13#define TRAILSIZE 30 13#define TRAILSIZE 30
14 14
15#define NR_MENUS 3 15#define NR_MENUS 3
16#define MAX_MENU_OPTIONS 8 16#define MAX_MENU_OPTIONS 8
17 17
18class SFCave : public QMainWindow 18class SFCave : public QMainWindow
19{ 19{
20Q_OBJECT 20Q_OBJECT
21 21
22public: 22public:
23 int sWidth; 23 int sWidth;
24 int sHeight; 24 int sHeight;
25 int segSize; 25 int segSize;
26 26
27 int currentSeed; 27 int currentSeed;
28 28
29 QList<int> replayList; 29 QList<int> replayList;
30 QListIterator<int> *replayIt; 30 QListIterator<int> *replayIt;
31 bool replay; 31 bool replay;
32 QString replayFile; 32 QString replayFile;
33 33
34 int blockWidth; 34 int blockWidth;
35 int blockHeight; 35 int blockHeight;
36 int gapHeight; 36 int gapHeight;
37 int state; 37 int state;
38 int prevState; 38 int prevState;
39 int speed; 39 int speed;
40 int crashLineLength; 40 int crashLineLength;
41 bool startScoring; 41 bool startScoring;
42 bool showEyeCandy; 42 bool showEyeCandy;
43 43
44 static double UpThrustVals[3][3]; 44 static double UpThrustVals[3][3];
45 static double DownThrustVals[3][3]; 45 static double DownThrustVals[3][3];
46 static double MaxUpThrustVals[3][3]; 46 static double MaxUpThrustVals[3][3];
47 static double MaxDownThrustVals[3][3]; 47 static double MaxDownThrustVals[3][3];
48 static int initialGateGaps[]; 48 static int initialGateGaps[];
49 49
50 static int flyEasyScores[7][3]; 50 static int flyEasyScores[7][3];
51 static int flyNormalScores[7][3]; 51 static int flyNormalScores[7][3];
52 static int flyHardScores[7][3]; 52 static int flyHardScores[7][3];
53 int *flyScores; 53 int *flyScores;
54 54
55 55
56 double thrustUp; 56 double thrustUp;
57 double noThrust; 57 double noThrust;
58 double maxUpThrust; 58 double maxUpThrust;
59 double maxDownThrust; 59 double maxDownThrust;
60 60
61 int gateDistance; 61 int gateDistance;
62 int nextGate; 62 int nextGate;
63 int lastGateBottomY; 63 int lastGateBottomY;
64 64
65 static QString menuOptions[NR_MENUS][MAX_MENU_OPTIONS]; 65 static QString menuOptions[NR_MENUS][MAX_MENU_OPTIONS];
66 int currentMenuNr; 66 int currentMenuNr;
67 static int nrMenuOptions[NR_MENUS]; 67 static int nrMenuOptions[NR_MENUS];
68 static int currentMenuOption[NR_MENUS]; 68 static int currentMenuOption[NR_MENUS];
69 69
70 static QString dificultyOption[3]; 70 static QString dificultyOption[3];
71 static QString gameTypes[3]; 71 static QString gameTypes[3];
72 int currentGameType; 72 int currentGameType;
73 int currentGameDifficulty; 73 int currentGameDifficulty;
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 );
125 void saveScore(); 131 void saveScore();
126 void saveReplay(); 132 void saveReplay();
127 void loadReplay(); 133 void loadReplay();
128 134
129private slots: 135private slots:
130 void run(); 136 void run();
131}; 137};
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 )