author | andyq <andyq> | 2002-12-21 18:37:35 (UTC) |
---|---|---|
committer | andyq <andyq> | 2002-12-21 18:37:35 (UTC) |
commit | c32f49c53600fe2aa5d9610221b73c08499ffd69 (patch) (side-by-side diff) | |
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 | 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 @@ -16,3 +16,3 @@ -#define CAPTION "SFCave 1.12 by AndyQ" +#define CAPTION "SFCave 1.13 by AndyQ" @@ -106,2 +106,23 @@ double SFCave::MaxDownThrustVals[3][3] = {{ 4.0, 4.0, 4.0 }, // S +int SFCave::flyEasyScores[7][3] = { { 0, 10, 5 }, + { 10, 20, 3 }, + { 20, 30, 2 }, + { 30, 40, 1 }, + { 50, 70, -2 }, + { 70, 300, -5 }, + { -1, -1, -1 } }; +int SFCave::flyNormalScores[7][3] = { { 0, 10, 5 }, + { 10, 20, 3 }, + { 20, 30, 2 }, + { 30, 40, 1 }, + { 50, 70, -2 }, + { 70, 300, -5 }, + { -1, -1, -1 } }; +int SFCave::flyHardScores[7][3] = { { 0, 20, 5 }, + { 20, 40, 3 }, + { 40, 100, 1 }, + { 100, 150, -2 }, + { 150, 300, -5 }, + { -1, -1, -1 } }; + int SFCave::initialGateGaps[] = { 75, 50, 25 }; @@ -180,2 +201,3 @@ SFCave :: SFCave( int spd, QWidget *w, char *name ) press = false; + showEyeCandy = false; @@ -228,2 +250,4 @@ void SFCave :: setUp() thrust = 0; + startScoring = false; + press = false; @@ -238,3 +262,3 @@ void SFCave :: setUp() gateDistance = 100; - else if ( currentGameDifficulty == DIFICULTY_EASY ) + else if ( currentGameDifficulty == DIFICULTY_NORMAL ) gateDistance = 60; @@ -258,2 +282,9 @@ void SFCave :: setUp() maxDownThrust = MaxDownThrustVals[FLY_GAME_TYPE][currentGameDifficulty]; + + if ( currentGameDifficulty == DIFICULTY_EASY ) + flyScores = flyEasyScores; + else if ( currentGameDifficulty == DIFICULTY_NORMAL ) + flyScores = flyNormalScores; + else + flyScores = flyHardScores; } @@ -320,2 +351,3 @@ void SFCave :: run() replayIt = new QListIterator<int>( replayList ); + break; case STATE_BOSS: @@ -326,2 +358,3 @@ void SFCave :: run() case STATE_CRASHED: + press = false; draw(); @@ -434,17 +467,27 @@ void SFCave :: handleGameFly() { + int diff = mapBottom[10] - user.y(); + if ( nrFrames % 4 == 0 ) { - // Update score - // get distance between landscape and ship - int diff = mapBottom[10] - user.y(); - - // the closer the difference is to 0 means more points - if ( diff < 10 ) - score += 5; - else if ( diff < 20 ) - score += 3; - else if ( diff < 30 ) - score += 2; - else if ( diff < 40 ) - score += 1; + if ( !startScoring ) + { + if ( diff < 40 ) + startScoring = true; + } + + if ( startScoring ) + { + // Update score + // get distance between landscape and ship + + // the closer the difference is to 0 means more points + for ( int i = 0 ; i < 10 && flyScores[i][0] != -1 ; ++i ) + { + if ( flyScores[i][0] <= diff && flyScores[i][1] > diff ) + { + score += flyScores[i][2]; + break; + } + } + } } @@ -652,7 +695,11 @@ void SFCave :: draw() { - p.setPen( Qt::red ); - p.drawLine( (i*segSize) - (offset*speed), mapBottom[i]-10, ((i+1)*segSize)-(offset*speed), mapBottom[i+1]-10 ); - p.drawLine( (i*segSize) - (offset*speed), mapBottom[i]-20, ((i+1)*segSize)-(offset*speed), mapBottom[i+1]-20 ); - p.drawLine( (i*segSize) - (offset*speed), mapBottom[i]-30, ((i+1)*segSize)-(offset*speed), mapBottom[i+1]-30 ); - p.drawLine( (i*segSize) - (offset*speed), mapBottom[i]-40, ((i+1)*segSize)-(offset*speed), mapBottom[i+1]-40 ); + p.setPen( Qt::blue ); + for ( int j = 1 ; j < 10 && flyScores[j][0] != -1 ; ++j ) + { + if ( flyScores[j][2] < 0 ) + p.setPen( Qt::red ); + + p.drawLine( (i*segSize) - (offset*speed), mapBottom[i]-flyScores[j][0], ((i+1)*segSize)-(offset*speed), mapBottom[i+1]-flyScores[j][0] ); + } + p.setPen( Qt::white ); @@ -672,4 +719,9 @@ void SFCave :: draw() if ( trail[i].x() >= 0 ) + { + if ( showEyeCandy ) + p.setPen( Qt::white.light((int)(100.0-3*(user.x()/100.0)* (user.x()-trail[i].x())) ) ); p.drawRect( trail[i].x(), trail[i].y(), 2, 2 ); + } + p.setPen( Qt::white ); // Draw blocks @@ -790,9 +842,16 @@ void SFCave :: keyPressEvent( QKeyEvent *e ) case Qt::Key_Space: - if ( state == STATE_RUNNING && !replay && !press ) + if ( state == STATE_RUNNING ) { - press = true; - replayList.append( new int( nrFrames ) ); + if ( !replay && !press ) + { + press = true; + replayList.append( new int( nrFrames ) ); + } } - else if ( state == STATE_CRASHED && e->key() == Key_Up ) - state = STATE_NEWGAME; + else if ( state == STATE_CRASHED ) + { + if ( e->key() == Key_Up ) + state = STATE_NEWGAME; + } + break; @@ -832,13 +891,19 @@ void SFCave :: keyReleaseEvent( QKeyEvent *e ) case Qt::Key_Up: - press = false; - if ( state == STATE_RUNNING && !replay && press ) - replayList.append( new int( nrFrames ) ); - + if ( state == STATE_RUNNING ) + { + if ( !replay && press ) + { + press = false; + replayList.append( new int( nrFrames ) ); + } + } break; + case Qt::Key_E: + showEyeCandy = !showEyeCandy; + break; + case Qt::Key_R: if ( state == STATE_CRASHED ) - { state = STATE_REPLAY; - } 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: int crashLineLength; + bool startScoring; + bool showEyeCandy; @@ -46,2 +48,8 @@ public: static int initialGateGaps[]; + + static int flyEasyScores[7][3]; + static int flyNormalScores[7][3]; + static int flyHardScores[7][3]; + int flyScores[7][3]; + |