-rw-r--r-- | noncore/games/sfcave/sfcave.cpp | 18 |
1 files changed, 14 insertions, 4 deletions
diff --git a/noncore/games/sfcave/sfcave.cpp b/noncore/games/sfcave/sfcave.cpp index 929dc41..5633a8f 100644 --- a/noncore/games/sfcave/sfcave.cpp +++ b/noncore/games/sfcave/sfcave.cpp | |||
@@ -1,41 +1,41 @@ | |||
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 | #ifdef QWS |
7 | #include <qpe/qpeapplication.h> | 7 | #include <qpe/qpeapplication.h> |
8 | #include <qpe/config.h> | 8 | #include <qpe/config.h> |
9 | #else | 9 | #else |
10 | #include <qapplication.h> | 10 | #include <qapplication.h> |
11 | #endif | 11 | #endif |
12 | #include <qdir.h> | 12 | #include <qdir.h> |
13 | 13 | ||
14 | #include "helpwindow.h" | 14 | #include "helpwindow.h" |
15 | #include "sfcave.h" | 15 | #include "sfcave.h" |
16 | 16 | ||
17 | #define CAPTION "SFCave 1.11 by AndyQ" | 17 | #define CAPTION "SFCave 1.12 by AndyQ" |
18 | 18 | ||
19 | #define UP_THRUST 0.6 | 19 | #define UP_THRUST 0.6 |
20 | #define NO_THRUST 0.8 | 20 | #define NO_THRUST 0.8 |
21 | #define MAX_DOWN_THRUST 4.0 | 21 | #define MAX_DOWN_THRUST 4.0 |
22 | #define MAX_UP_THRUST -3.5 | 22 | #define MAX_UP_THRUST -3.5 |
23 | 23 | ||
24 | // States | 24 | // States |
25 | #define STATE_BOSS 0 | 25 | #define STATE_BOSS 0 |
26 | #define STATE_RUNNING 1 | 26 | #define STATE_RUNNING 1 |
27 | #define STATE_CRASHING 2 | 27 | #define STATE_CRASHING 2 |
28 | #define STATE_CRASHED 3 | 28 | #define STATE_CRASHED 3 |
29 | #define STATE_NEWGAME 4 | 29 | #define STATE_NEWGAME 4 |
30 | #define STATE_MENU 5 | 30 | #define STATE_MENU 5 |
31 | #define STATE_REPLAY 6 | 31 | #define STATE_REPLAY 6 |
32 | 32 | ||
33 | // Menus | 33 | // Menus |
34 | #define MENU_MAIN_MENU 0 | 34 | #define MENU_MAIN_MENU 0 |
35 | #define MENU_OPTIONS_MENU 1 | 35 | #define MENU_OPTIONS_MENU 1 |
36 | #define MENU_REPLAY_MENU 2 | 36 | #define MENU_REPLAY_MENU 2 |
37 | 37 | ||
38 | // Main Menu Options | 38 | // Main Menu Options |
39 | #define MENU_START_GAME 0 | 39 | #define MENU_START_GAME 0 |
40 | #define MENU_REPLAY 1 | 40 | #define MENU_REPLAY 1 |
41 | #define MENU_OPTIONS 2 | 41 | #define MENU_OPTIONS 2 |
@@ -206,80 +206,90 @@ void SFCave :: setSeed( int seed ) | |||
206 | { | 206 | { |
207 | if ( seed == -1 ) | 207 | if ( seed == -1 ) |
208 | currentSeed = ((unsigned long) time((time_t *) NULL)); | 208 | currentSeed = ((unsigned long) time((time_t *) NULL)); |
209 | else | 209 | else |
210 | currentSeed = seed; | 210 | currentSeed = seed; |
211 | PutSeed( currentSeed ); | 211 | PutSeed( currentSeed ); |
212 | } | 212 | } |
213 | 213 | ||
214 | int SFCave :: nextInt( int range ) | 214 | int SFCave :: nextInt( int range ) |
215 | { | 215 | { |
216 | int val = (int)(Random( ) * range); | 216 | int val = (int)(Random( ) * range); |
217 | 217 | ||
218 | return val; | 218 | return val; |
219 | 219 | ||
220 | } | 220 | } |
221 | 221 | ||
222 | void SFCave :: setUp() | 222 | void SFCave :: setUp() |
223 | { | 223 | { |
224 | score = 0; | 224 | score = 0; |
225 | offset = 0; | 225 | offset = 0; |
226 | nrFrames = 0; | 226 | nrFrames = 0; |
227 | dir = 1; | 227 | dir = 1; |
228 | thrust = 0; | 228 | thrust = 0; |
229 | 229 | ||
230 | int dist[] = { 100, 60, 40 }; | ||
230 | if ( CURRENT_GAME_TYPE == SFCAVE_GAME ) | 231 | if ( CURRENT_GAME_TYPE == SFCAVE_GAME ) |
231 | { | 232 | { |
232 | thrustUp = UpThrustVals[SFCAVE_GAME_TYPE][currentGameDifficulty];; | 233 | thrustUp = UpThrustVals[SFCAVE_GAME_TYPE][currentGameDifficulty];; |
233 | noThrust = DownThrustVals[SFCAVE_GAME_TYPE][currentGameDifficulty];; | 234 | noThrust = DownThrustVals[SFCAVE_GAME_TYPE][currentGameDifficulty];; |
234 | maxUpThrust = MaxUpThrustVals[SFCAVE_GAME_TYPE][currentGameDifficulty];; | 235 | maxUpThrust = MaxUpThrustVals[SFCAVE_GAME_TYPE][currentGameDifficulty];; |
235 | maxDownThrust = MaxDownThrustVals[SFCAVE_GAME_TYPE][currentGameDifficulty];; | 236 | maxDownThrust = MaxDownThrustVals[SFCAVE_GAME_TYPE][currentGameDifficulty];; |
237 | |||
238 | if ( currentCameDifficulty == DIFICULTY_EASY ) | ||
239 | gateDistance = 100; | ||
240 | else if ( currentCameDifficulty == DIFICULTY_EASY ) | ||
241 | gateDistance = 60; | ||
242 | else | ||
243 | gateDistance = 40; | ||
244 | |||
245 | printf( "GD = %d\n", gateDistance ); | ||
236 | } | 246 | } |
237 | else if ( CURRENT_GAME_TYPE == GATES_GAME ) | 247 | else if ( CURRENT_GAME_TYPE == GATES_GAME ) |
238 | { | 248 | { |
239 | thrustUp = UpThrustVals[GATES_GAME_TYPE][currentGameDifficulty];; | 249 | thrustUp = UpThrustVals[GATES_GAME_TYPE][currentGameDifficulty];; |
240 | noThrust = DownThrustVals[GATES_GAME_TYPE][currentGameDifficulty];; | 250 | noThrust = DownThrustVals[GATES_GAME_TYPE][currentGameDifficulty];; |
241 | maxUpThrust = MaxUpThrustVals[GATES_GAME_TYPE][currentGameDifficulty];; | 251 | maxUpThrust = MaxUpThrustVals[GATES_GAME_TYPE][currentGameDifficulty];; |
242 | maxDownThrust = MaxDownThrustVals[GATES_GAME_TYPE][currentGameDifficulty];; | 252 | maxDownThrust = MaxDownThrustVals[GATES_GAME_TYPE][currentGameDifficulty];; |
253 | gateDistance = 75; | ||
254 | nextGate = nextInt( 50 ) + gateDistance; | ||
243 | } | 255 | } |
244 | else | 256 | else |
245 | { | 257 | { |
246 | thrustUp = UpThrustVals[FLY_GAME_TYPE][currentGameDifficulty]; | 258 | thrustUp = UpThrustVals[FLY_GAME_TYPE][currentGameDifficulty]; |
247 | noThrust = DownThrustVals[FLY_GAME_TYPE][currentGameDifficulty]; | 259 | noThrust = DownThrustVals[FLY_GAME_TYPE][currentGameDifficulty]; |
248 | maxUpThrust = MaxUpThrustVals[FLY_GAME_TYPE][currentGameDifficulty]; | 260 | maxUpThrust = MaxUpThrustVals[FLY_GAME_TYPE][currentGameDifficulty]; |
249 | maxDownThrust = MaxDownThrustVals[FLY_GAME_TYPE][currentGameDifficulty]; | 261 | maxDownThrust = MaxDownThrustVals[FLY_GAME_TYPE][currentGameDifficulty]; |
250 | } | 262 | } |
251 | 263 | ||
252 | crashLineLength = 0; | 264 | crashLineLength = 0; |
253 | lastGateBottomY = 0; | 265 | lastGateBottomY = 0; |
254 | 266 | ||
255 | user.setRect( 50, sWidth/2, 4, 4 ); | 267 | user.setRect( 50, sWidth/2, 4, 4 ); |
256 | 268 | ||
257 | blockWidth = 20; | 269 | blockWidth = 20; |
258 | blockHeight = 70; | 270 | blockHeight = 70; |
259 | gapHeight = initialGateGaps[currentGameDifficulty]; | 271 | gapHeight = initialGateGaps[currentGameDifficulty]; |
260 | gateDistance = 75; | ||
261 | nextGate = nextInt( 50 ) + gateDistance; | ||
262 | 272 | ||
263 | for ( int i = 0 ; i < TRAILSIZE ; ++i ) | 273 | for ( int i = 0 ; i < TRAILSIZE ; ++i ) |
264 | { | 274 | { |
265 | trail[i].setX( -1 ); | 275 | trail[i].setX( -1 ); |
266 | trail[i].setY( 0 ); | 276 | trail[i].setY( 0 ); |
267 | } | 277 | } |
268 | 278 | ||
269 | if ( CURRENT_GAME_TYPE != FLY_GAME ) | 279 | if ( CURRENT_GAME_TYPE != FLY_GAME ) |
270 | { | 280 | { |
271 | maxHeight = 50; | 281 | maxHeight = 50; |
272 | 282 | ||
273 | mapTop[0] = (int)(nextInt(50)) + 5; | 283 | mapTop[0] = (int)(nextInt(50)) + 5; |
274 | mapBottom[0] = (int)(nextInt(50)) + 5; | 284 | mapBottom[0] = (int)(nextInt(50)) + 5; |
275 | for ( int i = 1 ; i < MAPSIZE ; ++i ) | 285 | for ( int i = 1 ; i < MAPSIZE ; ++i ) |
276 | setPoint( i ); | 286 | setPoint( i ); |
277 | } | 287 | } |
278 | else | 288 | else |
279 | { | 289 | { |
280 | maxHeight = 100; | 290 | maxHeight = 100; |
281 | 291 | ||
282 | for ( int i = 0 ; i < MAPSIZE ; ++i ) | 292 | for ( int i = 0 ; i < MAPSIZE ; ++i ) |
283 | mapBottom[i] = sHeight - 10; | 293 | mapBottom[i] = sHeight - 10; |
284 | } | 294 | } |
285 | for ( int i = 0 ; i < BLOCKSIZE ; ++i ) | 295 | for ( int i = 0 ; i < BLOCKSIZE ; ++i ) |
@@ -347,49 +357,49 @@ void SFCave :: run() | |||
347 | draw(); | 357 | draw(); |
348 | break; | 358 | break; |
349 | } | 359 | } |
350 | } | 360 | } |
351 | } | 361 | } |
352 | 362 | ||
353 | void SFCave :: handleGameSFCave() | 363 | void SFCave :: handleGameSFCave() |
354 | { | 364 | { |
355 | // Update score | 365 | // Update score |
356 | if ( nrFrames % 5 == 0 ) | 366 | if ( nrFrames % 5 == 0 ) |
357 | score ++; | 367 | score ++; |
358 | 368 | ||
359 | if ( nrFrames % 500 == 0 ) | 369 | if ( nrFrames % 500 == 0 ) |
360 | { | 370 | { |
361 | if ( maxHeight < sHeight - 100 ) | 371 | if ( maxHeight < sHeight - 100 ) |
362 | { | 372 | { |
363 | maxHeight += 10; | 373 | maxHeight += 10; |
364 | 374 | ||
365 | // Reduce block height | 375 | // Reduce block height |
366 | if ( maxHeight > sHeight - 150 ) | 376 | if ( maxHeight > sHeight - 150 ) |
367 | blockHeight -= 5; | 377 | blockHeight -= 5; |
368 | } | 378 | } |
369 | } | 379 | } |
370 | 380 | ||
371 | if ( nrFrames % 100 == 0 ) | 381 | if ( nrFrames % gateDistance == 0 ) |
372 | addBlock(); | 382 | addBlock(); |
373 | 383 | ||
374 | if ( checkCollision() ) | 384 | if ( checkCollision() ) |
375 | { | 385 | { |
376 | if ( score > highestScore[currentGameType][currentGameDifficulty] ) | 386 | if ( score > highestScore[currentGameType][currentGameDifficulty] ) |
377 | { | 387 | { |
378 | highestScore[currentGameType][currentGameDifficulty] = score; | 388 | highestScore[currentGameType][currentGameDifficulty] = score; |
379 | saveScore(); | 389 | saveScore(); |
380 | } | 390 | } |
381 | state = STATE_CRASHING; | 391 | state = STATE_CRASHING; |
382 | } | 392 | } |
383 | else | 393 | else |
384 | { | 394 | { |
385 | moveLandscape(); | 395 | moveLandscape(); |
386 | } | 396 | } |
387 | 397 | ||
388 | } | 398 | } |
389 | 399 | ||
390 | 400 | ||
391 | void SFCave :: handleGameGates() | 401 | void SFCave :: handleGameGates() |
392 | { | 402 | { |
393 | // Update score | 403 | // Update score |
394 | if ( nrFrames % 5 == 0 ) | 404 | if ( nrFrames % 5 == 0 ) |
395 | score ++; | 405 | score ++; |