author | andyq <andyq> | 2003-01-23 22:40:43 (UTC) |
---|---|---|
committer | andyq <andyq> | 2003-01-23 22:40:43 (UTC) |
commit | d3b2ab85a765cd3c0b403f5b5ac2f9b92c22de38 (patch) (unidiff) | |
tree | e348c9237b0f5c0cb62c2d5d9bdc9e1a4ba19263 | |
parent | 0c31038ab4daf7d4ef5b58e8973fa9f4f91cb826 (diff) | |
download | opie-d3b2ab85a765cd3c0b403f5b5ac2f9b92c22de38.zip opie-d3b2ab85a765cd3c0b403f5b5ac2f9b92c22de38.tar.gz opie-d3b2ab85a765cd3c0b403f5b5ac2f9b92c22de38.tar.bz2 |
Fixed gcc 3.2 compile issue (hopefully)
-rw-r--r-- | noncore/games/sfcave/sfcave.cpp | 19 | ||||
-rw-r--r-- | noncore/games/sfcave/sfcave.h | 2 |
2 files changed, 11 insertions, 10 deletions
diff --git a/noncore/games/sfcave/sfcave.cpp b/noncore/games/sfcave/sfcave.cpp index d6d28b2..9b30fe6 100644 --- a/noncore/games/sfcave/sfcave.cpp +++ b/noncore/games/sfcave/sfcave.cpp | |||
@@ -107,48 +107,49 @@ double SFCave::MaxDownThrustVals[3][3] = {{ 4.0, 4.0, 4.0 }, // S | |||
107 | int SFCave::flyEasyScores[7][3] = { { 0, 10, 5 }, | 107 | int SFCave::flyEasyScores[7][3] = { { 0, 10, 5 }, |
108 | { 10, 20, 3 }, | 108 | { 10, 20, 3 }, |
109 | { 20, 30, 2 }, | 109 | { 20, 30, 2 }, |
110 | { 30, 40, 1 }, | 110 | { 30, 40, 1 }, |
111 | { 50, 70, -2 }, | 111 | { 50, 70, -2 }, |
112 | { 70, 300, -5 }, | 112 | { 70, 300, -5 }, |
113 | { -1, -1, -1 } }; | 113 | { -1, -1, -1 } }; |
114 | int SFCave::flyNormalScores[7][3] = { { 0, 10, 5 }, | 114 | int SFCave::flyNormalScores[7][3] = { { 0, 10, 5 }, |
115 | { 10, 20, 3 }, | 115 | { 10, 20, 3 }, |
116 | { 20, 30, 2 }, | 116 | { 20, 30, 2 }, |
117 | { 30, 40, 1 }, | 117 | { 30, 40, 1 }, |
118 | { 50, 70, -2 }, | 118 | { 50, 70, -2 }, |
119 | { 70, 300, -5 }, | 119 | { 70, 300, -5 }, |
120 | { -1, -1, -1 } }; | 120 | { -1, -1, -1 } }; |
121 | int SFCave::flyHardScores[7][3] = { { 0, 20, 5 }, | 121 | int SFCave::flyHardScores[7][3] = { { 0, 20, 5 }, |
122 | { 20, 40, 3 }, | 122 | { 20, 40, 3 }, |
123 | { 40, 100, 1 }, | 123 | { 40, 100, 1 }, |
124 | { 100, 150, -2 }, | 124 | { 100, 150, -2 }, |
125 | { 150, 300, -5 }, | 125 | { 150, 300, -5 }, |
126 | { -1, -1, -1 } }; | 126 | { -1, -1, -1 } }; |
127 | 127 | ||
128 | int SFCave::initialGateGaps[] = { 75, 50, 25 }; | 128 | int SFCave::initialGateGaps[] = { 75, 50, 25 }; |
129 | 129 | ||
130 | 130 | ||
131 | #define FLYSCORES( x, y ) (*(flyScores + ((x)*3) + y)) | ||
131 | bool movel; | 132 | bool movel; |
132 | 133 | ||
133 | 134 | ||
134 | int main( int argc, char *argv[] ) | 135 | int main( int argc, char *argv[] ) |
135 | { | 136 | { |
136 | movel = true; | 137 | movel = true; |
137 | #ifdef QWS | 138 | #ifdef QWS |
138 | QPEApplication a( argc, argv ); | 139 | QPEApplication a( argc, argv ); |
139 | #else | 140 | #else |
140 | QApplication a( argc, argv ); | 141 | QApplication a( argc, argv ); |
141 | #endif | 142 | #endif |
142 | 143 | ||
143 | int speed = 3; | 144 | int speed = 3; |
144 | for ( int i = 0 ; i < argc ; ++i ) | 145 | for ( int i = 0 ; i < argc ; ++i ) |
145 | { | 146 | { |
146 | if ( strcmp( argv[i], "-s" ) == 0 ) | 147 | if ( strcmp( argv[i], "-s" ) == 0 ) |
147 | { | 148 | { |
148 | if ( i+1 < argc ) | 149 | if ( i+1 < argc ) |
149 | speed = atoi( argv[i+1] ); | 150 | speed = atoi( argv[i+1] ); |
150 | } | 151 | } |
151 | } | 152 | } |
152 | 153 | ||
153 | SFCave app( speed ); | 154 | SFCave app( speed ); |
154 | a.setMainWidget( &app ); | 155 | a.setMainWidget( &app ); |
@@ -261,53 +262,53 @@ void SFCave :: setUp() | |||
261 | if ( currentGameDifficulty == DIFICULTY_EASY ) | 262 | if ( currentGameDifficulty == DIFICULTY_EASY ) |
262 | gateDistance = 100; | 263 | gateDistance = 100; |
263 | else if ( currentGameDifficulty == DIFICULTY_NORMAL ) | 264 | else if ( currentGameDifficulty == DIFICULTY_NORMAL ) |
264 | gateDistance = 60; | 265 | gateDistance = 60; |
265 | else | 266 | else |
266 | gateDistance = 40; | 267 | gateDistance = 40; |
267 | } | 268 | } |
268 | else if ( CURRENT_GAME_TYPE == GATES_GAME ) | 269 | else if ( CURRENT_GAME_TYPE == GATES_GAME ) |
269 | { | 270 | { |
270 | thrustUp = UpThrustVals[GATES_GAME_TYPE][currentGameDifficulty];; | 271 | thrustUp = UpThrustVals[GATES_GAME_TYPE][currentGameDifficulty];; |
271 | noThrust = DownThrustVals[GATES_GAME_TYPE][currentGameDifficulty];; | 272 | noThrust = DownThrustVals[GATES_GAME_TYPE][currentGameDifficulty];; |
272 | maxUpThrust = MaxUpThrustVals[GATES_GAME_TYPE][currentGameDifficulty];; | 273 | maxUpThrust = MaxUpThrustVals[GATES_GAME_TYPE][currentGameDifficulty];; |
273 | maxDownThrust = MaxDownThrustVals[GATES_GAME_TYPE][currentGameDifficulty];; | 274 | maxDownThrust = MaxDownThrustVals[GATES_GAME_TYPE][currentGameDifficulty];; |
274 | gateDistance = 75; | 275 | gateDistance = 75; |
275 | nextGate = nextInt( 50 ) + gateDistance; | 276 | nextGate = nextInt( 50 ) + gateDistance; |
276 | } | 277 | } |
277 | else | 278 | else |
278 | { | 279 | { |
279 | thrustUp = UpThrustVals[FLY_GAME_TYPE][currentGameDifficulty]; | 280 | thrustUp = UpThrustVals[FLY_GAME_TYPE][currentGameDifficulty]; |
280 | noThrust = DownThrustVals[FLY_GAME_TYPE][currentGameDifficulty]; | 281 | noThrust = DownThrustVals[FLY_GAME_TYPE][currentGameDifficulty]; |
281 | maxUpThrust = MaxUpThrustVals[FLY_GAME_TYPE][currentGameDifficulty]; | 282 | maxUpThrust = MaxUpThrustVals[FLY_GAME_TYPE][currentGameDifficulty]; |
282 | maxDownThrust = MaxDownThrustVals[FLY_GAME_TYPE][currentGameDifficulty]; | 283 | maxDownThrust = MaxDownThrustVals[FLY_GAME_TYPE][currentGameDifficulty]; |
283 | 284 | ||
284 | if ( currentGameDifficulty == DIFICULTY_EASY ) | 285 | if ( currentGameDifficulty == DIFICULTY_EASY ) |
285 | flyScores = flyEasyScores; | 286 | flyScores = (int*)flyEasyScores; |
286 | else if ( currentGameDifficulty == DIFICULTY_NORMAL ) | 287 | else if ( currentGameDifficulty == DIFICULTY_NORMAL ) |
287 | flyScores = flyNormalScores; | 288 | flyScores = (int*)flyNormalScores; |
288 | else | 289 | else |
289 | flyScores = flyHardScores; | 290 | flyScores = (int*)flyHardScores; |
290 | } | 291 | } |
291 | 292 | ||
292 | crashLineLength = 0; | 293 | crashLineLength = 0; |
293 | lastGateBottomY = 0; | 294 | lastGateBottomY = 0; |
294 | 295 | ||
295 | user.setRect( 50, sWidth/2, 4, 4 ); | 296 | user.setRect( 50, sWidth/2, 4, 4 ); |
296 | 297 | ||
297 | blockWidth = 20; | 298 | blockWidth = 20; |
298 | blockHeight = 70; | 299 | blockHeight = 70; |
299 | gapHeight = initialGateGaps[currentGameDifficulty]; | 300 | gapHeight = initialGateGaps[currentGameDifficulty]; |
300 | 301 | ||
301 | for ( int i = 0 ; i < TRAILSIZE ; ++i ) | 302 | for ( int i = 0 ; i < TRAILSIZE ; ++i ) |
302 | { | 303 | { |
303 | trail[i].setX( -1 ); | 304 | trail[i].setX( -1 ); |
304 | trail[i].setY( 0 ); | 305 | trail[i].setY( 0 ); |
305 | } | 306 | } |
306 | 307 | ||
307 | if ( CURRENT_GAME_TYPE != FLY_GAME ) | 308 | if ( CURRENT_GAME_TYPE != FLY_GAME ) |
308 | { | 309 | { |
309 | maxHeight = 50; | 310 | maxHeight = 50; |
310 | 311 | ||
311 | mapTop[0] = (int)(nextInt(50)) + 5; | 312 | mapTop[0] = (int)(nextInt(50)) + 5; |
312 | mapBottom[0] = (int)(nextInt(50)) + 5; | 313 | mapBottom[0] = (int)(nextInt(50)) + 5; |
313 | for ( int i = 1 ; i < MAPSIZE ; ++i ) | 314 | for ( int i = 1 ; i < MAPSIZE ; ++i ) |
@@ -460,53 +461,53 @@ void SFCave :: handleGameGates() | |||
460 | { | 461 | { |
461 | moveLandscape(); | 462 | moveLandscape(); |
462 | } | 463 | } |
463 | 464 | ||
464 | } | 465 | } |
465 | 466 | ||
466 | void SFCave :: handleGameFly() | 467 | void SFCave :: handleGameFly() |
467 | { | 468 | { |
468 | int diff = mapBottom[10] - user.y(); | 469 | int diff = mapBottom[10] - user.y(); |
469 | 470 | ||
470 | if ( nrFrames % 4 == 0 ) | 471 | if ( nrFrames % 4 == 0 ) |
471 | { | 472 | { |
472 | if ( !startScoring ) | 473 | if ( !startScoring ) |
473 | { | 474 | { |
474 | if ( diff < 40 ) | 475 | if ( diff < 40 ) |
475 | startScoring = true; | 476 | startScoring = true; |
476 | } | 477 | } |
477 | 478 | ||
478 | if ( startScoring ) | 479 | if ( startScoring ) |
479 | { | 480 | { |
480 | // Update score | 481 | // Update score |
481 | // get distance between landscape and ship | 482 | // get distance between landscape and ship |
482 | 483 | ||
483 | // the closer the difference is to 0 means more points | 484 | // the closer the difference is to 0 means more points |
484 | for ( int i = 0 ; i < 10 && flyScores[i][0] != -1 ; ++i ) | 485 | for ( int i = 0 ; i < 10 && FLYSCORES( i, 0 ) != -1 ; ++i ) |
485 | { | 486 | { |
486 | if ( flyScores[i][0] <= diff && flyScores[i][1] > diff ) | 487 | if ( FLYSCORES( i, 0 ) <= diff && FLYSCORES(i, 1 ) > diff ) |
487 | { | 488 | { |
488 | score += flyScores[i][2]; | 489 | score += FLYSCORES( i, 2 ); |
489 | break; | 490 | break; |
490 | } | 491 | } |
491 | } | 492 | } |
492 | } | 493 | } |
493 | } | 494 | } |
494 | 495 | ||
495 | if ( checkFlyGameCollision() ) | 496 | if ( checkFlyGameCollision() ) |
496 | { | 497 | { |
497 | if ( score > highestScore[currentGameType][currentGameDifficulty] ) | 498 | if ( score > highestScore[currentGameType][currentGameDifficulty] ) |
498 | { | 499 | { |
499 | highestScore[currentGameType][currentGameDifficulty] = score; | 500 | highestScore[currentGameType][currentGameDifficulty] = score; |
500 | saveScore(); | 501 | saveScore(); |
501 | } | 502 | } |
502 | state = STATE_CRASHING; | 503 | state = STATE_CRASHING; |
503 | } | 504 | } |
504 | else | 505 | else |
505 | { | 506 | { |
506 | moveFlyGameLandscape(); | 507 | moveFlyGameLandscape(); |
507 | } | 508 | } |
508 | } | 509 | } |
509 | 510 | ||
510 | bool SFCave :: checkFlyGameCollision() | 511 | bool SFCave :: checkFlyGameCollision() |
511 | { | 512 | { |
512 | if ( (user.y() + user.width()) >= mapBottom[11] ) | 513 | if ( (user.y() + user.width()) >= mapBottom[11] ) |
@@ -673,54 +674,54 @@ void SFCave :: drawBoss() | |||
673 | 674 | ||
674 | bitBlt( this, 0, 0, offscreen, 0, 0, sWidth, sHeight, Qt::CopyROP, true ); | 675 | bitBlt( this, 0, 0, offscreen, 0, 0, sWidth, sHeight, Qt::CopyROP, true ); |
675 | } | 676 | } |
676 | 677 | ||
677 | void SFCave :: draw() | 678 | void SFCave :: draw() |
678 | { | 679 | { |
679 | //printf( "Paint\n" ); | 680 | //printf( "Paint\n" ); |
680 | offscreen->fill( Qt::black ); | 681 | offscreen->fill( Qt::black ); |
681 | 682 | ||
682 | QPainter p( offscreen ); | 683 | QPainter p( offscreen ); |
683 | QFontMetrics fm = p.fontMetrics(); | 684 | QFontMetrics fm = p.fontMetrics(); |
684 | p.setPen( Qt::white ); | 685 | p.setPen( Qt::white ); |
685 | 686 | ||
686 | for ( int i = 0 ; i < MAPSIZE -3; ++i ) | 687 | for ( int i = 0 ; i < MAPSIZE -3; ++i ) |
687 | { | 688 | { |
688 | // Only display top landscape if not running FLY_GAME | 689 | // Only display top landscape if not running FLY_GAME |
689 | if ( CURRENT_GAME_TYPE != FLY_GAME ) | 690 | if ( CURRENT_GAME_TYPE != FLY_GAME ) |
690 | p.drawLine( (i*segSize) - (offset*speed), mapTop[i], ((i+1)*segSize)-(offset*speed), mapTop[i+1] ); | 691 | p.drawLine( (i*segSize) - (offset*speed), mapTop[i], ((i+1)*segSize)-(offset*speed), mapTop[i+1] ); |
691 | 692 | ||
692 | p.drawLine( (i*segSize) - (offset*speed), mapBottom[i], ((i+1)*segSize)-(offset*speed), mapBottom[i+1] ); | 693 | p.drawLine( (i*segSize) - (offset*speed), mapBottom[i], ((i+1)*segSize)-(offset*speed), mapBottom[i+1] ); |
693 | 694 | ||
694 | if ( CURRENT_GAME_TYPE == FLY_GAME && showScoreZones ) | 695 | if ( CURRENT_GAME_TYPE == FLY_GAME && showScoreZones ) |
695 | { | 696 | { |
696 | p.setPen( Qt::blue ); | 697 | p.setPen( Qt::blue ); |
697 | for ( int j = 1 ; j < 10 && flyScores[j][0] != -1 ; ++j ) | 698 | for ( int j = 1 ; j < 10 && FLYSCORES( j, 0 ) != -1 ; ++j ) |
698 | { | 699 | { |
699 | if ( flyScores[j][2] < 0 ) | 700 | if ( FLYSCORES( j, 2 ) < 0 ) |
700 | p.setPen( Qt::red ); | 701 | p.setPen( Qt::red ); |
701 | 702 | ||
702 | p.drawLine( (i*segSize) - (offset*speed), mapBottom[i]-flyScores[j][0], ((i+1)*segSize)-(offset*speed), mapBottom[i+1]-flyScores[j][0] ); | 703 | p.drawLine( (i*segSize) - (offset*speed), mapBottom[i]-FLYSCORES( j, 0 ), ((i+1)*segSize)-(offset*speed), mapBottom[i+1]-FLYSCORES( j, 0 ) ); |
703 | } | 704 | } |
704 | 705 | ||
705 | p.setPen( Qt::white ); | 706 | p.setPen( Qt::white ); |
706 | } | 707 | } |
707 | } | 708 | } |
708 | 709 | ||
709 | // Uncomment this to show user segment (usful for checking collision boundary with landscape | 710 | // Uncomment this to show user segment (usful for checking collision boundary with landscape |
710 | // p.setPen( Qt::red ); | 711 | // p.setPen( Qt::red ); |
711 | // p.drawLine( (11*segSize) - (offset*speed), 0, ((11)*segSize)-(offset*speed), sHeight ); | 712 | // p.drawLine( (11*segSize) - (offset*speed), 0, ((11)*segSize)-(offset*speed), sHeight ); |
712 | // p.setPen( Qt::white ); | 713 | // p.setPen( Qt::white ); |
713 | 714 | ||
714 | // Draw user | 715 | // Draw user |
715 | p.drawRect( user ); | 716 | p.drawRect( user ); |
716 | 717 | ||
717 | // Draw trails | 718 | // Draw trails |
718 | for ( int i = 0 ; i < TRAILSIZE ; ++i ) | 719 | for ( int i = 0 ; i < TRAILSIZE ; ++i ) |
719 | if ( trail[i].x() >= 0 ) | 720 | if ( trail[i].x() >= 0 ) |
720 | { | 721 | { |
721 | if ( showEyeCandy ) | 722 | if ( showEyeCandy ) |
722 | p.setPen( Qt::white.light((int)(100.0-3*(user.x()/100.0)* (user.x()-trail[i].x())) ) ); | 723 | p.setPen( Qt::white.light((int)(100.0-3*(user.x()/100.0)* (user.x()-trail[i].x())) ) ); |
723 | p.drawRect( trail[i].x(), trail[i].y(), 2, 2 ); | 724 | p.drawRect( trail[i].x(), trail[i].y(), 2, 2 ); |
724 | } | 725 | } |
725 | 726 | ||
726 | p.setPen( Qt::white ); | 727 | p.setPen( Qt::white ); |
diff --git a/noncore/games/sfcave/sfcave.h b/noncore/games/sfcave/sfcave.h index f95558d..b1fe819 100644 --- a/noncore/games/sfcave/sfcave.h +++ b/noncore/games/sfcave/sfcave.h | |||
@@ -29,49 +29,49 @@ 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; | 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[7][3]; | 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 | ||