-rw-r--r-- | noncore/games/sfcave/sfcave.cpp | 127 | ||||
-rw-r--r-- | noncore/games/sfcave/sfcave.h | 8 |
2 files changed, 104 insertions, 31 deletions
diff --git a/noncore/games/sfcave/sfcave.cpp b/noncore/games/sfcave/sfcave.cpp index c1e4532..d6d28b2 100644 --- a/noncore/games/sfcave/sfcave.cpp +++ b/noncore/games/sfcave/sfcave.cpp | |||
@@ -5,25 +5,25 @@ | |||
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.12 by AndyQ" | 17 | #define CAPTION "SFCave 1.13 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 |
@@ -95,24 +95,45 @@ double SFCave::UpThrustVals[3][3] = {{ 0.6, 0.6, 0.6 }, // S | |||
95 | double SFCave::DownThrustVals[3][3] = {{ 0.8, 0.8, 0.8 }, // SFCave | 95 | double SFCave::DownThrustVals[3][3] = {{ 0.8, 0.8, 0.8 }, // SFCave |
96 | { 0.8, 0.8, 1.0 }, // Gates | 96 | { 0.8, 0.8, 1.0 }, // Gates |
97 | { 0.4, 0.7, 1.0 } }; // Fly | 97 | { 0.4, 0.7, 1.0 } }; // Fly |
98 | 98 | ||
99 | double SFCave::MaxUpThrustVals[3][3] = {{ -3.5, -3.5, -3.5 }, // SFCave | 99 | double SFCave::MaxUpThrustVals[3][3] = {{ -3.5, -3.5, -3.5 }, // SFCave |
100 | { -3.5, -4.0, -5.0 }, // Gates | 100 | { -3.5, -4.0, -5.0 }, // Gates |
101 | { -3.5, -4.0, -5.0 } }; // Fly | 101 | { -3.5, -4.0, -5.0 } }; // Fly |
102 | 102 | ||
103 | double SFCave::MaxDownThrustVals[3][3] = {{ 4.0, 4.0, 4.0 }, // SFCave | 103 | double SFCave::MaxDownThrustVals[3][3] = {{ 4.0, 4.0, 4.0 }, // SFCave |
104 | { 4.0, 5.0, 5.5 }, // Gates | 104 | { 4.0, 5.0, 5.5 }, // Gates |
105 | { 3.5, 4.0, 5.0 } }; // Fly | 105 | { 3.5, 4.0, 5.0 } }; // Fly |
106 | 106 | ||
107 | int SFCave::flyEasyScores[7][3] = { { 0, 10, 5 }, | ||
108 | { 10, 20, 3 }, | ||
109 | { 20, 30, 2 }, | ||
110 | { 30, 40, 1 }, | ||
111 | { 50, 70, -2 }, | ||
112 | { 70, 300, -5 }, | ||
113 | { -1, -1, -1 } }; | ||
114 | int SFCave::flyNormalScores[7][3] = { { 0, 10, 5 }, | ||
115 | { 10, 20, 3 }, | ||
116 | { 20, 30, 2 }, | ||
117 | { 30, 40, 1 }, | ||
118 | { 50, 70, -2 }, | ||
119 | { 70, 300, -5 }, | ||
120 | { -1, -1, -1 } }; | ||
121 | int SFCave::flyHardScores[7][3] = { { 0, 20, 5 }, | ||
122 | { 20, 40, 3 }, | ||
123 | { 40, 100, 1 }, | ||
124 | { 100, 150, -2 }, | ||
125 | { 150, 300, -5 }, | ||
126 | { -1, -1, -1 } }; | ||
127 | |||
107 | int SFCave::initialGateGaps[] = { 75, 50, 25 }; | 128 | int SFCave::initialGateGaps[] = { 75, 50, 25 }; |
108 | 129 | ||
109 | 130 | ||
110 | bool movel; | 131 | bool movel; |
111 | 132 | ||
112 | 133 | ||
113 | int main( int argc, char *argv[] ) | 134 | int main( int argc, char *argv[] ) |
114 | { | 135 | { |
115 | movel = true; | 136 | movel = true; |
116 | #ifdef QWS | 137 | #ifdef QWS |
117 | QPEApplication a( argc, argv ); | 138 | QPEApplication a( argc, argv ); |
118 | #else | 139 | #else |
@@ -169,24 +190,25 @@ SFCave :: SFCave( int spd, QWidget *w, char *name ) | |||
169 | 190 | ||
170 | for ( int i = 0 ; i < 3 ; ++i ) | 191 | for ( int i = 0 ; i < 3 ; ++i ) |
171 | { | 192 | { |
172 | for ( int j = 0 ; j < 3 ; ++j ) | 193 | for ( int j = 0 ; j < 3 ; ++j ) |
173 | highestScore[i][j] = cfg.readNumEntry( key + gameTypes[i] + "_" + dificultyOption[j], 0 ); | 194 | highestScore[i][j] = cfg.readNumEntry( key + gameTypes[i] + "_" + dificultyOption[j], 0 ); |
174 | } | 195 | } |
175 | 196 | ||
176 | currentGameType = cfg.readNumEntry( "gameType", 0 ); | 197 | currentGameType = cfg.readNumEntry( "gameType", 0 ); |
177 | currentGameDifficulty = cfg.readNumEntry( "difficulty", 0 ); | 198 | currentGameDifficulty = cfg.readNumEntry( "difficulty", 0 ); |
178 | #endif | 199 | #endif |
179 | speed = spd; // Change to 2 for PC | 200 | speed = spd; // Change to 2 for PC |
180 | press = false; | 201 | press = false; |
202 | showEyeCandy = false; | ||
181 | 203 | ||
182 | offscreen = new QPixmap( sWidth, sHeight ); | 204 | offscreen = new QPixmap( sWidth, sHeight ); |
183 | offscreen->fill( Qt::black ); | 205 | offscreen->fill( Qt::black ); |
184 | 206 | ||
185 | // setUp(); | 207 | // setUp(); |
186 | crashLineLength = -1; | 208 | crashLineLength = -1; |
187 | state = STATE_MENU; | 209 | state = STATE_MENU; |
188 | prevState = STATE_MENU; | 210 | prevState = STATE_MENU; |
189 | 211 | ||
190 | gameTimer = new QTimer( this, "game timer" ); | 212 | gameTimer = new QTimer( this, "game timer" ); |
191 | connect( gameTimer, SIGNAL( timeout() ), | 213 | connect( gameTimer, SIGNAL( timeout() ), |
192 | this, SLOT( run() ) ); | 214 | this, SLOT( run() ) ); |
@@ -217,54 +239,63 @@ int SFCave :: nextInt( int range ) | |||
217 | 239 | ||
218 | return val; | 240 | return val; |
219 | 241 | ||
220 | } | 242 | } |
221 | 243 | ||
222 | void SFCave :: setUp() | 244 | void SFCave :: setUp() |
223 | { | 245 | { |
224 | score = 0; | 246 | score = 0; |
225 | offset = 0; | 247 | offset = 0; |
226 | nrFrames = 0; | 248 | nrFrames = 0; |
227 | dir = 1; | 249 | dir = 1; |
228 | thrust = 0; | 250 | thrust = 0; |
251 | startScoring = false; | ||
252 | press = false; | ||
229 | 253 | ||
230 | if ( CURRENT_GAME_TYPE == SFCAVE_GAME ) | 254 | if ( CURRENT_GAME_TYPE == SFCAVE_GAME ) |
231 | { | 255 | { |
232 | thrustUp = UpThrustVals[SFCAVE_GAME_TYPE][currentGameDifficulty];; | 256 | thrustUp = UpThrustVals[SFCAVE_GAME_TYPE][currentGameDifficulty];; |
233 | noThrust = DownThrustVals[SFCAVE_GAME_TYPE][currentGameDifficulty];; | 257 | noThrust = DownThrustVals[SFCAVE_GAME_TYPE][currentGameDifficulty];; |
234 | maxUpThrust = MaxUpThrustVals[SFCAVE_GAME_TYPE][currentGameDifficulty];; | 258 | maxUpThrust = MaxUpThrustVals[SFCAVE_GAME_TYPE][currentGameDifficulty];; |
235 | maxDownThrust = MaxDownThrustVals[SFCAVE_GAME_TYPE][currentGameDifficulty];; | 259 | maxDownThrust = MaxDownThrustVals[SFCAVE_GAME_TYPE][currentGameDifficulty];; |
236 | 260 | ||
237 | if ( currentGameDifficulty == DIFICULTY_EASY ) | 261 | if ( currentGameDifficulty == DIFICULTY_EASY ) |
238 | gateDistance = 100; | 262 | gateDistance = 100; |
239 | else if ( currentGameDifficulty == DIFICULTY_EASY ) | 263 | else if ( currentGameDifficulty == DIFICULTY_NORMAL ) |
240 | gateDistance = 60; | 264 | gateDistance = 60; |
241 | else | 265 | else |
242 | gateDistance = 40; | 266 | gateDistance = 40; |
243 | } | 267 | } |
244 | else if ( CURRENT_GAME_TYPE == GATES_GAME ) | 268 | else if ( CURRENT_GAME_TYPE == GATES_GAME ) |
245 | { | 269 | { |
246 | thrustUp = UpThrustVals[GATES_GAME_TYPE][currentGameDifficulty];; | 270 | thrustUp = UpThrustVals[GATES_GAME_TYPE][currentGameDifficulty];; |
247 | noThrust = DownThrustVals[GATES_GAME_TYPE][currentGameDifficulty];; | 271 | noThrust = DownThrustVals[GATES_GAME_TYPE][currentGameDifficulty];; |
248 | maxUpThrust = MaxUpThrustVals[GATES_GAME_TYPE][currentGameDifficulty];; | 272 | maxUpThrust = MaxUpThrustVals[GATES_GAME_TYPE][currentGameDifficulty];; |
249 | maxDownThrust = MaxDownThrustVals[GATES_GAME_TYPE][currentGameDifficulty];; | 273 | maxDownThrust = MaxDownThrustVals[GATES_GAME_TYPE][currentGameDifficulty];; |
250 | gateDistance = 75; | 274 | gateDistance = 75; |
251 | nextGate = nextInt( 50 ) + gateDistance; | 275 | nextGate = nextInt( 50 ) + gateDistance; |
252 | } | 276 | } |
253 | else | 277 | else |
254 | { | 278 | { |
255 | thrustUp = UpThrustVals[FLY_GAME_TYPE][currentGameDifficulty]; | 279 | thrustUp = UpThrustVals[FLY_GAME_TYPE][currentGameDifficulty]; |
256 | noThrust = DownThrustVals[FLY_GAME_TYPE][currentGameDifficulty]; | 280 | noThrust = DownThrustVals[FLY_GAME_TYPE][currentGameDifficulty]; |
257 | maxUpThrust = MaxUpThrustVals[FLY_GAME_TYPE][currentGameDifficulty]; | 281 | maxUpThrust = MaxUpThrustVals[FLY_GAME_TYPE][currentGameDifficulty]; |
258 | maxDownThrust = MaxDownThrustVals[FLY_GAME_TYPE][currentGameDifficulty]; | 282 | maxDownThrust = MaxDownThrustVals[FLY_GAME_TYPE][currentGameDifficulty]; |
283 | |||
284 | if ( currentGameDifficulty == DIFICULTY_EASY ) | ||
285 | flyScores = flyEasyScores; | ||
286 | else if ( currentGameDifficulty == DIFICULTY_NORMAL ) | ||
287 | flyScores = flyNormalScores; | ||
288 | else | ||
289 | flyScores = flyHardScores; | ||
259 | } | 290 | } |
260 | 291 | ||
261 | crashLineLength = 0; | 292 | crashLineLength = 0; |
262 | lastGateBottomY = 0; | 293 | lastGateBottomY = 0; |
263 | 294 | ||
264 | user.setRect( 50, sWidth/2, 4, 4 ); | 295 | user.setRect( 50, sWidth/2, 4, 4 ); |
265 | 296 | ||
266 | blockWidth = 20; | 297 | blockWidth = 20; |
267 | blockHeight = 70; | 298 | blockHeight = 70; |
268 | gapHeight = initialGateGaps[currentGameDifficulty]; | 299 | gapHeight = initialGateGaps[currentGameDifficulty]; |
269 | 300 | ||
270 | for ( int i = 0 ; i < TRAILSIZE ; ++i ) | 301 | for ( int i = 0 ; i < TRAILSIZE ; ++i ) |
@@ -309,30 +340,32 @@ void SFCave :: run() | |||
309 | replay = false; | 340 | replay = false; |
310 | replayList.clear(); | 341 | replayList.clear(); |
311 | break; | 342 | break; |
312 | case STATE_REPLAY: | 343 | case STATE_REPLAY: |
313 | setSeed( currentSeed ); | 344 | setSeed( currentSeed ); |
314 | setUp(); | 345 | setUp(); |
315 | draw(); | 346 | draw(); |
316 | state = STATE_RUNNING; | 347 | state = STATE_RUNNING; |
317 | replay = true; | 348 | replay = true; |
318 | if ( replayIt ) | 349 | if ( replayIt ) |
319 | delete replayIt; | 350 | delete replayIt; |
320 | replayIt = new QListIterator<int>( replayList ); | 351 | replayIt = new QListIterator<int>( replayList ); |
352 | break; | ||
321 | case STATE_BOSS: | 353 | case STATE_BOSS: |
322 | drawBoss(); | 354 | drawBoss(); |
323 | break; | 355 | break; |
324 | 356 | ||
325 | case STATE_CRASHING: | 357 | case STATE_CRASHING: |
326 | case STATE_CRASHED: | 358 | case STATE_CRASHED: |
359 | press = false; | ||
327 | draw(); | 360 | draw(); |
328 | break; | 361 | break; |
329 | 362 | ||
330 | case STATE_RUNNING: | 363 | case STATE_RUNNING: |
331 | { | 364 | { |
332 | if ( nrFrames % 2 == 0 ) | 365 | if ( nrFrames % 2 == 0 ) |
333 | handleKeys(); | 366 | handleKeys(); |
334 | 367 | ||
335 | // Apply Game rules | 368 | // Apply Game rules |
336 | nrFrames ++; | 369 | nrFrames ++; |
337 | 370 | ||
338 | if ( replay ) | 371 | if ( replay ) |
@@ -423,39 +456,49 @@ void SFCave :: handleGameGates() | |||
423 | } | 456 | } |
424 | state = STATE_CRASHING; | 457 | state = STATE_CRASHING; |
425 | } | 458 | } |
426 | else | 459 | else |
427 | { | 460 | { |
428 | moveLandscape(); | 461 | moveLandscape(); |
429 | } | 462 | } |
430 | 463 | ||
431 | } | 464 | } |
432 | 465 | ||
433 | void SFCave :: handleGameFly() | 466 | void SFCave :: handleGameFly() |
434 | { | 467 | { |
468 | int diff = mapBottom[10] - user.y(); | ||
469 | |||
435 | if ( nrFrames % 4 == 0 ) | 470 | if ( nrFrames % 4 == 0 ) |
436 | { | 471 | { |
437 | // Update score | 472 | if ( !startScoring ) |
438 | // get distance between landscape and ship | 473 | { |
439 | int diff = mapBottom[10] - user.y(); | 474 | if ( diff < 40 ) |
440 | 475 | startScoring = true; | |
441 | // the closer the difference is to 0 means more points | 476 | } |
442 | if ( diff < 10 ) | 477 | |
443 | score += 5; | 478 | if ( startScoring ) |
444 | else if ( diff < 20 ) | 479 | { |
445 | score += 3; | 480 | // Update score |
446 | else if ( diff < 30 ) | 481 | // get distance between landscape and ship |
447 | score += 2; | 482 | |
448 | else if ( diff < 40 ) | 483 | // the closer the difference is to 0 means more points |
449 | score += 1; | 484 | for ( int i = 0 ; i < 10 && flyScores[i][0] != -1 ; ++i ) |
485 | { | ||
486 | if ( flyScores[i][0] <= diff && flyScores[i][1] > diff ) | ||
487 | { | ||
488 | score += flyScores[i][2]; | ||
489 | break; | ||
490 | } | ||
491 | } | ||
492 | } | ||
450 | } | 493 | } |
451 | 494 | ||
452 | if ( checkFlyGameCollision() ) | 495 | if ( checkFlyGameCollision() ) |
453 | { | 496 | { |
454 | if ( score > highestScore[currentGameType][currentGameDifficulty] ) | 497 | if ( score > highestScore[currentGameType][currentGameDifficulty] ) |
455 | { | 498 | { |
456 | highestScore[currentGameType][currentGameDifficulty] = score; | 499 | highestScore[currentGameType][currentGameDifficulty] = score; |
457 | saveScore(); | 500 | saveScore(); |
458 | } | 501 | } |
459 | state = STATE_CRASHING; | 502 | state = STATE_CRASHING; |
460 | } | 503 | } |
461 | else | 504 | else |
@@ -641,46 +684,55 @@ void SFCave :: draw() | |||
641 | p.setPen( Qt::white ); | 684 | p.setPen( Qt::white ); |
642 | 685 | ||
643 | for ( int i = 0 ; i < MAPSIZE -3; ++i ) | 686 | for ( int i = 0 ; i < MAPSIZE -3; ++i ) |
644 | { | 687 | { |
645 | // Only display top landscape if not running FLY_GAME | 688 | // Only display top landscape if not running FLY_GAME |
646 | if ( CURRENT_GAME_TYPE != FLY_GAME ) | 689 | if ( CURRENT_GAME_TYPE != FLY_GAME ) |
647 | p.drawLine( (i*segSize) - (offset*speed), mapTop[i], ((i+1)*segSize)-(offset*speed), mapTop[i+1] ); | 690 | p.drawLine( (i*segSize) - (offset*speed), mapTop[i], ((i+1)*segSize)-(offset*speed), mapTop[i+1] ); |
648 | 691 | ||
649 | p.drawLine( (i*segSize) - (offset*speed), mapBottom[i], ((i+1)*segSize)-(offset*speed), mapBottom[i+1] ); | 692 | p.drawLine( (i*segSize) - (offset*speed), mapBottom[i], ((i+1)*segSize)-(offset*speed), mapBottom[i+1] ); |
650 | 693 | ||
651 | if ( CURRENT_GAME_TYPE == FLY_GAME && showScoreZones ) | 694 | if ( CURRENT_GAME_TYPE == FLY_GAME && showScoreZones ) |
652 | { | 695 | { |
653 | p.setPen( Qt::red ); | 696 | p.setPen( Qt::blue ); |
654 | p.drawLine( (i*segSize) - (offset*speed), mapBottom[i]-10, ((i+1)*segSize)-(offset*speed), mapBottom[i+1]-10 ); | 697 | for ( int j = 1 ; j < 10 && flyScores[j][0] != -1 ; ++j ) |
655 | p.drawLine( (i*segSize) - (offset*speed), mapBottom[i]-20, ((i+1)*segSize)-(offset*speed), mapBottom[i+1]-20 ); | 698 | { |
656 | p.drawLine( (i*segSize) - (offset*speed), mapBottom[i]-30, ((i+1)*segSize)-(offset*speed), mapBottom[i+1]-30 ); | 699 | if ( flyScores[j][2] < 0 ) |
657 | p.drawLine( (i*segSize) - (offset*speed), mapBottom[i]-40, ((i+1)*segSize)-(offset*speed), mapBottom[i+1]-40 ); | 700 | p.setPen( Qt::red ); |
701 | |||
702 | p.drawLine( (i*segSize) - (offset*speed), mapBottom[i]-flyScores[j][0], ((i+1)*segSize)-(offset*speed), mapBottom[i+1]-flyScores[j][0] ); | ||
703 | } | ||
704 | |||
658 | p.setPen( Qt::white ); | 705 | p.setPen( Qt::white ); |
659 | } | 706 | } |
660 | } | 707 | } |
661 | 708 | ||
662 | // Uncomment this to show user segment (usful for checking collision boundary with landscape | 709 | // Uncomment this to show user segment (usful for checking collision boundary with landscape |
663 | // p.setPen( Qt::red ); | 710 | // p.setPen( Qt::red ); |
664 | // p.drawLine( (11*segSize) - (offset*speed), 0, ((11)*segSize)-(offset*speed), sHeight ); | 711 | // p.drawLine( (11*segSize) - (offset*speed), 0, ((11)*segSize)-(offset*speed), sHeight ); |
665 | // p.setPen( Qt::white ); | 712 | // p.setPen( Qt::white ); |
666 | 713 | ||
667 | // Draw user | 714 | // Draw user |
668 | p.drawRect( user ); | 715 | p.drawRect( user ); |
669 | 716 | ||
670 | // Draw trails | 717 | // Draw trails |
671 | for ( int i = 0 ; i < TRAILSIZE ; ++i ) | 718 | for ( int i = 0 ; i < TRAILSIZE ; ++i ) |
672 | if ( trail[i].x() >= 0 ) | 719 | if ( trail[i].x() >= 0 ) |
720 | { | ||
721 | if ( showEyeCandy ) | ||
722 | p.setPen( Qt::white.light((int)(100.0-3*(user.x()/100.0)* (user.x()-trail[i].x())) ) ); | ||
673 | p.drawRect( trail[i].x(), trail[i].y(), 2, 2 ); | 723 | p.drawRect( trail[i].x(), trail[i].y(), 2, 2 ); |
724 | } | ||
674 | 725 | ||
726 | p.setPen( Qt::white ); | ||
675 | // Draw blocks | 727 | // Draw blocks |
676 | for ( int i = 0 ; i < BLOCKSIZE ; ++i ) | 728 | for ( int i = 0 ; i < BLOCKSIZE ; ++i ) |
677 | if ( blocks[i].y() != -1 ) | 729 | if ( blocks[i].y() != -1 ) |
678 | { | 730 | { |
679 | p.fillRect( blocks[i], Qt::black ); | 731 | p.fillRect( blocks[i], Qt::black ); |
680 | p.drawRect( blocks[i] ); | 732 | p.drawRect( blocks[i] ); |
681 | } | 733 | } |
682 | 734 | ||
683 | // draw score | 735 | // draw score |
684 | QString s; | 736 | QString s; |
685 | s.sprintf( "score %06d high score %06d", score, highestScore[currentGameType][currentGameDifficulty] ); | 737 | s.sprintf( "score %06d high score %06d", score, highestScore[currentGameType][currentGameDifficulty] ); |
686 | p.drawText( 5, 10, s ); | 738 | p.drawText( 5, 10, s ); |
@@ -779,31 +831,38 @@ void SFCave :: handleKeys() | |||
779 | 831 | ||
780 | void SFCave :: keyPressEvent( QKeyEvent *e ) | 832 | void SFCave :: keyPressEvent( QKeyEvent *e ) |
781 | { | 833 | { |
782 | if ( state == STATE_MENU ) | 834 | if ( state == STATE_MENU ) |
783 | handleMenuKeys( e ); | 835 | handleMenuKeys( e ); |
784 | else | 836 | else |
785 | { | 837 | { |
786 | switch( e->key() ) | 838 | switch( e->key() ) |
787 | { | 839 | { |
788 | case Qt::Key_Up: | 840 | case Qt::Key_Up: |
789 | case Qt::Key_F9: | 841 | case Qt::Key_F9: |
790 | case Qt::Key_Space: | 842 | case Qt::Key_Space: |
791 | if ( state == STATE_RUNNING && !replay && !press ) | 843 | if ( state == STATE_RUNNING ) |
792 | { | 844 | { |
793 | press = true; | 845 | if ( !replay && !press ) |
794 | replayList.append( new int( nrFrames ) ); | 846 | { |
847 | press = true; | ||
848 | replayList.append( new int( nrFrames ) ); | ||
849 | } | ||
795 | } | 850 | } |
796 | else if ( state == STATE_CRASHED && e->key() == Key_Up ) | 851 | else if ( state == STATE_CRASHED ) |
797 | state = STATE_NEWGAME; | 852 | { |
853 | if ( e->key() == Key_Up ) | ||
854 | state = STATE_NEWGAME; | ||
855 | } | ||
856 | |||
798 | break; | 857 | break; |
799 | case Qt::Key_M: | 858 | case Qt::Key_M: |
800 | case Qt::Key_Return: | 859 | case Qt::Key_Return: |
801 | case Qt::Key_Enter: | 860 | case Qt::Key_Enter: |
802 | if ( state == STATE_CRASHED ) | 861 | if ( state == STATE_CRASHED ) |
803 | { | 862 | { |
804 | state = STATE_MENU; | 863 | state = STATE_MENU; |
805 | currentMenuNr = 0; | 864 | currentMenuNr = 0; |
806 | currentMenuOption[currentMenuNr] = 0; | 865 | currentMenuOption[currentMenuNr] = 0; |
807 | } | 866 | } |
808 | break; | 867 | break; |
809 | 868 | ||
@@ -821,35 +880,41 @@ void SFCave :: keyPressEvent( QKeyEvent *e ) | |||
821 | void SFCave :: keyReleaseEvent( QKeyEvent *e ) | 880 | void SFCave :: keyReleaseEvent( QKeyEvent *e ) |
822 | { | 881 | { |
823 | if ( state == STATE_MENU ) | 882 | if ( state == STATE_MENU ) |
824 | { | 883 | { |
825 | } | 884 | } |
826 | else | 885 | else |
827 | { | 886 | { |
828 | switch( e->key() ) | 887 | switch( e->key() ) |
829 | { | 888 | { |
830 | case Qt::Key_F9: | 889 | case Qt::Key_F9: |
831 | case Qt::Key_Space: | 890 | case Qt::Key_Space: |
832 | case Qt::Key_Up: | 891 | case Qt::Key_Up: |
833 | press = false; | 892 | if ( state == STATE_RUNNING ) |
834 | if ( state == STATE_RUNNING && !replay && press ) | 893 | { |
835 | replayList.append( new int( nrFrames ) ); | 894 | if ( !replay && press ) |
836 | 895 | { | |
896 | press = false; | ||
897 | replayList.append( new int( nrFrames ) ); | ||
898 | } | ||
899 | } | ||
837 | break; | 900 | break; |
838 | 901 | ||
902 | case Qt::Key_E: | ||
903 | showEyeCandy = !showEyeCandy; | ||
904 | break; | ||
905 | |||
839 | case Qt::Key_R: | 906 | case Qt::Key_R: |
840 | if ( state == STATE_CRASHED ) | 907 | if ( state == STATE_CRASHED ) |
841 | { | ||
842 | state = STATE_REPLAY; | 908 | state = STATE_REPLAY; |
843 | } | ||
844 | break; | 909 | break; |
845 | 910 | ||
846 | case Qt::Key_Down: | 911 | case Qt::Key_Down: |
847 | if ( state == STATE_CRASHED ) | 912 | if ( state == STATE_CRASHED ) |
848 | state = STATE_NEWGAME; | 913 | state = STATE_NEWGAME; |
849 | break; | 914 | break; |
850 | 915 | ||
851 | case Qt::Key_S: | 916 | case Qt::Key_S: |
852 | if ( state == STATE_CRASHED ) | 917 | if ( state == STATE_CRASHED ) |
853 | saveReplay(); | 918 | saveReplay(); |
854 | break; | 919 | break; |
855 | 920 | ||
diff --git a/noncore/games/sfcave/sfcave.h b/noncore/games/sfcave/sfcave.h index 65e5ae4..f95558d 100644 --- a/noncore/games/sfcave/sfcave.h +++ b/noncore/games/sfcave/sfcave.h | |||
@@ -29,30 +29,38 @@ public: | |||
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; | ||
42 | bool showEyeCandy; | ||
41 | 43 | ||
42 | static double UpThrustVals[3][3]; | 44 | static double UpThrustVals[3][3]; |
43 | static double DownThrustVals[3][3]; | 45 | static double DownThrustVals[3][3]; |
44 | static double MaxUpThrustVals[3][3]; | 46 | static double MaxUpThrustVals[3][3]; |
45 | static double MaxDownThrustVals[3][3]; | 47 | static double MaxDownThrustVals[3][3]; |
46 | static int initialGateGaps[]; | 48 | static int initialGateGaps[]; |
49 | |||
50 | static int flyEasyScores[7][3]; | ||
51 | static int flyNormalScores[7][3]; | ||
52 | static int flyHardScores[7][3]; | ||
53 | int flyScores[7][3]; | ||
54 | |||
47 | 55 | ||
48 | double thrustUp; | 56 | double thrustUp; |
49 | double noThrust; | 57 | double noThrust; |
50 | double maxUpThrust; | 58 | double maxUpThrust; |
51 | double maxDownThrust; | 59 | double maxDownThrust; |
52 | 60 | ||
53 | int gateDistance; | 61 | int gateDistance; |
54 | int nextGate; | 62 | int nextGate; |
55 | int lastGateBottomY; | 63 | int lastGateBottomY; |
56 | 64 | ||
57 | static QString menuOptions[NR_MENUS][MAX_MENU_OPTIONS]; | 65 | static QString menuOptions[NR_MENUS][MAX_MENU_OPTIONS]; |
58 | int currentMenuNr; | 66 | int currentMenuNr; |