-rw-r--r-- | noncore/games/sfcave/sfcave.cpp | 477 | ||||
-rw-r--r-- | noncore/games/sfcave/sfcave.h | 26 |
2 files changed, 372 insertions, 131 deletions
diff --git a/noncore/games/sfcave/sfcave.cpp b/noncore/games/sfcave/sfcave.cpp index 8b9c844..788606f 100644 --- a/noncore/games/sfcave/sfcave.cpp +++ b/noncore/games/sfcave/sfcave.cpp | |||
@@ -11,5 +11,11 @@ | |||
11 | 11 | ||
12 | #include "helpwindow.h" | ||
12 | #include "sfcave.h" | 13 | #include "sfcave.h" |
13 | 14 | ||
14 | #define CAPTION "SFCave 1.7 by AndyQ" | 15 | #define CAPTION "SFCave 1.8 by AndyQ" |
16 | |||
17 | #define UP_THRUST 0.6 | ||
18 | #define NO_THRUST 0.8 | ||
19 | #define MAX_DOWN_THRUST 4.0 | ||
20 | #define MAX_UP_THRUST -3.5 | ||
15 | 21 | ||
@@ -18,5 +24,6 @@ | |||
18 | #define STATE_RUNNING 1 | 24 | #define STATE_RUNNING 1 |
19 | #define STATE_CRASHED 2 | 25 | #define STATE_CRASHING 2 |
20 | #define STATE_NEWGAME 3 | 26 | #define STATE_CRASHED 3 |
21 | #define STATE_MENU 4 | 27 | #define STATE_NEWGAME 4 |
28 | #define STATE_MENU 5 | ||
22 | 29 | ||
@@ -29,3 +36,4 @@ | |||
29 | #define MENU_OPTIONS 1 | 36 | #define MENU_OPTIONS 1 |
30 | #define MENU_QUIT 2 | 37 | #define MENU_HELP 2 |
38 | #define MENU_QUIT 3 | ||
31 | 39 | ||
@@ -33,7 +41,5 @@ | |||
33 | #define MENU_GAME_TYPE 0 | 41 | #define MENU_GAME_TYPE 0 |
34 | #define MENU_GAME_DIFFICULTY 1 | 42 | #define MENU_GAME_DIFFICULTY 1 |
35 | #define MENU_BACK 2 | 43 | #define MENU_CLEAR_HIGHSCORES 2 |
36 | 44 | #define MENU_BACK 3 | |
37 | QString SFCave::menuOptions[2][5] = { { "Start Game", "Options", "Quit", "", "" }, | ||
38 | { "Game Type - %s", "Game Difficulty - %s", "Back", "", "" } }; | ||
39 | 45 | ||
@@ -43,2 +49,5 @@ QString SFCave::menuOptions[2][5] = { { "Start Game", "Options", "Quit", "", "" | |||
43 | 49 | ||
50 | #define DIFICULTY_EASY 0 | ||
51 | #define DIFICULTY_NORMAL 1 | ||
52 | #define DIFICULTY_HARD 2 | ||
44 | #define EASY "Easy" | 53 | #define EASY "Easy" |
@@ -53,2 +62,5 @@ QString SFCave::menuOptions[2][5] = { { "Start Game", "Options", "Quit", "", "" | |||
53 | #define FLY_GAME "Fly" | 62 | #define FLY_GAME "Fly" |
63 | #define CURRENT_GAME_TYPE gameTypes[currentGameType] | ||
64 | #define CURRENT_GAME_DIFFICULTY difficultyOption[currentGameDifficulty]; | ||
65 | |||
54 | QString SFCave::dificultyOption[] = { EASY, NORMAL, HARD }; | 66 | QString SFCave::dificultyOption[] = { EASY, NORMAL, HARD }; |
@@ -56,4 +68,29 @@ QString SFCave::gameTypes[] = { SFCAVE_GAME, GATES_GAME, FLY_GAME }; | |||
56 | 68 | ||
57 | #define CURRENT_GAME_TYPE gameTypes[currentGameType] | 69 | QString SFCave::menuOptions[2][5] = { { "Start Game", "Options", "Help", "Quit", "" }, |
58 | #define CURRENT_GAME_DIFFICULTY difficultyOption[currentGameDifficulty]; | 70 | { "Game Type - %s", "Game Difficulty - %s", "Clear High Scores for this game", "Back", "" } }; |
71 | |||
72 | #define UP_THRUST 0.6 | ||
73 | #define NO_THRUST 0.8 | ||
74 | #define MAX_DOWN_THRUST 4.0 | ||
75 | #define MAX_UP_THRUST -3.5 | ||
76 | double SFCave::UpThrustVals[3][3] = {{ 0.6, 0.6, 0.6 }, // SFCave | ||
77 | { 0.6, 0.6, 0.8 }, // Gates | ||
78 | { 0.4, 0.7, 1.0 } }; // Fly | ||
79 | |||
80 | double SFCave::DownThrustVals[3][3] = {{ 0.8, 0.8, 0.8 }, // SFCave | ||
81 | { 0.8, 0.8, 1.0 }, // Gates | ||
82 | { 0.4, 0.7, 1.0 } }; // Fly | ||
83 | |||
84 | double SFCave::MaxUpThrustVals[3][3] = {{ -3.5, -3.5, -3.5 }, // SFCave | ||
85 | { -3.5, -4.0, -5.0 }, // Gates | ||
86 | { -3.5, -4.0, -5.0 } }; // Fly | ||
87 | |||
88 | double SFCave::MaxDownThrustVals[3][3] = {{ 4.0, 4.0, 4.0 }, // SFCave | ||
89 | { 4.0, 5.0, 5.5 }, // Gates | ||
90 | { 3.5, 4.0, 5.0 } }; // Fly | ||
91 | |||
92 | int SFCave::initialGateGaps[] = { 75, 50, 25 }; | ||
93 | |||
94 | int SFCave::nrMenuOptions[2] = { 4, 4 }; | ||
95 | int SFCave ::currentMenuOption[2] = { 0, 0 }; | ||
59 | 96 | ||
@@ -65,3 +102,2 @@ int main( int argc, char *argv[] ) | |||
65 | movel = true; | 102 | movel = true; |
66 | |||
67 | #ifdef QWS | 103 | #ifdef QWS |
@@ -104,6 +140,2 @@ SFCave :: SFCave( int spd, QWidget *w, char *name ) | |||
104 | currentMenuNr = 0; | 140 | currentMenuNr = 0; |
105 | nrMenuOptions[0] = 3; | ||
106 | nrMenuOptions[1] = 3; | ||
107 | currentMenuOption[0] = 0; | ||
108 | currentMenuOption[1] = 0; | ||
109 | currentGameType = 0; | 141 | currentGameType = 0; |
@@ -112,2 +144,3 @@ SFCave :: SFCave( int spd, QWidget *w, char *name ) | |||
112 | setCaption( CAPTION ); | 144 | setCaption( CAPTION ); |
145 | showScoreZones = false; | ||
113 | 146 | ||
@@ -117,5 +150,9 @@ SFCave :: SFCave( int spd, QWidget *w, char *name ) | |||
117 | QString key = "highScore_"; | 150 | QString key = "highScore_"; |
118 | highestScore[SFCAVE_GAME_TYPE] = cfg.readNumEntry( key + SFCAVE_GAME, 0 ); | 151 | |
119 | highestScore[GATES_GAME_TYPE] = cfg.readNumEntry( key + GATES_GAME, 0 ); | 152 | for ( int i = 0 ; i < 3 ; ++i ) |
120 | highestScore[FLY_GAME_TYPE] = cfg.readNumEntry( key + FLY_GAME, 0 ); | 153 | { |
154 | for ( int j = 0 ; j < 3 ; ++j ) | ||
155 | highestScore[i][j] = cfg.readNumEntry( key + gameTypes[i] + "_" + dificultyOption[j], 0 ); | ||
156 | } | ||
157 | |||
121 | currentGameType = cfg.readNumEntry( "gameType", 0 ); | 158 | currentGameType = cfg.readNumEntry( "gameType", 0 ); |
@@ -159,3 +196,2 @@ void SFCave :: setUp() | |||
159 | offset = 0; | 196 | offset = 0; |
160 | maxHeight = 50; | ||
161 | nrFrames = 0; | 197 | nrFrames = 0; |
@@ -163,2 +199,25 @@ void SFCave :: setUp() | |||
163 | thrust = 0; | 199 | thrust = 0; |
200 | |||
201 | if ( CURRENT_GAME_TYPE == SFCAVE_GAME ) | ||
202 | { | ||
203 | thrustUp = UpThrustVals[SFCAVE_GAME_TYPE][currentGameDifficulty];; | ||
204 | noThrust = DownThrustVals[SFCAVE_GAME_TYPE][currentGameDifficulty];; | ||
205 | maxUpThrust = MaxUpThrustVals[SFCAVE_GAME_TYPE][currentGameDifficulty];; | ||
206 | maxDownThrust = MaxDownThrustVals[SFCAVE_GAME_TYPE][currentGameDifficulty];; | ||
207 | } | ||
208 | else if ( CURRENT_GAME_TYPE == GATES_GAME ) | ||
209 | { | ||
210 | thrustUp = UpThrustVals[GATES_GAME_TYPE][currentGameDifficulty];; | ||
211 | noThrust = DownThrustVals[GATES_GAME_TYPE][currentGameDifficulty];; | ||
212 | maxUpThrust = MaxUpThrustVals[GATES_GAME_TYPE][currentGameDifficulty];; | ||
213 | maxDownThrust = MaxDownThrustVals[GATES_GAME_TYPE][currentGameDifficulty];; | ||
214 | } | ||
215 | else | ||
216 | { | ||
217 | thrustUp = UpThrustVals[FLY_GAME_TYPE][currentGameDifficulty]; | ||
218 | noThrust = DownThrustVals[FLY_GAME_TYPE][currentGameDifficulty]; | ||
219 | maxUpThrust = MaxUpThrustVals[FLY_GAME_TYPE][currentGameDifficulty]; | ||
220 | maxDownThrust = MaxDownThrustVals[FLY_GAME_TYPE][currentGameDifficulty]; | ||
221 | } | ||
222 | |||
164 | crashLineLength = 0; | 223 | crashLineLength = 0; |
@@ -169,3 +228,3 @@ void SFCave :: setUp() | |||
169 | blockHeight = 70; | 228 | blockHeight = 70; |
170 | gapHeight = 125; | 229 | gapHeight = initialGateGaps[currentGameDifficulty]; |
171 | gateDistance = 75; | 230 | gateDistance = 75; |
@@ -179,6 +238,18 @@ void SFCave :: setUp() | |||
179 | 238 | ||
180 | mapTop[0] = (int)(nextInt(50)) + 5; | 239 | if ( CURRENT_GAME_TYPE != FLY_GAME ) |
181 | for ( int i = 1 ; i < MAPSIZE ; ++i ) | 240 | { |
182 | setPoint( i ); | 241 | maxHeight = 50; |
242 | |||
243 | mapTop[0] = (int)(nextInt(50)) + 5; | ||
244 | mapBottom[0] = (int)(nextInt(50)) + 5; | ||
245 | for ( int i = 1 ; i < MAPSIZE ; ++i ) | ||
246 | setPoint( i ); | ||
247 | } | ||
248 | else | ||
249 | { | ||
250 | maxHeight = 100; | ||
183 | 251 | ||
252 | for ( int i = 0 ; i < MAPSIZE ; ++i ) | ||
253 | mapBottom[i] = sHeight - 10; | ||
254 | } | ||
184 | for ( int i = 0 ; i < BLOCKSIZE ; ++i ) | 255 | for ( int i = 0 ; i < BLOCKSIZE ; ++i ) |
@@ -189,94 +260,193 @@ void SFCave :: run() | |||
189 | { | 260 | { |
190 | //running = true; | 261 | switch ( state ) |
191 | //setUp(); | 262 | { |
192 | switch ( state ) | 263 | case STATE_MENU: |
264 | displayMenu(); | ||
265 | break; | ||
266 | case STATE_NEWGAME: | ||
267 | setUp(); | ||
268 | draw(); | ||
269 | state = STATE_RUNNING; | ||
270 | break; | ||
271 | case STATE_BOSS: | ||
272 | drawBoss(); | ||
273 | break; | ||
274 | |||
275 | case STATE_CRASHING: | ||
276 | case STATE_CRASHED: | ||
277 | draw(); | ||
278 | break; | ||
279 | |||
280 | case STATE_RUNNING: | ||
193 | { | 281 | { |
194 | case STATE_MENU: | 282 | if ( nrFrames % 2 == 0 ) |
195 | displayMenu(); | 283 | handleKeys(); |
196 | break; | 284 | |
197 | case STATE_NEWGAME: | 285 | // Apply Game rules |
198 | setUp(); | 286 | nrFrames ++; |
199 | draw(); | 287 | if ( CURRENT_GAME_TYPE == SFCAVE_GAME ) |
200 | state = STATE_RUNNING; | 288 | handleGameSFCave(); |
201 | break; | 289 | else if ( CURRENT_GAME_TYPE == GATES_GAME ) |
202 | case STATE_BOSS: | 290 | handleGameGates(); |
203 | drawBoss(); | 291 | else if ( CURRENT_GAME_TYPE == FLY_GAME ) |
204 | break; | 292 | handleGameFly(); |
293 | |||
294 | draw(); | ||
295 | break; | ||
296 | } | ||
297 | } | ||
298 | } | ||
205 | 299 | ||
206 | case STATE_CRASHED: | 300 | void SFCave :: handleGameSFCave() |
207 | draw(); | 301 | { |
208 | break; | 302 | // Update score |
303 | if ( nrFrames % 5 == 0 ) | ||
304 | score ++; | ||
209 | 305 | ||
210 | case STATE_RUNNING: | 306 | if ( nrFrames % 500 == 0 ) |
211 | { | 307 | { |
212 | if ( nrFrames % 5 == 0 ) | 308 | if ( maxHeight < sHeight - 100 ) |
213 | score ++; | 309 | { |
214 | if ( nrFrames % 2 == 0 ) | 310 | maxHeight += 10; |
215 | handleKeys(); | ||
216 | |||
217 | // Apply Game rules | ||
218 | nrFrames ++; | ||
219 | if ( CURRENT_GAME_TYPE == SFCAVE_GAME ) | ||
220 | { | ||
221 | if ( nrFrames % 500 == 0 ) | ||
222 | { | ||
223 | if ( maxHeight < sHeight - 100 ) | ||
224 | { | ||
225 | maxHeight += 10; | ||
226 | |||
227 | // Reduce block height | ||
228 | if ( maxHeight > sHeight - 150 ) | ||
229 | blockHeight -= 5; | ||
230 | } | ||
231 | } | ||
232 | 311 | ||
233 | if ( nrFrames % 100 == 0 ) | 312 | // Reduce block height |
234 | addBlock(); | 313 | if ( maxHeight > sHeight - 150 ) |
235 | } | 314 | blockHeight -= 5; |
236 | else if ( CURRENT_GAME_TYPE == GATES_GAME ) | 315 | } |
237 | { | 316 | } |
238 | // Slightly random gap distance | ||
239 | if ( nrFrames >= nextGate ) | ||
240 | { | ||
241 | nextGate = nrFrames + nextInt( 50 ) + gateDistance; | ||
242 | addGate(); | ||
243 | } | ||
244 | 317 | ||
245 | if ( nrFrames % 500 == 0 ) | 318 | if ( nrFrames % 100 == 0 ) |
246 | { | 319 | addBlock(); |
247 | if ( gapHeight > 75 ) | ||
248 | gapHeight -= 5; | ||
249 | } | ||
250 | } | ||
251 | else if ( CURRENT_GAME_TYPE == FLY_GAME ) | ||
252 | { | ||
253 | } | ||
254 | |||
255 | |||
256 | if ( checkCollision() ) | ||
257 | { | ||
258 | if ( score > highestScore[currentGameType] ) | ||
259 | highestScore[currentGameType] = score; | ||
260 | 320 | ||
261 | #ifdef QWS | 321 | if ( checkCollision() ) |
262 | Config cfg( "sfcave" ); | 322 | { |
263 | cfg.setGroup( "settings" ); | 323 | if ( score > highestScore[currentGameType][currentGameDifficulty] ) |
264 | QString key = "highScore_"; | 324 | { |
265 | key += CURRENT_GAME_TYPE; | 325 | highestScore[currentGameType][currentGameDifficulty] = score; |
266 | cfg.writeEntry( key, highestScore[currentGameType] ); | 326 | saveScore(); |
267 | #endif | 327 | } |
328 | state = STATE_CRASHING; | ||
329 | } | ||
330 | else | ||
331 | { | ||
332 | moveLandscape(); | ||
333 | } | ||
268 | 334 | ||
269 | state = STATE_CRASHED; | 335 | } |
270 | } | ||
271 | else | ||
272 | { | ||
273 | if ( movel ) | ||
274 | moveLandscape(); | ||
275 | //movel = false; | ||
276 | } | ||
277 | 336 | ||
278 | draw(); | 337 | |
279 | break; | 338 | void SFCave :: handleGameGates() |
280 | } | 339 | { |
340 | // Update score | ||
341 | if ( nrFrames % 5 == 0 ) | ||
342 | score ++; | ||
343 | |||
344 | // Slightly random gap distance | ||
345 | if ( nrFrames >= nextGate ) | ||
346 | { | ||
347 | nextGate = nrFrames + nextInt( 50 ) + gateDistance; | ||
348 | addGate(); | ||
349 | } | ||
350 | |||
351 | if ( nrFrames % 500 == 0 ) | ||
352 | { | ||
353 | if ( gapHeight > 75 ) | ||
354 | gapHeight -= 5; | ||
355 | } | ||
356 | |||
357 | if ( checkCollision() ) | ||
358 | { | ||
359 | if ( score > highestScore[currentGameType][currentGameDifficulty] ) | ||
360 | { | ||
361 | highestScore[currentGameType][currentGameDifficulty] = score; | ||
362 | saveScore(); | ||
363 | } | ||
364 | state = STATE_CRASHING; | ||
365 | } | ||
366 | else | ||
367 | { | ||
368 | moveLandscape(); | ||
369 | } | ||
370 | |||
371 | } | ||
372 | |||
373 | void SFCave :: handleGameFly() | ||
374 | { | ||
375 | if ( nrFrames % 4 == 0 ) | ||
376 | { | ||
377 | // Update score | ||
378 | // get distance between landscape and ship | ||
379 | int diff = mapBottom[10] - user.y(); | ||
380 | |||
381 | // the closer the difference is to 0 means more points | ||
382 | if ( diff < 10 ) | ||
383 | score += 5; | ||
384 | else if ( diff < 20 ) | ||
385 | score += 3; | ||
386 | else if ( diff < 30 ) | ||
387 | score += 2; | ||
388 | else if ( diff < 40 ) | ||
389 | score += 1; | ||
390 | } | ||
391 | |||
392 | if ( checkFlyGameCollision() ) | ||
393 | { | ||
394 | if ( score > highestScore[currentGameType][currentGameDifficulty] ) | ||
395 | { | ||
396 | highestScore[currentGameType][currentGameDifficulty] = score; | ||
397 | saveScore(); | ||
281 | } | 398 | } |
399 | state = STATE_CRASHING; | ||
400 | } | ||
401 | else | ||
402 | { | ||
403 | moveFlyGameLandscape(); | ||
404 | } | ||
405 | } | ||
406 | |||
407 | bool SFCave :: checkFlyGameCollision() | ||
408 | { | ||
409 | if ( (user.y() + user.width()) >= mapBottom[11] ) | ||
410 | return true; | ||
411 | |||
412 | return false; | ||
413 | } | ||
414 | |||
415 | void SFCave :: moveFlyGameLandscape() | ||
416 | { | ||
417 | offset++; | ||
418 | |||
419 | if ( offset >= segSize ) | ||
420 | { | ||
421 | offset = 0; | ||
422 | for ( int i = 0 ; i < MAPSIZE-speed ; ++i ) | ||
423 | mapBottom[i] = mapBottom[i+speed]; | ||
424 | |||
425 | for ( int i = speed ; i > 0 ; --i ) | ||
426 | setFlyPoint( MAPSIZE-i ); | ||
427 | } | ||
428 | } | ||
429 | |||
430 | void SFCave :: setFlyPoint( int point ) | ||
431 | { | ||
432 | static int fly_difficulty_levels[] = { 5, 10, 15 }; | ||
433 | if ( nextInt(100) >= 75 ) | ||
434 | dir *= -1; | ||
435 | |||
436 | int prevPoint = mapBottom[point-1]; | ||
437 | |||
438 | int nextPoint = prevPoint + (dir * nextInt( fly_difficulty_levels[currentGameDifficulty] ) ); | ||
439 | |||
440 | if ( nextPoint > sHeight ) | ||
441 | { | ||
442 | nextPoint = sHeight; | ||
443 | dir *= -1; | ||
444 | } | ||
445 | else if ( nextPoint < maxHeight ) | ||
446 | { | ||
447 | nextPoint = maxHeight; | ||
448 | dir *= 1; | ||
449 | } | ||
450 | |||
451 | mapBottom[point] = nextPoint; | ||
282 | } | 452 | } |
@@ -285,3 +455,3 @@ bool SFCave :: checkCollision() | |||
285 | { | 455 | { |
286 | if ( (user.y() + user.width()) >= mapBottom[10] || user.y() <= mapTop[10] ) | 456 | if ( (user.y() + user.width()) >= mapBottom[11] || user.y() <= mapTop[11] ) |
287 | return true; | 457 | return true; |
@@ -352,3 +522,3 @@ void SFCave :: addGate() | |||
352 | int y1 = mapTop[50]; | 522 | int y1 = mapTop[50]; |
353 | int b1Height = nextInt(mapBottom[50] - mapTop[50] - gateDistance); | 523 | int b1Height = nextInt(mapBottom[50] - mapTop[50] - gapHeight); |
354 | 524 | ||
@@ -362,3 +532,3 @@ void SFCave :: addGate() | |||
362 | int x2 = sWidth; | 532 | int x2 = sWidth; |
363 | int y2 = y1 + b1Height + gateDistance; | 533 | int y2 = y1 + b1Height + gapHeight; |
364 | int b2Height = mapBottom[50] - y2; | 534 | int b2Height = mapBottom[50] - y2; |
@@ -391,3 +561,3 @@ void SFCave :: setPoint( int point ) | |||
391 | 561 | ||
392 | mapBottom[point] = sHeight - (maxHeight - mapBottom[point]); | 562 | // mapBottom[point] = sHeight - (maxHeight - mapBottom[point]); |
393 | mapBottom[point] = sHeight - (maxHeight - mapTop[point]); | 563 | mapBottom[point] = sHeight - (maxHeight - mapTop[point]); |
@@ -413,6 +583,24 @@ void SFCave :: draw() | |||
413 | { | 583 | { |
414 | p.drawLine( (i*segSize) - (offset*speed), mapTop[i], ((i+1)*segSize)-(offset*speed), mapTop[i+1] ); | 584 | // Only display top landscape if not running FLY_GAME |
585 | if ( CURRENT_GAME_TYPE != FLY_GAME ) | ||
586 | p.drawLine( (i*segSize) - (offset*speed), mapTop[i], ((i+1)*segSize)-(offset*speed), mapTop[i+1] ); | ||
587 | |||
415 | p.drawLine( (i*segSize) - (offset*speed), mapBottom[i], ((i+1)*segSize)-(offset*speed), mapBottom[i+1] ); | 588 | p.drawLine( (i*segSize) - (offset*speed), mapBottom[i], ((i+1)*segSize)-(offset*speed), mapBottom[i+1] ); |
589 | |||
590 | if ( CURRENT_GAME_TYPE == FLY_GAME && showScoreZones ) | ||
591 | { | ||
592 | p.setPen( Qt::red ); | ||
593 | p.drawLine( (i*segSize) - (offset*speed), mapBottom[i]-10, ((i+1)*segSize)-(offset*speed), mapBottom[i+1]-10 ); | ||
594 | p.drawLine( (i*segSize) - (offset*speed), mapBottom[i]-20, ((i+1)*segSize)-(offset*speed), mapBottom[i+1]-20 ); | ||
595 | p.drawLine( (i*segSize) - (offset*speed), mapBottom[i]-30, ((i+1)*segSize)-(offset*speed), mapBottom[i+1]-30 ); | ||
596 | p.drawLine( (i*segSize) - (offset*speed), mapBottom[i]-40, ((i+1)*segSize)-(offset*speed), mapBottom[i+1]-40 ); | ||
597 | p.setPen( Qt::white ); | ||
598 | } | ||
416 | } | 599 | } |
417 | 600 | ||
601 | // Uncomment this to show user segment (usful for checking collision boundary with landscape | ||
602 | // p.setPen( Qt::red ); | ||
603 | // p.drawLine( (11*segSize) - (offset*speed), 0, ((11)*segSize)-(offset*speed), sHeight ); | ||
604 | // p.setPen( Qt::white ); | ||
605 | |||
418 | // Draw user | 606 | // Draw user |
@@ -435,3 +623,3 @@ void SFCave :: draw() | |||
435 | QString s; | 623 | QString s; |
436 | s.sprintf( "score %06d high score %06d", score, highestScore[currentGameType] ); | 624 | s.sprintf( "score %06d high score %06d", score, highestScore[currentGameType][currentGameDifficulty] ); |
437 | p.drawText( 5, 10, s ); | 625 | p.drawText( 5, 10, s ); |
@@ -439,3 +627,3 @@ void SFCave :: draw() | |||
439 | 627 | ||
440 | if ( state == STATE_CRASHED ) | 628 | if ( state == STATE_CRASHING || state == STATE_CRASHED ) |
441 | { | 629 | { |
@@ -452,3 +640,6 @@ void SFCave :: draw() | |||
452 | 640 | ||
453 | if ( crashLineLength >= 15 || crashLineLength == -1 ) | 641 | if ( state == STATE_CRASHING && crashLineLength >= 15 ) //|| crashLineLength == -1) ) |
642 | state = STATE_CRASHED; | ||
643 | |||
644 | if ( state == STATE_CRASHED ) | ||
454 | { | 645 | { |
@@ -459,3 +650,2 @@ void SFCave :: draw() | |||
459 | p.drawText( (sWidth/2) - (fm.width( text )/2), 155, text ); | 650 | p.drawText( (sWidth/2) - (fm.width( text )/2), 155, text ); |
460 | // p.drawText( 70, 140, QString( "Press down to start" ) ); | ||
461 | } | 651 | } |
@@ -494,10 +684,10 @@ void SFCave :: handleKeys() | |||
494 | if ( press ) | 684 | if ( press ) |
495 | thrust -= 0.6; | 685 | thrust -= thrustUp; |
496 | else | 686 | else |
497 | thrust += 0.8; | 687 | thrust += noThrust; |
498 | 688 | ||
499 | if ( thrust > 4.0 ) | 689 | if ( thrust > maxDownThrust ) |
500 | thrust = 4.0; | 690 | thrust = maxDownThrust; |
501 | else if ( thrust < -3.5 ) | 691 | else if ( thrust < maxUpThrust ) |
502 | thrust = -3.5; | 692 | thrust = maxUpThrust; |
503 | } | 693 | } |
@@ -590,4 +780,10 @@ void SFCave :: keyPressEvent( QKeyEvent *e ) | |||
590 | case Qt::Key_Enter: | 780 | case Qt::Key_Enter: |
591 | if ( state == STATE_CRASHED && crashLineLength >= 15 || crashLineLength == -1 ) | 781 | if ( state == STATE_CRASHED ) |
592 | state = STATE_MENU; | 782 | state = STATE_MENU; |
783 | break; | ||
784 | |||
785 | case Qt::Key_Z: | ||
786 | showScoreZones = !showScoreZones; | ||
787 | break; | ||
788 | |||
593 | default: | 789 | default: |
@@ -618,3 +814,3 @@ void SFCave :: keyReleaseEvent( QKeyEvent *e ) | |||
618 | case Qt::Key_Down: | 814 | case Qt::Key_Down: |
619 | if ( state == STATE_CRASHED && crashLineLength >= 15 || crashLineLength == -1 ) | 815 | if ( state == STATE_CRASHED ) |
620 | { | 816 | { |
@@ -699,2 +895,11 @@ void SFCave :: dealWithMenuSelection() | |||
699 | 895 | ||
896 | case MENU_HELP: | ||
897 | { | ||
898 | // Display Help Menu | ||
899 | HelpWindow *dlg = new HelpWindow( this ); | ||
900 | dlg->exec(); | ||
901 | delete dlg; | ||
902 | break; | ||
903 | } | ||
904 | |||
700 | case MENU_QUIT: | 905 | case MENU_QUIT: |
@@ -716,4 +921,9 @@ void SFCave :: dealWithMenuSelection() | |||
716 | break; | 921 | break; |
922 | |||
923 | case MENU_CLEAR_HIGHSCORES: | ||
924 | for ( int i = 0 ; i < 3 ; ++i ) | ||
925 | highestScore[currentGameType][i] = 0; | ||
926 | break; | ||
717 | 927 | ||
718 | case MENU_BACK: | 928 | case MENU_BACK: |
719 | currentMenuNr = MENU_MAIN_MENU; | 929 | currentMenuNr = MENU_MAIN_MENU; |
@@ -732,2 +942,15 @@ void SFCave :: dealWithMenuSelection() | |||
732 | } | 942 | } |
733 | } \ No newline at end of file | 943 | } |
944 | |||
945 | void SFCave :: saveScore() | ||
946 | { | ||
947 | #ifdef QWS | ||
948 | Config cfg( "sfcave" ); | ||
949 | cfg.setGroup( "settings" ); | ||
950 | QString key = "highScore_"; | ||
951 | |||
952 | cfg.writeEntry( key + gameTypes[currentGameType] + "_" + dificultyOption[currentGameDifficulty], highestScore[currentGameType][currentGameDifficulty] ); | ||
953 | key += CURRENT_GAME_TYPE; | ||
954 | cfg.writeEntry( key, highestScore[currentGameType] ); | ||
955 | #endif | ||
956 | } | ||
diff --git a/noncore/games/sfcave/sfcave.h b/noncore/games/sfcave/sfcave.h index b19d147..69a0e13 100644 --- a/noncore/games/sfcave/sfcave.h +++ b/noncore/games/sfcave/sfcave.h | |||
@@ -30,2 +30,13 @@ public: | |||
30 | 30 | ||
31 | static double UpThrustVals[3][3]; | ||
32 | static double DownThrustVals[3][3]; | ||
33 | static double MaxUpThrustVals[3][3]; | ||
34 | static double MaxDownThrustVals[3][3]; | ||
35 | static int initialGateGaps[]; | ||
36 | |||
37 | double thrustUp; | ||
38 | double noThrust; | ||
39 | double maxUpThrust; | ||
40 | double maxDownThrust; | ||
41 | |||
31 | int gateDistance; | 42 | int gateDistance; |
@@ -36,4 +47,4 @@ public: | |||
36 | int currentMenuNr; | 47 | int currentMenuNr; |
37 | int nrMenuOptions[2]; | 48 | static int nrMenuOptions[2]; |
38 | int currentMenuOption[2]; | 49 | static int currentMenuOption[2]; |
39 | 50 | ||
@@ -48,3 +59,3 @@ public: | |||
48 | int score; | 59 | int score; |
49 | int highestScore[3]; | 60 | int highestScore[3][3]; |
50 | 61 | ||
@@ -61,3 +72,3 @@ public: | |||
61 | 72 | ||
62 | bool bossMode; | 73 | bool showScoreZones; |
63 | 74 | ||
@@ -72,2 +83,8 @@ public: | |||
72 | void setUp(); | 83 | void setUp(); |
84 | void handleGameSFCave(); | ||
85 | void handleGameGates(); | ||
86 | void handleGameFly(); | ||
87 | bool checkFlyGameCollision(); | ||
88 | void moveFlyGameLandscape(); | ||
89 | void setFlyPoint( int point ); | ||
73 | bool checkCollision(); | 90 | bool checkCollision(); |
@@ -86,2 +103,3 @@ public: | |||
86 | void keyReleaseEvent( QKeyEvent *e ); | 103 | void keyReleaseEvent( QKeyEvent *e ); |
104 | void saveScore(); | ||
87 | 105 | ||