author | andyq <andyq> | 2002-12-21 18:37:35 (UTC) |
---|---|---|
committer | andyq <andyq> | 2002-12-21 18:37:35 (UTC) |
commit | c32f49c53600fe2aa5d9610221b73c08499ffd69 (patch) (unidiff) | |
tree | 292aa0137fe6b2cd7e7eb7dd84cefa05f36216ab | |
parent | 491ac1e10a2caceb5003b0649f0cb0131e9b81fd (diff) | |
download | opie-c32f49c53600fe2aa5d9610221b73c08499ffd69.zip opie-c32f49c53600fe2aa5d9610221b73c08499ffd69.tar.gz opie-c32f49c53600fe2aa5d9610221b73c08499ffd69.tar.bz2 |
Added bit of eye candy - press 'e' to make smoke trails fade out (at expense of a little speed), and made fly game scoring zones better
-rw-r--r-- | noncore/games/sfcave/sfcave.cpp | 105 | ||||
-rw-r--r-- | noncore/games/sfcave/sfcave.h | 8 |
2 files changed, 93 insertions, 20 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 | |||
@@ -16,3 +16,3 @@ | |||
16 | 16 | ||
17 | #define CAPTION "SFCave 1.12 by AndyQ" | 17 | #define CAPTION "SFCave 1.13 by AndyQ" |
18 | 18 | ||
@@ -106,2 +106,23 @@ double SFCave::MaxDownThrustVals[3][3] = {{ 4.0, 4.0, 4.0 }, // S | |||
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 }; |
@@ -180,2 +201,3 @@ SFCave :: SFCave( int spd, QWidget *w, char *name ) | |||
180 | press = false; | 201 | press = false; |
202 | showEyeCandy = false; | ||
181 | 203 | ||
@@ -228,2 +250,4 @@ void SFCave :: setUp() | |||
228 | thrust = 0; | 250 | thrust = 0; |
251 | startScoring = false; | ||
252 | press = false; | ||
229 | 253 | ||
@@ -238,3 +262,3 @@ void SFCave :: setUp() | |||
238 | gateDistance = 100; | 262 | gateDistance = 100; |
239 | else if ( currentGameDifficulty == DIFICULTY_EASY ) | 263 | else if ( currentGameDifficulty == DIFICULTY_NORMAL ) |
240 | gateDistance = 60; | 264 | gateDistance = 60; |
@@ -258,2 +282,9 @@ void SFCave :: setUp() | |||
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 | } |
@@ -320,2 +351,3 @@ void SFCave :: run() | |||
320 | replayIt = new QListIterator<int>( replayList ); | 351 | replayIt = new QListIterator<int>( replayList ); |
352 | break; | ||
321 | case STATE_BOSS: | 353 | case STATE_BOSS: |
@@ -326,2 +358,3 @@ void SFCave :: run() | |||
326 | case STATE_CRASHED: | 358 | case STATE_CRASHED: |
359 | press = false; | ||
327 | draw(); | 360 | draw(); |
@@ -434,17 +467,27 @@ 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 | { |
472 | if ( !startScoring ) | ||
473 | { | ||
474 | if ( diff < 40 ) | ||
475 | startScoring = true; | ||
476 | } | ||
477 | |||
478 | if ( startScoring ) | ||
479 | { | ||
437 | // Update score | 480 | // Update score |
438 | // get distance between landscape and ship | 481 | // get distance between landscape and ship |
439 | int diff = mapBottom[10] - user.y(); | ||
440 | 482 | ||
441 | // the closer the difference is to 0 means more points | 483 | // the closer the difference is to 0 means more points |
442 | if ( diff < 10 ) | 484 | for ( int i = 0 ; i < 10 && flyScores[i][0] != -1 ; ++i ) |
443 | score += 5; | 485 | { |
444 | else if ( diff < 20 ) | 486 | if ( flyScores[i][0] <= diff && flyScores[i][1] > diff ) |
445 | score += 3; | 487 | { |
446 | else if ( diff < 30 ) | 488 | score += flyScores[i][2]; |
447 | score += 2; | 489 | break; |
448 | else if ( diff < 40 ) | 490 | } |
449 | score += 1; | 491 | } |
492 | } | ||
450 | } | 493 | } |
@@ -652,7 +695,11 @@ void SFCave :: draw() | |||
652 | { | 695 | { |
696 | p.setPen( Qt::blue ); | ||
697 | for ( int j = 1 ; j < 10 && flyScores[j][0] != -1 ; ++j ) | ||
698 | { | ||
699 | if ( flyScores[j][2] < 0 ) | ||
653 | p.setPen( Qt::red ); | 700 | p.setPen( Qt::red ); |
654 | p.drawLine( (i*segSize) - (offset*speed), mapBottom[i]-10, ((i+1)*segSize)-(offset*speed), mapBottom[i+1]-10 ); | 701 | |
655 | p.drawLine( (i*segSize) - (offset*speed), mapBottom[i]-20, ((i+1)*segSize)-(offset*speed), mapBottom[i+1]-20 ); | 702 | p.drawLine( (i*segSize) - (offset*speed), mapBottom[i]-flyScores[j][0], ((i+1)*segSize)-(offset*speed), mapBottom[i+1]-flyScores[j][0] ); |
656 | p.drawLine( (i*segSize) - (offset*speed), mapBottom[i]-30, ((i+1)*segSize)-(offset*speed), mapBottom[i+1]-30 ); | 703 | } |
657 | p.drawLine( (i*segSize) - (offset*speed), mapBottom[i]-40, ((i+1)*segSize)-(offset*speed), mapBottom[i+1]-40 ); | 704 | |
658 | p.setPen( Qt::white ); | 705 | p.setPen( Qt::white ); |
@@ -672,4 +719,9 @@ void SFCave :: draw() | |||
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 |
@@ -790,3 +842,5 @@ void SFCave :: keyPressEvent( QKeyEvent *e ) | |||
790 | case Qt::Key_Space: | 842 | case Qt::Key_Space: |
791 | if ( state == STATE_RUNNING && !replay && !press ) | 843 | if ( state == STATE_RUNNING ) |
844 | { | ||
845 | if ( !replay && !press ) | ||
792 | { | 846 | { |
@@ -795,4 +849,9 @@ void SFCave :: keyPressEvent( QKeyEvent *e ) | |||
795 | } | 849 | } |
796 | else if ( state == STATE_CRASHED && e->key() == Key_Up ) | 850 | } |
851 | else if ( state == STATE_CRASHED ) | ||
852 | { | ||
853 | if ( e->key() == Key_Up ) | ||
797 | state = STATE_NEWGAME; | 854 | state = STATE_NEWGAME; |
855 | } | ||
856 | |||
798 | break; | 857 | break; |
@@ -832,6 +891,14 @@ void SFCave :: keyReleaseEvent( QKeyEvent *e ) | |||
832 | case Qt::Key_Up: | 891 | case Qt::Key_Up: |
892 | if ( state == STATE_RUNNING ) | ||
893 | { | ||
894 | if ( !replay && press ) | ||
895 | { | ||
833 | press = false; | 896 | press = false; |
834 | if ( state == STATE_RUNNING && !replay && press ) | ||
835 | replayList.append( new int( nrFrames ) ); | 897 | replayList.append( new int( nrFrames ) ); |
898 | } | ||
899 | } | ||
900 | break; | ||
836 | 901 | ||
902 | case Qt::Key_E: | ||
903 | showEyeCandy = !showEyeCandy; | ||
837 | break; | 904 | break; |
@@ -840,5 +907,3 @@ void SFCave :: keyReleaseEvent( QKeyEvent *e ) | |||
840 | if ( state == STATE_CRASHED ) | 907 | if ( state == STATE_CRASHED ) |
841 | { | ||
842 | state = STATE_REPLAY; | 908 | state = STATE_REPLAY; |
843 | } | ||
844 | break; | 909 | break; |
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 | |||
@@ -40,2 +40,4 @@ public: | |||
40 | int crashLineLength; | 40 | int crashLineLength; |
41 | bool startScoring; | ||
42 | bool showEyeCandy; | ||
41 | 43 | ||
@@ -47,2 +49,8 @@ public: | |||
47 | 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 | |||
55 | |||
48 | double thrustUp; | 56 | double thrustUp; |