author | zecke <zecke> | 2004-11-15 14:45:23 (UTC) |
---|---|---|
committer | zecke <zecke> | 2004-11-15 14:45:23 (UTC) |
commit | 74febba2749d3a8eefc13c1f46a0f7f5fc095d5a (patch) (unidiff) | |
tree | 421efd9b22184e94bf4dfdcd02e83fd567cece8f | |
parent | 2423fe1ba41caf6977afaf7df3156522b54db819 (diff) | |
download | opie-74febba2749d3a8eefc13c1f46a0f7f5fc095d5a.zip opie-74febba2749d3a8eefc13c1f46a0f7f5fc095d5a.tar.gz opie-74febba2749d3a8eefc13c1f46a0f7f5fc095d5a.tar.bz2 |
-Make HELP_TEXT translatable
-Make HelpWindow a QWidget
-rw-r--r-- | noncore/games/sfcave/helpwindow.cpp | 77 | ||||
-rw-r--r-- | noncore/games/sfcave/helpwindow.h | 4 | ||||
-rw-r--r-- | noncore/games/sfcave/sfcave.cpp | 7 |
3 files changed, 42 insertions, 46 deletions
diff --git a/noncore/games/sfcave/helpwindow.cpp b/noncore/games/sfcave/helpwindow.cpp index 8a5d034..bd6035a 100644 --- a/noncore/games/sfcave/helpwindow.cpp +++ b/noncore/games/sfcave/helpwindow.cpp | |||
@@ -1,79 +1,76 @@ | |||
1 | /*************************************************************************** | 1 | /*************************************************************************** |
2 | helpwindow.cpp - description | 2 | helpwindow.cpp - description |
3 | ------------------- | 3 | ------------------- |
4 | begin : Sun Sep 8 2002 | 4 | begin : Sun Sep 8 2002 |
5 | copyright : (C) 2002 by Andy Qua | 5 | copyright : (C) 2002 by Andy Qua |
6 | email : andy.qua@blueyonder.co.uk | 6 | email : andy.qua@blueyonder.co.uk |
7 | ***************************************************************************/ | 7 | ***************************************************************************/ |
8 | 8 | ||
9 | /*************************************************************************** | 9 | /*************************************************************************** |
10 | * * | 10 | * * |
11 | * This program is free software; you can redistribute it and/or modify * | 11 | * This program is free software; you can redistribute it and/or modify * |
12 | * it under the terms of the GNU General Public License as published by * | 12 | * it under the terms of the GNU General Public License as published by * |
13 | * the Free Software Foundation; either version 2 of the License, or * | 13 | * the Free Software Foundation; either version 2 of the License, or * |
14 | * (at your option) any later version. * | 14 | * (at your option) any later version. * |
15 | * * | 15 | * * |
16 | ***************************************************************************/ | 16 | ***************************************************************************/ |
17 | 17 | ||
18 | #include <qlayout.h> | 18 | #include <qlayout.h> |
19 | #include <qtextview.h> | 19 | #include <qtextview.h> |
20 | 20 | ||
21 | #include <qpe/qpeapplication.h> | 21 | #include <qpe/qpeapplication.h> |
22 | 22 | ||
23 | #include "helpwindow.h" | 23 | #include "helpwindow.h" |
24 | 24 | ||
25 | 25 | ||
26 | #define HELP_TEXT \ | 26 | static QString HELP_TEXT() { |
27 | "<qt><h1>SFCave Help</h1><p> " \ | 27 | return QObject::tr("<qt><h1>SFCave Help</h1><p> " |
28 | "SFCave is a flying game for the Zaurus.<br><br> " \ | 28 | "SFCave is a flying game for the Zaurus.<br><br> " |
29 | "The aim is to stay alive for as long as possible and get the highest score " \ | 29 | "The aim is to stay alive for as long as possible and get the highest score " |
30 | "you can.<br><br>" \ | 30 | "you can.<br><br>" |
31 | "There are three game types currently - SFCave, Gates, and Fly.<br>" \ | 31 | "There are three game types currently - SFCave, Gates, and Fly.<br>" |
32 | "<b>SFCave</b> is a remake of the classic SFCave game - fly through the " \ | 32 | "<b>SFCave</b> is a remake of the classic SFCave game - fly through the " |
33 | "cavern avoiding all the blocks that just happen to be hanging in " \ | 33 | "cavern avoiding all the blocks that just happen to be hanging in " |
34 | "midair<br><br>" \ | 34 | "midair<br><br>" |
35 | "<b>Gates</b> is similar to SFCave but instead you must fly through the " \ | 35 | "<b>Gates</b> is similar to SFCave but instead you must fly through the " |
36 | "without crashing.<br><br>" \ | 36 | "without crashing.<br><br>" |
37 | "<b>Fly</b> is somewhat different to SFCave and above. Instead, you have " \ | 37 | "<b>Fly</b> is somewhat different to SFCave and above. Instead, you have " |
38 | "are flying in the open air above a scrolling landscape, and the aim is to " \ | 38 | "are flying in the open air above a scrolling landscape, and the aim is to " |
39 | "hug the ground - the closer to the land you fly the more points " \ | 39 | "hug the ground - the closer to the land you fly the more points " |
40 | "scored.<br><br><br>" \ | 40 | "scored.<br><br><br>" |
41 | "Basic instruction - Press <b>Up</B> or <b>Down</b> on the circle pad to " \ | 41 | "Basic instruction - Press <b>Up</B> or <b>Down</b> on the circle pad to " |
42 | "start a new game, press the middle of the pad to apply thrust (makes you " \ | 42 | "start a new game, press the middle of the pad to apply thrust (makes you " |
43 | "go up), and release the pad to remove thrust and drop down.<br><br>" \ | 43 | "go up), and release the pad to remove thrust and drop down.<br><br>" |
44 | "Also, if playing the Fly game, you can press z to toggle the display " \ | 44 | "Also, if playing the Fly game, you can press z to toggle the display " |
45 | "of the scoring zones. This will display 4 red lines at varying heights " \ | 45 | "of the scoring zones. This will display 4 red lines at varying heights " |
46 | "above the landscape - if your ship falls into this zone, point are scored. " \ | 46 | "above the landscape - if your ship falls into this zone, point are scored. " |
47 | "The closer to the landscape you get the more points you get.<br><br>" \ | 47 | "The closer to the landscape you get the more points you get.<br><br>" |
48 | "In addition, SFCave has replays - save and load too so you can show off to all " \ | 48 | "In addition, SFCave has replays - save and load too so you can show off to all " |
49 | "your friends (or vice versa). Currently, this is in its infancy but will improve.<br>" \ | 49 | "your friends (or vice versa). Currently, this is in its infancy but will improve.<br>" |
50 | "To use, once you have crashed, press 'r' to replay the last game.<br>" \ | 50 | "To use, once you have crashed, press 'r' to replay the last game.<br>" |
51 | "To save the replay press 's'.<br>" \ | 51 | "To save the replay press 's'.<br>" |
52 | "To load a saved replay press 'l' (after you've crashed at least once).<br><br>" \ | 52 | "To load a saved replay press 'l' (after you've crashed at least once).<br><br>" |
53 | "Replays are currently saved to your home directory in a file called sfcave.replay." \ | 53 | "Replays are currently saved to your home directory in a file called sfcave.replay." |
54 | "This file can be copied and given to others as long as it it put in their home directory.<br><br>" \ | 54 | "This file can be copied and given to others as long as it it put in their home directory.<br><br>" |
55 | "Have lots of fun.<br>" \ | 55 | "Have lots of fun.<br>" |
56 | "Andy" \ | 56 | "Andy" |
57 | "</p></qt>" | 57 | "</p></qt>"); |
58 | } | ||
58 | 59 | ||
59 | 60 | ||
60 | HelpWindow::HelpWindow( QWidget *parent, const char *name, bool modal, WFlags flags ) | 61 | HelpWindow::HelpWindow( QWidget *parent, const char *name) |
61 | : QDialog( parent, name, modal, flags ) | 62 | : QWidget( parent, name, WDestructiveClose ) |
62 | { | 63 | { |
63 | // resize( 230, 280 ); | 64 | setCaption( tr("Help for SFCave") ); |
64 | |||
65 | setCaption( "Help for SFCave" ); | ||
66 | 65 | ||
67 | QVBoxLayout *layout = new QVBoxLayout( this ); | 66 | QVBoxLayout *layout = new QVBoxLayout( this ); |
68 | QString text = HELP_TEXT;; | 67 | QString text = HELP_TEXT();; |
69 | QTextView *view = new QTextView( text, 0, this, "view" ); | 68 | QTextView *view = new QTextView( text, 0, this, "view" ); |
70 | layout->insertSpacing( -1, 5 ); | 69 | layout->insertSpacing( -1, 5 ); |
71 | layout->insertWidget( -1, view ); | 70 | layout->insertWidget( -1, view ); |
72 | layout->insertSpacing( -1, 5 ); | 71 | layout->insertSpacing( -1, 5 ); |
73 | |||
74 | QPEApplication::showDialog( this ); | ||
75 | } | 72 | } |
76 | 73 | ||
77 | HelpWindow::~HelpWindow() | 74 | HelpWindow::~HelpWindow() |
78 | { | 75 | { |
79 | } | 76 | } |
diff --git a/noncore/games/sfcave/helpwindow.h b/noncore/games/sfcave/helpwindow.h index edc1b6e..0aaba7e 100644 --- a/noncore/games/sfcave/helpwindow.h +++ b/noncore/games/sfcave/helpwindow.h | |||
@@ -1,34 +1,34 @@ | |||
1 | /*************************************************************************** | 1 | /*************************************************************************** |
2 | helpwindow.h - description | 2 | helpwindow.h - description |
3 | ------------------- | 3 | ------------------- |
4 | begin : Sun Sep 8 2002 | 4 | begin : Sun Sep 8 2002 |
5 | copyright : (C) 2002 by Andy Qua | 5 | copyright : (C) 2002 by Andy Qua |
6 | email : andy.qua@blueyonder.co.uk | 6 | email : andy.qua@blueyonder.co.uk |
7 | ***************************************************************************/ | 7 | ***************************************************************************/ |
8 | 8 | ||
9 | /*************************************************************************** | 9 | /*************************************************************************** |
10 | * * | 10 | * * |
11 | * This program is free software; you can redistribute it and/or modify * | 11 | * This program is free software; you can redistribute it and/or modify * |
12 | * it under the terms of the GNU General Public License as published by * | 12 | * it under the terms of the GNU General Public License as published by * |
13 | * the Free Software Foundation; either version 2 of the License, or * | 13 | * the Free Software Foundation; either version 2 of the License, or * |
14 | * (at your option) any later version. * | 14 | * (at your option) any later version. * |
15 | * * | 15 | * * |
16 | ***************************************************************************/ | 16 | ***************************************************************************/ |
17 | 17 | ||
18 | #ifndef HELPWINDOW_H | 18 | #ifndef HELPWINDOW_H |
19 | #define HELPWINDOW_H | 19 | #define HELPWINDOW_H |
20 | 20 | ||
21 | #include <qdialog.h> | 21 | #include <qdialog.h> |
22 | 22 | ||
23 | /** | 23 | /** |
24 | *@author Andy Qua | 24 | *@author Andy Qua |
25 | */ | 25 | */ |
26 | 26 | ||
27 | class HelpWindow : public QDialog | 27 | class HelpWindow : public QWidget |
28 | { | 28 | { |
29 | public: | 29 | public: |
30 | HelpWindow( QWidget *parent = 0, const char *name = 0, bool modal = true, WFlags flags = 0 ); | 30 | HelpWindow( QWidget *parent = 0, const char *name = 0); |
31 | ~HelpWindow(); | 31 | ~HelpWindow(); |
32 | }; | 32 | }; |
33 | 33 | ||
34 | #endif | 34 | #endif |
diff --git a/noncore/games/sfcave/sfcave.cpp b/noncore/games/sfcave/sfcave.cpp index d5aa38a..a6c92a0 100644 --- a/noncore/games/sfcave/sfcave.cpp +++ b/noncore/games/sfcave/sfcave.cpp | |||
@@ -1,1212 +1,1211 @@ | |||
1 | #include <stdio.h> | 1 | #include <stdio.h> |
2 | #include <stdlib.h> | 2 | #include <stdlib.h> |
3 | #include <math.h> | 3 | #include <math.h> |
4 | #include <time.h> | 4 | #include <time.h> |
5 | 5 | ||
6 | #include <opie2/oapplicationfactory.h> | 6 | #include <opie2/oapplicationfactory.h> |
7 | #include <qpe/qpeapplication.h> | ||
7 | #include <qpe/config.h> | 8 | #include <qpe/config.h> |
8 | #include <qpe/global.h> | 9 | #include <qpe/global.h> |
9 | 10 | ||
10 | #include <qapplication.h> | ||
11 | #include <qdir.h> | 11 | #include <qdir.h> |
12 | 12 | ||
13 | #include "helpwindow.h" | 13 | #include "helpwindow.h" |
14 | #include "sfcave.h" | 14 | #include "sfcave.h" |
15 | 15 | ||
16 | #define CAPTION "SFCave 1.13 by AndyQ" | 16 | #define CAPTION "SFCave 1.13 by AndyQ" |
17 | 17 | ||
18 | #define UP_THRUST 0.6 | 18 | #define UP_THRUST 0.6 |
19 | #define NO_THRUST 0.8 | 19 | #define NO_THRUST 0.8 |
20 | #define MAX_DOWN_THRUST 4.0 | 20 | #define MAX_DOWN_THRUST 4.0 |
21 | #define MAX_UP_THRUST -3.5 | 21 | #define MAX_UP_THRUST -3.5 |
22 | 22 | ||
23 | // States | 23 | // States |
24 | #define STATE_BOSS 0 | 24 | #define STATE_BOSS 0 |
25 | #define STATE_RUNNING 1 | 25 | #define STATE_RUNNING 1 |
26 | #define STATE_CRASHING 2 | 26 | #define STATE_CRASHING 2 |
27 | #define STATE_CRASHED 3 | 27 | #define STATE_CRASHED 3 |
28 | #define STATE_NEWGAME 4 | 28 | #define STATE_NEWGAME 4 |
29 | #define STATE_MENU 5 | 29 | #define STATE_MENU 5 |
30 | #define STATE_REPLAY 6 | 30 | #define STATE_REPLAY 6 |
31 | 31 | ||
32 | // Menus | 32 | // Menus |
33 | #define MENU_MAIN_MENU 0 | 33 | #define MENU_MAIN_MENU 0 |
34 | #define MENU_OPTIONS_MENU 1 | 34 | #define MENU_OPTIONS_MENU 1 |
35 | #define MENU_REPLAY_MENU 2 | 35 | #define MENU_REPLAY_MENU 2 |
36 | 36 | ||
37 | // Main Menu Options | 37 | // Main Menu Options |
38 | #define MENU_START_GAME 0 | 38 | #define MENU_START_GAME 0 |
39 | #define MENU_REPLAY 1 | 39 | #define MENU_REPLAY 1 |
40 | #define MENU_OPTIONS 2 | 40 | #define MENU_OPTIONS 2 |
41 | #define MENU_HELP 3 | 41 | #define MENU_HELP 3 |
42 | #define MENU_QUIT 4 | 42 | #define MENU_QUIT 4 |
43 | 43 | ||
44 | // Option Menu Options | 44 | // Option Menu Options |
45 | #define MENU_GAME_TYPE 0 | 45 | #define MENU_GAME_TYPE 0 |
46 | #define MENU_GAME_DIFFICULTY 1 | 46 | #define MENU_GAME_DIFFICULTY 1 |
47 | #define MENU_CLEAR_HIGHSCORES 2 | 47 | #define MENU_CLEAR_HIGHSCORES 2 |
48 | #define MENU_BACK 3 | 48 | #define MENU_BACK 3 |
49 | 49 | ||
50 | // Replay Menu Options | 50 | // Replay Menu Options |
51 | #define MENU_REPLAY_START 0 | 51 | #define MENU_REPLAY_START 0 |
52 | #define MENU_REPLAY_LOAD 1 | 52 | #define MENU_REPLAY_LOAD 1 |
53 | #define MENU_REPLAY_SAVE 2 | 53 | #define MENU_REPLAY_SAVE 2 |
54 | #define MENU_REPLAY_BACK 3 | 54 | #define MENU_REPLAY_BACK 3 |
55 | 55 | ||
56 | 56 | ||
57 | #define NR_GAME_DIFFICULTIES 3 | 57 | #define NR_GAME_DIFFICULTIES 3 |
58 | #define NR_GAME_TYPES 3 | 58 | #define NR_GAME_TYPES 3 |
59 | 59 | ||
60 | #define DIFICULTY_EASY 0 | 60 | #define DIFICULTY_EASY 0 |
61 | #define DIFICULTY_NORMAL 1 | 61 | #define DIFICULTY_NORMAL 1 |
62 | #define DIFICULTY_HARD 2 | 62 | #define DIFICULTY_HARD 2 |
63 | #define EASY "Easy" | 63 | #define EASY "Easy" |
64 | #define NORMAL "Normal" | 64 | #define NORMAL "Normal" |
65 | #define HARD "Hard" | 65 | #define HARD "Hard" |
66 | 66 | ||
67 | #define SFCAVE_GAME_TYPE 0 | 67 | #define SFCAVE_GAME_TYPE 0 |
68 | #define GATES_GAME_TYPE 1 | 68 | #define GATES_GAME_TYPE 1 |
69 | #define FLY_GAME_TYPE 2 | 69 | #define FLY_GAME_TYPE 2 |
70 | #define SFCAVE_GAME "SFCave" | 70 | #define SFCAVE_GAME "SFCave" |
71 | #define GATES_GAME "Gates" | 71 | #define GATES_GAME "Gates" |
72 | #define FLY_GAME "Fly" | 72 | #define FLY_GAME "Fly" |
73 | #define CURRENT_GAME_TYPE gameTypes[currentGameType] | 73 | #define CURRENT_GAME_TYPE gameTypes[currentGameType] |
74 | #define CURRENT_GAME_DIFFICULTY difficultyOption[currentGameDifficulty]; | 74 | #define CURRENT_GAME_DIFFICULTY difficultyOption[currentGameDifficulty]; |
75 | 75 | ||
76 | QString SFCave::dificultyOption[] = { EASY, NORMAL, HARD }; | 76 | QString SFCave::dificultyOption[] = { EASY, NORMAL, HARD }; |
77 | QString SFCave::gameTypes[] = { SFCAVE_GAME, GATES_GAME, FLY_GAME }; | 77 | QString SFCave::gameTypes[] = { SFCAVE_GAME, GATES_GAME, FLY_GAME }; |
78 | 78 | ||
79 | QString SFCave::menuOptions[NR_MENUS][MAX_MENU_OPTIONS] = { { "Start Game", "Replays", "Options", "Help", "Quit", "", "", "" }, | 79 | QString SFCave::menuOptions[NR_MENUS][MAX_MENU_OPTIONS] = { { "Start Game", "Replays", "Options", "Help", "Quit", "", "", "" }, |
80 | { "Game Type - %s", "Game Difficulty - %s", "Clear High Scores for this game", "Back", "", "", "", "" }, | 80 | { "Game Type - %s", "Game Difficulty - %s", "Clear High Scores for this game", "Back", "", "", "", "" }, |
81 | { "Play Reply", "Load Replay", "Save Replay", "Back", "", "", "", "" } }; | 81 | { "Play Reply", "Load Replay", "Save Replay", "Back", "", "", "", "" } }; |
82 | 82 | ||
83 | int SFCave::nrMenuOptions[NR_MENUS] = { 5, 4, 4 }; | 83 | int SFCave::nrMenuOptions[NR_MENUS] = { 5, 4, 4 }; |
84 | int SFCave ::currentMenuOption[NR_MENUS] = { 0, 0, 0 }; | 84 | int SFCave ::currentMenuOption[NR_MENUS] = { 0, 0, 0 }; |
85 | 85 | ||
86 | #define UP_THRUST 0.6 | 86 | #define UP_THRUST 0.6 |
87 | #define NO_THRUST 0.8 | 87 | #define NO_THRUST 0.8 |
88 | #define MAX_DOWN_THRUST 4.0 | 88 | #define MAX_DOWN_THRUST 4.0 |
89 | #define MAX_UP_THRUST -3.5 | 89 | #define MAX_UP_THRUST -3.5 |
90 | double SFCave::UpThrustVals[3][3] = {{ 0.6, 0.6, 0.6 }, // SFCave | 90 | double SFCave::UpThrustVals[3][3] = {{ 0.6, 0.6, 0.6 }, // SFCave |
91 | { 0.6, 0.6, 0.8 }, // Gates | 91 | { 0.6, 0.6, 0.8 }, // Gates |
92 | { 0.4, 0.7, 1.0 } }; // Fly | 92 | { 0.4, 0.7, 1.0 } }; // Fly |
93 | 93 | ||
94 | double SFCave::DownThrustVals[3][3] = {{ 0.8, 0.8, 0.8 }, // SFCave | 94 | double SFCave::DownThrustVals[3][3] = {{ 0.8, 0.8, 0.8 }, // SFCave |
95 | { 0.8, 0.8, 1.0 }, // Gates | 95 | { 0.8, 0.8, 1.0 }, // Gates |
96 | { 0.4, 0.7, 1.0 } }; // Fly | 96 | { 0.4, 0.7, 1.0 } }; // Fly |
97 | 97 | ||
98 | double SFCave::MaxUpThrustVals[3][3] = {{ -3.5, -3.5, -3.5 }, // SFCave | 98 | double SFCave::MaxUpThrustVals[3][3] = {{ -3.5, -3.5, -3.5 }, // SFCave |
99 | { -3.5, -4.0, -5.0 }, // Gates | 99 | { -3.5, -4.0, -5.0 }, // Gates |
100 | { -3.5, -4.0, -5.0 } }; // Fly | 100 | { -3.5, -4.0, -5.0 } }; // Fly |
101 | 101 | ||
102 | double SFCave::MaxDownThrustVals[3][3] = {{ 4.0, 4.0, 4.0 }, // SFCave | 102 | double SFCave::MaxDownThrustVals[3][3] = {{ 4.0, 4.0, 4.0 }, // SFCave |
103 | { 4.0, 5.0, 5.5 }, // Gates | 103 | { 4.0, 5.0, 5.5 }, // Gates |
104 | { 3.5, 4.0, 5.0 } }; // Fly | 104 | { 3.5, 4.0, 5.0 } }; // Fly |
105 | 105 | ||
106 | int SFCave::flyEasyScores[7][3] = { { 0, 10, 5 }, | 106 | int SFCave::flyEasyScores[7][3] = { { 0, 10, 5 }, |
107 | { 10, 20, 3 }, | 107 | { 10, 20, 3 }, |
108 | { 20, 30, 2 }, | 108 | { 20, 30, 2 }, |
109 | { 30, 40, 1 }, | 109 | { 30, 40, 1 }, |
110 | { 50, 70, -2 }, | 110 | { 50, 70, -2 }, |
111 | { 70, 300, -5 }, | 111 | { 70, 300, -5 }, |
112 | { -1, -1, -1 } }; | 112 | { -1, -1, -1 } }; |
113 | int SFCave::flyNormalScores[7][3] = { { 0, 10, 5 }, | 113 | int SFCave::flyNormalScores[7][3] = { { 0, 10, 5 }, |
114 | { 10, 20, 3 }, | 114 | { 10, 20, 3 }, |
115 | { 20, 30, 2 }, | 115 | { 20, 30, 2 }, |
116 | { 30, 40, 1 }, | 116 | { 30, 40, 1 }, |
117 | { 50, 70, -2 }, | 117 | { 50, 70, -2 }, |
118 | { 70, 300, -5 }, | 118 | { 70, 300, -5 }, |
119 | { -1, -1, -1 } }; | 119 | { -1, -1, -1 } }; |
120 | int SFCave::flyHardScores[7][3] = { { 0, 20, 5 }, | 120 | int SFCave::flyHardScores[7][3] = { { 0, 20, 5 }, |
121 | { 20, 40, 3 }, | 121 | { 20, 40, 3 }, |
122 | { 40, 100, 1 }, | 122 | { 40, 100, 1 }, |
123 | { 100, 150, -2 }, | 123 | { 100, 150, -2 }, |
124 | { 150, 300, -5 }, | 124 | { 150, 300, -5 }, |
125 | { -1, -1, -1 } }; | 125 | { -1, -1, -1 } }; |
126 | 126 | ||
127 | int SFCave::initialGateGaps[] = { 75, 50, 25 }; | 127 | int SFCave::initialGateGaps[] = { 75, 50, 25 }; |
128 | 128 | ||
129 | 129 | ||
130 | #define FLYSCORES( x, y ) (*(flyScores + ((x)*3) + y)) | 130 | #define FLYSCORES( x, y ) (*(flyScores + ((x)*3) + y)) |
131 | bool movel; | 131 | bool movel; |
132 | 132 | ||
133 | 133 | ||
134 | OPIE_EXPORT_APP( Opie::Core::OApplicationFactory<SFCave> ) | 134 | OPIE_EXPORT_APP( Opie::Core::OApplicationFactory<SFCave> ) |
135 | 135 | ||
136 | SFCave :: SFCave( QWidget *w, const char *name, WFlags fl ) | 136 | SFCave :: SFCave( QWidget *w, const char *name, WFlags fl ) |
137 | : QMainWindow( w, name, fl ) | 137 | : QMainWindow( w, name, fl ) |
138 | 138 | ||
139 | { | 139 | { |
140 | showMaximized(); | 140 | showMaximized(); |
141 | movel = true; | 141 | movel = true; |
142 | int spd = 3; | 142 | int spd = 3; |
143 | 143 | ||
144 | 144 | ||
145 | replayIt = 0; | 145 | replayIt = 0; |
146 | 146 | ||
147 | replayFile = Global::applicationFileName("sfcave", "replay"); | 147 | replayFile = Global::applicationFileName("sfcave", "replay"); |
148 | 148 | ||
149 | sWidth = width(); | 149 | sWidth = width(); |
150 | sHeight = height(); | 150 | sHeight = height(); |
151 | segSize = sWidth/(MAPSIZE-1)+1; | 151 | segSize = sWidth/(MAPSIZE-1)+1; |
152 | 152 | ||
153 | currentMenuNr = 0; | 153 | currentMenuNr = 0; |
154 | currentGameType = 0; | 154 | currentGameType = 0; |
155 | currentGameDifficulty = 0; | 155 | currentGameDifficulty = 0; |
156 | 156 | ||
157 | setCaption( CAPTION ); | 157 | setCaption( CAPTION ); |
158 | showScoreZones = false; | 158 | showScoreZones = false; |
159 | 159 | ||
160 | #ifdef QWS | 160 | #ifdef QWS |
161 | Config cfg( "sfcave" ); | 161 | Config cfg( "sfcave" ); |
162 | cfg.setGroup( "settings" ); | 162 | cfg.setGroup( "settings" ); |
163 | QString key = "highScore_"; | 163 | QString key = "highScore_"; |
164 | 164 | ||
165 | for ( int i = 0 ; i < 3 ; ++i ) | 165 | for ( int i = 0 ; i < 3 ; ++i ) |
166 | { | 166 | { |
167 | for ( int j = 0 ; j < 3 ; ++j ) | 167 | for ( int j = 0 ; j < 3 ; ++j ) |
168 | highestScore[i][j] = cfg.readNumEntry( key + gameTypes[i] + "_" + dificultyOption[j], 0 ); | 168 | highestScore[i][j] = cfg.readNumEntry( key + gameTypes[i] + "_" + dificultyOption[j], 0 ); |
169 | } | 169 | } |
170 | 170 | ||
171 | currentGameType = cfg.readNumEntry( "gameType", 0 ); | 171 | currentGameType = cfg.readNumEntry( "gameType", 0 ); |
172 | currentGameDifficulty = cfg.readNumEntry( "difficulty", 0 ); | 172 | currentGameDifficulty = cfg.readNumEntry( "difficulty", 0 ); |
173 | #endif | 173 | #endif |
174 | speed = spd; // Change to 2 for PC | 174 | speed = spd; // Change to 2 for PC |
175 | press = false; | 175 | press = false; |
176 | showEyeCandy = false; | 176 | showEyeCandy = false; |
177 | 177 | ||
178 | offscreen = new QPixmap( sWidth, sHeight ); | 178 | offscreen = new QPixmap( sWidth, sHeight ); |
179 | offscreen->fill( Qt::black ); | 179 | offscreen->fill( Qt::black ); |
180 | 180 | ||
181 | // setUp(); | 181 | // setUp(); |
182 | crashLineLength = -1; | 182 | crashLineLength = -1; |
183 | state = STATE_MENU; | 183 | state = STATE_MENU; |
184 | prevState = STATE_MENU; | 184 | prevState = STATE_MENU; |
185 | 185 | ||
186 | gameTimer = new QTimer( this, "game timer" ); | 186 | gameTimer = new QTimer( this, "game timer" ); |
187 | connect( gameTimer, SIGNAL( timeout() ), | 187 | connect( gameTimer, SIGNAL( timeout() ), |
188 | this, SLOT( run() ) ); | 188 | this, SLOT( run() ) ); |
189 | 189 | ||
190 | QTimer::singleShot(0, this, SLOT(start())); | 190 | QTimer::singleShot(0, this, SLOT(start())); |
191 | } | 191 | } |
192 | 192 | ||
193 | SFCave :: ~SFCave() | 193 | SFCave :: ~SFCave() |
194 | { | 194 | { |
195 | } | 195 | } |
196 | 196 | ||
197 | void SFCave :: start() | 197 | void SFCave :: start() |
198 | { | 198 | { |
199 | gameTimer->start( 10 ); | 199 | gameTimer->start( 10 ); |
200 | 200 | ||
201 | } | 201 | } |
202 | 202 | ||
203 | void SFCave :: setSeed( int seed ) | 203 | void SFCave :: setSeed( int seed ) |
204 | { | 204 | { |
205 | if ( seed == -1 ) | 205 | if ( seed == -1 ) |
206 | currentSeed = ((unsigned long) time((time_t *) NULL)); | 206 | currentSeed = ((unsigned long) time((time_t *) NULL)); |
207 | else | 207 | else |
208 | currentSeed = seed; | 208 | currentSeed = seed; |
209 | PutSeed( currentSeed ); | 209 | PutSeed( currentSeed ); |
210 | } | 210 | } |
211 | 211 | ||
212 | int SFCave :: nextInt( int range ) | 212 | int SFCave :: nextInt( int range ) |
213 | { | 213 | { |
214 | int val = (int)(Random( ) * range); | 214 | int val = (int)(Random( ) * range); |
215 | 215 | ||
216 | return val; | 216 | return val; |
217 | 217 | ||
218 | } | 218 | } |
219 | 219 | ||
220 | void SFCave :: setUp() | 220 | void SFCave :: setUp() |
221 | { | 221 | { |
222 | score = 0; | 222 | score = 0; |
223 | offset = 0; | 223 | offset = 0; |
224 | nrFrames = 0; | 224 | nrFrames = 0; |
225 | dir = 1; | 225 | dir = 1; |
226 | thrust = 0; | 226 | thrust = 0; |
227 | startScoring = false; | 227 | startScoring = false; |
228 | press = false; | 228 | press = false; |
229 | 229 | ||
230 | if ( CURRENT_GAME_TYPE == SFCAVE_GAME ) | 230 | if ( CURRENT_GAME_TYPE == SFCAVE_GAME ) |
231 | { | 231 | { |
232 | thrustUp = UpThrustVals[SFCAVE_GAME_TYPE][currentGameDifficulty];; | 232 | thrustUp = UpThrustVals[SFCAVE_GAME_TYPE][currentGameDifficulty];; |
233 | noThrust = DownThrustVals[SFCAVE_GAME_TYPE][currentGameDifficulty];; | 233 | noThrust = DownThrustVals[SFCAVE_GAME_TYPE][currentGameDifficulty];; |
234 | maxUpThrust = MaxUpThrustVals[SFCAVE_GAME_TYPE][currentGameDifficulty];; | 234 | maxUpThrust = MaxUpThrustVals[SFCAVE_GAME_TYPE][currentGameDifficulty];; |
235 | maxDownThrust = MaxDownThrustVals[SFCAVE_GAME_TYPE][currentGameDifficulty];; | 235 | maxDownThrust = MaxDownThrustVals[SFCAVE_GAME_TYPE][currentGameDifficulty];; |
236 | 236 | ||
237 | if ( currentGameDifficulty == DIFICULTY_EASY ) | 237 | if ( currentGameDifficulty == DIFICULTY_EASY ) |
238 | gateDistance = 100; | 238 | gateDistance = 100; |
239 | else if ( currentGameDifficulty == DIFICULTY_NORMAL ) | 239 | else if ( currentGameDifficulty == DIFICULTY_NORMAL ) |
240 | gateDistance = 60; | 240 | gateDistance = 60; |
241 | else | 241 | else |
242 | gateDistance = 40; | 242 | gateDistance = 40; |
243 | } | 243 | } |
244 | else if ( CURRENT_GAME_TYPE == GATES_GAME ) | 244 | else if ( CURRENT_GAME_TYPE == GATES_GAME ) |
245 | { | 245 | { |
246 | thrustUp = UpThrustVals[GATES_GAME_TYPE][currentGameDifficulty];; | 246 | thrustUp = UpThrustVals[GATES_GAME_TYPE][currentGameDifficulty];; |
247 | noThrust = DownThrustVals[GATES_GAME_TYPE][currentGameDifficulty];; | 247 | noThrust = DownThrustVals[GATES_GAME_TYPE][currentGameDifficulty];; |
248 | maxUpThrust = MaxUpThrustVals[GATES_GAME_TYPE][currentGameDifficulty];; | 248 | maxUpThrust = MaxUpThrustVals[GATES_GAME_TYPE][currentGameDifficulty];; |
249 | maxDownThrust = MaxDownThrustVals[GATES_GAME_TYPE][currentGameDifficulty];; | 249 | maxDownThrust = MaxDownThrustVals[GATES_GAME_TYPE][currentGameDifficulty];; |
250 | gateDistance = 75; | 250 | gateDistance = 75; |
251 | nextGate = nextInt( 50 ) + gateDistance; | 251 | nextGate = nextInt( 50 ) + gateDistance; |
252 | } | 252 | } |
253 | else | 253 | else |
254 | { | 254 | { |
255 | thrustUp = UpThrustVals[FLY_GAME_TYPE][currentGameDifficulty]; | 255 | thrustUp = UpThrustVals[FLY_GAME_TYPE][currentGameDifficulty]; |
256 | noThrust = DownThrustVals[FLY_GAME_TYPE][currentGameDifficulty]; | 256 | noThrust = DownThrustVals[FLY_GAME_TYPE][currentGameDifficulty]; |
257 | maxUpThrust = MaxUpThrustVals[FLY_GAME_TYPE][currentGameDifficulty]; | 257 | maxUpThrust = MaxUpThrustVals[FLY_GAME_TYPE][currentGameDifficulty]; |
258 | maxDownThrust = MaxDownThrustVals[FLY_GAME_TYPE][currentGameDifficulty]; | 258 | maxDownThrust = MaxDownThrustVals[FLY_GAME_TYPE][currentGameDifficulty]; |
259 | 259 | ||
260 | if ( currentGameDifficulty == DIFICULTY_EASY ) | 260 | if ( currentGameDifficulty == DIFICULTY_EASY ) |
261 | flyScores = (int*)flyEasyScores; | 261 | flyScores = (int*)flyEasyScores; |
262 | else if ( currentGameDifficulty == DIFICULTY_NORMAL ) | 262 | else if ( currentGameDifficulty == DIFICULTY_NORMAL ) |
263 | flyScores = (int*)flyNormalScores; | 263 | flyScores = (int*)flyNormalScores; |
264 | else | 264 | else |
265 | flyScores = (int*)flyHardScores; | 265 | flyScores = (int*)flyHardScores; |
266 | } | 266 | } |
267 | 267 | ||
268 | crashLineLength = 0; | 268 | crashLineLength = 0; |
269 | lastGateBottomY = 0; | 269 | lastGateBottomY = 0; |
270 | 270 | ||
271 | user.setRect( 50, sWidth/2, 4, 4 ); | 271 | user.setRect( 50, sWidth/2, 4, 4 ); |
272 | 272 | ||
273 | blockWidth = 20; | 273 | blockWidth = 20; |
274 | blockHeight = 70; | 274 | blockHeight = 70; |
275 | gapHeight = initialGateGaps[currentGameDifficulty]; | 275 | gapHeight = initialGateGaps[currentGameDifficulty]; |
276 | 276 | ||
277 | for ( int i = 0 ; i < TRAILSIZE ; ++i ) | 277 | for ( int i = 0 ; i < TRAILSIZE ; ++i ) |
278 | { | 278 | { |
279 | trail[i].setX( -1 ); | 279 | trail[i].setX( -1 ); |
280 | trail[i].setY( 0 ); | 280 | trail[i].setY( 0 ); |
281 | } | 281 | } |
282 | 282 | ||
283 | if ( CURRENT_GAME_TYPE != FLY_GAME ) | 283 | if ( CURRENT_GAME_TYPE != FLY_GAME ) |
284 | { | 284 | { |
285 | maxHeight = 50; | 285 | maxHeight = 50; |
286 | 286 | ||
287 | mapTop[0] = (int)(nextInt(50)) + 5; | 287 | mapTop[0] = (int)(nextInt(50)) + 5; |
288 | mapBottom[0] = (int)(nextInt(50)) + 5; | 288 | mapBottom[0] = (int)(nextInt(50)) + 5; |
289 | for ( int i = 1 ; i < MAPSIZE ; ++i ) | 289 | for ( int i = 1 ; i < MAPSIZE ; ++i ) |
290 | setPoint( i ); | 290 | setPoint( i ); |
291 | } | 291 | } |
292 | else | 292 | else |
293 | { | 293 | { |
294 | maxHeight = 100; | 294 | maxHeight = 100; |
295 | 295 | ||
296 | for ( int i = 0 ; i < MAPSIZE ; ++i ) | 296 | for ( int i = 0 ; i < MAPSIZE ; ++i ) |
297 | mapBottom[i] = sHeight - 10; | 297 | mapBottom[i] = sHeight - 10; |
298 | } | 298 | } |
299 | for ( int i = 0 ; i < BLOCKSIZE ; ++i ) | 299 | for ( int i = 0 ; i < BLOCKSIZE ; ++i ) |
300 | blocks[i].setY( -1 ); | 300 | blocks[i].setY( -1 ); |
301 | 301 | ||
302 | } | 302 | } |
303 | 303 | ||
304 | void SFCave :: run() | 304 | void SFCave :: run() |
305 | { | 305 | { |
306 | switch ( state ) | 306 | switch ( state ) |
307 | { | 307 | { |
308 | case STATE_MENU: | 308 | case STATE_MENU: |
309 | displayMenu(); | 309 | displayMenu(); |
310 | break; | 310 | break; |
311 | case STATE_NEWGAME: | 311 | case STATE_NEWGAME: |
312 | setSeed( -1 ); | 312 | setSeed( -1 ); |
313 | setUp(); | 313 | setUp(); |
314 | draw(); | 314 | draw(); |
315 | state = STATE_RUNNING; | 315 | state = STATE_RUNNING; |
316 | replay = false; | 316 | replay = false; |
317 | replayList.clear(); | 317 | replayList.clear(); |
318 | break; | 318 | break; |
319 | case STATE_REPLAY: | 319 | case STATE_REPLAY: |
320 | setSeed( currentSeed ); | 320 | setSeed( currentSeed ); |
321 | setUp(); | 321 | setUp(); |
322 | draw(); | 322 | draw(); |
323 | state = STATE_RUNNING; | 323 | state = STATE_RUNNING; |
324 | replay = true; | 324 | replay = true; |
325 | if ( replayIt ) | 325 | if ( replayIt ) |
326 | delete replayIt; | 326 | delete replayIt; |
327 | replayIt = new QListIterator<int>( replayList ); | 327 | replayIt = new QListIterator<int>( replayList ); |
328 | break; | 328 | break; |
329 | case STATE_BOSS: | 329 | case STATE_BOSS: |
330 | drawBoss(); | 330 | drawBoss(); |
331 | break; | 331 | break; |
332 | 332 | ||
333 | case STATE_CRASHING: | 333 | case STATE_CRASHING: |
334 | case STATE_CRASHED: | 334 | case STATE_CRASHED: |
335 | press = false; | 335 | press = false; |
336 | draw(); | 336 | draw(); |
337 | break; | 337 | break; |
338 | 338 | ||
339 | case STATE_RUNNING: | 339 | case STATE_RUNNING: |
340 | { | 340 | { |
341 | if ( nrFrames % 2 == 0 ) | 341 | if ( nrFrames % 2 == 0 ) |
342 | handleKeys(); | 342 | handleKeys(); |
343 | 343 | ||
344 | // Apply Game rules | 344 | // Apply Game rules |
345 | nrFrames ++; | 345 | nrFrames ++; |
346 | 346 | ||
347 | if ( replay ) | 347 | if ( replay ) |
348 | { | 348 | { |
349 | while( replayIt->current() && *(replayIt->current()) == nrFrames ) | 349 | while( replayIt->current() && *(replayIt->current()) == nrFrames ) |
350 | { | 350 | { |
351 | press = !press; | 351 | press = !press; |
352 | ++(*replayIt); | 352 | ++(*replayIt); |
353 | } | 353 | } |
354 | } | 354 | } |
355 | 355 | ||
356 | if ( CURRENT_GAME_TYPE == SFCAVE_GAME ) | 356 | if ( CURRENT_GAME_TYPE == SFCAVE_GAME ) |
357 | handleGameSFCave(); | 357 | handleGameSFCave(); |
358 | else if ( CURRENT_GAME_TYPE == GATES_GAME ) | 358 | else if ( CURRENT_GAME_TYPE == GATES_GAME ) |
359 | handleGameGates(); | 359 | handleGameGates(); |
360 | else if ( CURRENT_GAME_TYPE == FLY_GAME ) | 360 | else if ( CURRENT_GAME_TYPE == FLY_GAME ) |
361 | handleGameFly(); | 361 | handleGameFly(); |
362 | 362 | ||
363 | draw(); | 363 | draw(); |
364 | break; | 364 | break; |
365 | } | 365 | } |
366 | } | 366 | } |
367 | } | 367 | } |
368 | 368 | ||
369 | void SFCave :: handleGameSFCave() | 369 | void SFCave :: handleGameSFCave() |
370 | { | 370 | { |
371 | // Update score | 371 | // Update score |
372 | if ( nrFrames % 5 == 0 ) | 372 | if ( nrFrames % 5 == 0 ) |
373 | score ++; | 373 | score ++; |
374 | 374 | ||
375 | if ( nrFrames % 500 == 0 ) | 375 | if ( nrFrames % 500 == 0 ) |
376 | { | 376 | { |
377 | if ( maxHeight < sHeight - 100 ) | 377 | if ( maxHeight < sHeight - 100 ) |
378 | { | 378 | { |
379 | maxHeight += 10; | 379 | maxHeight += 10; |
380 | 380 | ||
381 | // Reduce block height | 381 | // Reduce block height |
382 | if ( maxHeight > sHeight - 150 ) | 382 | if ( maxHeight > sHeight - 150 ) |
383 | blockHeight -= 5; | 383 | blockHeight -= 5; |
384 | } | 384 | } |
385 | } | 385 | } |
386 | 386 | ||
387 | if ( nrFrames % gateDistance == 0 ) | 387 | if ( nrFrames % gateDistance == 0 ) |
388 | addBlock(); | 388 | addBlock(); |
389 | 389 | ||
390 | if ( checkCollision() ) | 390 | if ( checkCollision() ) |
391 | { | 391 | { |
392 | if ( score > highestScore[currentGameType][currentGameDifficulty] ) | 392 | if ( score > highestScore[currentGameType][currentGameDifficulty] ) |
393 | { | 393 | { |
394 | highestScore[currentGameType][currentGameDifficulty] = score; | 394 | highestScore[currentGameType][currentGameDifficulty] = score; |
395 | saveScore(); | 395 | saveScore(); |
396 | } | 396 | } |
397 | state = STATE_CRASHING; | 397 | state = STATE_CRASHING; |
398 | } | 398 | } |
399 | else | 399 | else |
400 | { | 400 | { |
401 | moveLandscape(); | 401 | moveLandscape(); |
402 | } | 402 | } |
403 | 403 | ||
404 | } | 404 | } |
405 | 405 | ||
406 | 406 | ||
407 | void SFCave :: handleGameGates() | 407 | void SFCave :: handleGameGates() |
408 | { | 408 | { |
409 | // Update score | 409 | // Update score |
410 | if ( nrFrames % 5 == 0 ) | 410 | if ( nrFrames % 5 == 0 ) |
411 | score ++; | 411 | score ++; |
412 | 412 | ||
413 | // Slightly random gap distance | 413 | // Slightly random gap distance |
414 | if ( nrFrames >= nextGate ) | 414 | if ( nrFrames >= nextGate ) |
415 | { | 415 | { |
416 | nextGate = nrFrames + nextInt( 50 ) + gateDistance; | 416 | nextGate = nrFrames + nextInt( 50 ) + gateDistance; |
417 | addGate(); | 417 | addGate(); |
418 | } | 418 | } |
419 | 419 | ||
420 | if ( nrFrames % 500 == 0 ) | 420 | if ( nrFrames % 500 == 0 ) |
421 | { | 421 | { |
422 | if ( gapHeight > 75 ) | 422 | if ( gapHeight > 75 ) |
423 | gapHeight -= 5; | 423 | gapHeight -= 5; |
424 | } | 424 | } |
425 | 425 | ||
426 | if ( checkCollision() ) | 426 | if ( checkCollision() ) |
427 | { | 427 | { |
428 | if ( score > highestScore[currentGameType][currentGameDifficulty] ) | 428 | if ( score > highestScore[currentGameType][currentGameDifficulty] ) |
429 | { | 429 | { |
430 | highestScore[currentGameType][currentGameDifficulty] = score; | 430 | highestScore[currentGameType][currentGameDifficulty] = score; |
431 | saveScore(); | 431 | saveScore(); |
432 | } | 432 | } |
433 | state = STATE_CRASHING; | 433 | state = STATE_CRASHING; |
434 | } | 434 | } |
435 | else | 435 | else |
436 | { | 436 | { |
437 | moveLandscape(); | 437 | moveLandscape(); |
438 | } | 438 | } |
439 | 439 | ||
440 | } | 440 | } |
441 | 441 | ||
442 | void SFCave :: handleGameFly() | 442 | void SFCave :: handleGameFly() |
443 | { | 443 | { |
444 | int diff = mapBottom[10] - user.y(); | 444 | int diff = mapBottom[10] - user.y(); |
445 | 445 | ||
446 | if ( nrFrames % 4 == 0 ) | 446 | if ( nrFrames % 4 == 0 ) |
447 | { | 447 | { |
448 | if ( !startScoring ) | 448 | if ( !startScoring ) |
449 | { | 449 | { |
450 | if ( diff < 40 ) | 450 | if ( diff < 40 ) |
451 | startScoring = true; | 451 | startScoring = true; |
452 | } | 452 | } |
453 | 453 | ||
454 | if ( startScoring ) | 454 | if ( startScoring ) |
455 | { | 455 | { |
456 | // Update score | 456 | // Update score |
457 | // get distance between landscape and ship | 457 | // get distance between landscape and ship |
458 | 458 | ||
459 | // the closer the difference is to 0 means more points | 459 | // the closer the difference is to 0 means more points |
460 | for ( int i = 0 ; i < 10 && FLYSCORES( i, 0 ) != -1 ; ++i ) | 460 | for ( int i = 0 ; i < 10 && FLYSCORES( i, 0 ) != -1 ; ++i ) |
461 | { | 461 | { |
462 | if ( FLYSCORES( i, 0 ) <= diff && FLYSCORES(i, 1 ) > diff ) | 462 | if ( FLYSCORES( i, 0 ) <= diff && FLYSCORES(i, 1 ) > diff ) |
463 | { | 463 | { |
464 | score += FLYSCORES( i, 2 ); | 464 | score += FLYSCORES( i, 2 ); |
465 | break; | 465 | break; |
466 | } | 466 | } |
467 | } | 467 | } |
468 | } | 468 | } |
469 | } | 469 | } |
470 | 470 | ||
471 | if ( checkFlyGameCollision() ) | 471 | if ( checkFlyGameCollision() ) |
472 | { | 472 | { |
473 | if ( score > highestScore[currentGameType][currentGameDifficulty] ) | 473 | if ( score > highestScore[currentGameType][currentGameDifficulty] ) |
474 | { | 474 | { |
475 | highestScore[currentGameType][currentGameDifficulty] = score; | 475 | highestScore[currentGameType][currentGameDifficulty] = score; |
476 | saveScore(); | 476 | saveScore(); |
477 | } | 477 | } |
478 | state = STATE_CRASHING; | 478 | state = STATE_CRASHING; |
479 | } | 479 | } |
480 | else | 480 | else |
481 | { | 481 | { |
482 | moveFlyGameLandscape(); | 482 | moveFlyGameLandscape(); |
483 | } | 483 | } |
484 | } | 484 | } |
485 | 485 | ||
486 | bool SFCave :: checkFlyGameCollision() | 486 | bool SFCave :: checkFlyGameCollision() |
487 | { | 487 | { |
488 | if ( (user.y() + user.width()) >= mapBottom[11] ) | 488 | if ( (user.y() + user.width()) >= mapBottom[11] ) |
489 | return true; | 489 | return true; |
490 | 490 | ||
491 | return false; | 491 | return false; |
492 | } | 492 | } |
493 | 493 | ||
494 | void SFCave :: moveFlyGameLandscape() | 494 | void SFCave :: moveFlyGameLandscape() |
495 | { | 495 | { |
496 | offset++; | 496 | offset++; |
497 | 497 | ||
498 | if ( offset >= segSize ) | 498 | if ( offset >= segSize ) |
499 | { | 499 | { |
500 | offset = 0; | 500 | offset = 0; |
501 | for ( int i = 0 ; i < MAPSIZE-speed ; ++i ) | 501 | for ( int i = 0 ; i < MAPSIZE-speed ; ++i ) |
502 | mapBottom[i] = mapBottom[i+speed]; | 502 | mapBottom[i] = mapBottom[i+speed]; |
503 | 503 | ||
504 | for ( int i = speed ; i > 0 ; --i ) | 504 | for ( int i = speed ; i > 0 ; --i ) |
505 | setFlyPoint( MAPSIZE-i ); | 505 | setFlyPoint( MAPSIZE-i ); |
506 | } | 506 | } |
507 | } | 507 | } |
508 | 508 | ||
509 | void SFCave :: setFlyPoint( int point ) | 509 | void SFCave :: setFlyPoint( int point ) |
510 | { | 510 | { |
511 | static int fly_difficulty_levels[] = { 5, 10, 15 }; | 511 | static int fly_difficulty_levels[] = { 5, 10, 15 }; |
512 | if ( nextInt(100) >= 75 ) | 512 | if ( nextInt(100) >= 75 ) |
513 | dir *= -1; | 513 | dir *= -1; |
514 | 514 | ||
515 | int prevPoint = mapBottom[point-1]; | 515 | int prevPoint = mapBottom[point-1]; |
516 | 516 | ||
517 | int nextPoint = prevPoint + (dir * nextInt( fly_difficulty_levels[currentGameDifficulty] ) ); | 517 | int nextPoint = prevPoint + (dir * nextInt( fly_difficulty_levels[currentGameDifficulty] ) ); |
518 | 518 | ||
519 | if ( nextPoint > sHeight ) | 519 | if ( nextPoint > sHeight ) |
520 | { | 520 | { |
521 | nextPoint = sHeight; | 521 | nextPoint = sHeight; |
522 | dir *= -1; | 522 | dir *= -1; |
523 | } | 523 | } |
524 | else if ( nextPoint < maxHeight ) | 524 | else if ( nextPoint < maxHeight ) |
525 | { | 525 | { |
526 | nextPoint = maxHeight; | 526 | nextPoint = maxHeight; |
527 | dir *= 1; | 527 | dir *= 1; |
528 | } | 528 | } |
529 | 529 | ||
530 | mapBottom[point] = nextPoint; | 530 | mapBottom[point] = nextPoint; |
531 | } | 531 | } |
532 | 532 | ||
533 | bool SFCave :: checkCollision() | 533 | bool SFCave :: checkCollision() |
534 | { | 534 | { |
535 | if ( (user.y() + user.width()) >= mapBottom[11] || user.y() <= mapTop[11] ) | 535 | if ( (user.y() + user.width()) >= mapBottom[11] || user.y() <= mapTop[11] ) |
536 | return true; | 536 | return true; |
537 | 537 | ||
538 | for ( int i = 0 ; i < BLOCKSIZE ; ++i ) | 538 | for ( int i = 0 ; i < BLOCKSIZE ; ++i ) |
539 | { | 539 | { |
540 | if ( blocks[i].y() != -1 ) | 540 | if ( blocks[i].y() != -1 ) |
541 | { | 541 | { |
542 | if ( blocks[i].intersects( user ) ) | 542 | if ( blocks[i].intersects( user ) ) |
543 | return true; | 543 | return true; |
544 | } | 544 | } |
545 | } | 545 | } |
546 | return false; | 546 | return false; |
547 | } | 547 | } |
548 | 548 | ||
549 | void SFCave :: moveLandscape() | 549 | void SFCave :: moveLandscape() |
550 | { | 550 | { |
551 | offset++; | 551 | offset++; |
552 | 552 | ||
553 | if ( offset >= segSize ) | 553 | if ( offset >= segSize ) |
554 | { | 554 | { |
555 | offset = 0; | 555 | offset = 0; |
556 | for ( int i = 0 ; i < MAPSIZE-speed ; ++i ) | 556 | for ( int i = 0 ; i < MAPSIZE-speed ; ++i ) |
557 | { | 557 | { |
558 | mapTop[i] = mapTop[i+speed]; | 558 | mapTop[i] = mapTop[i+speed]; |
559 | mapBottom[i] = mapBottom[i+speed]; | 559 | mapBottom[i] = mapBottom[i+speed]; |
560 | } | 560 | } |
561 | 561 | ||
562 | for ( int i = speed ; i > 0 ; --i ) | 562 | for ( int i = speed ; i > 0 ; --i ) |
563 | setPoint( MAPSIZE-i ); | 563 | setPoint( MAPSIZE-i ); |
564 | } | 564 | } |
565 | 565 | ||
566 | for ( int i = 0 ; i < BLOCKSIZE ; ++i ) | 566 | for ( int i = 0 ; i < BLOCKSIZE ; ++i ) |
567 | { | 567 | { |
568 | if ( blocks[i].y() != -1 ) | 568 | if ( blocks[i].y() != -1 ) |
569 | { | 569 | { |
570 | blocks[i].moveBy( -speed, 0 ); | 570 | blocks[i].moveBy( -speed, 0 ); |
571 | if ( blocks[i].x() + blocks[i].width() < 0 ) | 571 | if ( blocks[i].x() + blocks[i].width() < 0 ) |
572 | blocks[i].setY( -1 ); | 572 | blocks[i].setY( -1 ); |
573 | } | 573 | } |
574 | } | 574 | } |
575 | } | 575 | } |
576 | 576 | ||
577 | void SFCave :: addBlock() | 577 | void SFCave :: addBlock() |
578 | { | 578 | { |
579 | for ( int i = 0 ; i < BLOCKSIZE ; ++i ) | 579 | for ( int i = 0 ; i < BLOCKSIZE ; ++i ) |
580 | { | 580 | { |
581 | if ( blocks[i].y() == -1 ) | 581 | if ( blocks[i].y() == -1 ) |
582 | { | 582 | { |
583 | int x = sWidth; | 583 | int x = sWidth; |
584 | 584 | ||
585 | int y = mapTop[50] + (int)(nextInt(mapBottom[50] - mapTop[50] - blockHeight)); | 585 | int y = mapTop[50] + (int)(nextInt(mapBottom[50] - mapTop[50] - blockHeight)); |
586 | 586 | ||
587 | blocks[i].setRect( x, y, blockWidth, blockHeight ); | 587 | blocks[i].setRect( x, y, blockWidth, blockHeight ); |
588 | 588 | ||
589 | break; | 589 | break; |
590 | } | 590 | } |
591 | } | 591 | } |
592 | } | 592 | } |
593 | 593 | ||
594 | void SFCave :: addGate() | 594 | void SFCave :: addGate() |
595 | { | 595 | { |
596 | for ( int i = 0 ; i < BLOCKSIZE ; ++i ) | 596 | for ( int i = 0 ; i < BLOCKSIZE ; ++i ) |
597 | { | 597 | { |
598 | if ( blocks[i].y() == -1 ) | 598 | if ( blocks[i].y() == -1 ) |
599 | { | 599 | { |
600 | int x1 = sWidth; | 600 | int x1 = sWidth; |
601 | int y1 = mapTop[50]; | 601 | int y1 = mapTop[50]; |
602 | int b1Height = nextInt(mapBottom[50] - mapTop[50] - gapHeight); | 602 | int b1Height = nextInt(mapBottom[50] - mapTop[50] - gapHeight); |
603 | 603 | ||
604 | // See if height between last gate and this one is too big | 604 | // See if height between last gate and this one is too big |
605 | if ( b1Height - 100 > lastGateBottomY ) | 605 | if ( b1Height - 100 > lastGateBottomY ) |
606 | b1Height -= 25; | 606 | b1Height -= 25; |
607 | else if ( b1Height + 100 < lastGateBottomY ) | 607 | else if ( b1Height + 100 < lastGateBottomY ) |
608 | b1Height += 25; | 608 | b1Height += 25; |
609 | lastGateBottomY = b1Height; | 609 | lastGateBottomY = b1Height; |
610 | 610 | ||
611 | 611 | ||
612 | int x2 = sWidth; | 612 | int x2 = sWidth; |
613 | int y2 = y1 + b1Height + gapHeight; | 613 | int y2 = y1 + b1Height + gapHeight; |
614 | int b2Height = mapBottom[50] - y2; | 614 | int b2Height = mapBottom[50] - y2; |
615 | 615 | ||
616 | 616 | ||
617 | blocks[i].setRect( x1, y1, blockWidth, b1Height ); | 617 | blocks[i].setRect( x1, y1, blockWidth, b1Height ); |
618 | blocks[i+1].setRect( x2, y2, blockWidth, b2Height ); | 618 | blocks[i+1].setRect( x2, y2, blockWidth, b2Height ); |
619 | 619 | ||
620 | break; | 620 | break; |
621 | } | 621 | } |
622 | } | 622 | } |
623 | } | 623 | } |
624 | 624 | ||
625 | void SFCave :: setPoint( int point ) | 625 | void SFCave :: setPoint( int point ) |
626 | { | 626 | { |
627 | if ( nextInt(100) >= 80 ) | 627 | if ( nextInt(100) >= 80 ) |
628 | dir *= -1; | 628 | dir *= -1; |
629 | 629 | ||
630 | mapTop[point] = mapTop[point-1] + (dir * nextInt( 5 ) ); | 630 | mapTop[point] = mapTop[point-1] + (dir * nextInt( 5 ) ); |
631 | if ( mapTop[point] < 0 ) | 631 | if ( mapTop[point] < 0 ) |
632 | { | 632 | { |
633 | mapTop[point] = 0; | 633 | mapTop[point] = 0; |
634 | dir *= -1; | 634 | dir *= -1; |
635 | } | 635 | } |
636 | else if ( mapTop[point] >= maxHeight ) | 636 | else if ( mapTop[point] >= maxHeight ) |
637 | { | 637 | { |
638 | mapTop[point] = maxHeight; | 638 | mapTop[point] = maxHeight; |
639 | dir *= -1; | 639 | dir *= -1; |
640 | } | 640 | } |
641 | 641 | ||
642 | // mapBottom[point] = sHeight - (maxHeight - mapBottom[point]); | 642 | // mapBottom[point] = sHeight - (maxHeight - mapBottom[point]); |
643 | mapBottom[point] = sHeight - (maxHeight - mapTop[point]); | 643 | mapBottom[point] = sHeight - (maxHeight - mapTop[point]); |
644 | } | 644 | } |
645 | 645 | ||
646 | void SFCave :: drawBoss() | 646 | void SFCave :: drawBoss() |
647 | { | 647 | { |
648 | offscreen->fill( Qt::black ); | 648 | offscreen->fill( Qt::black ); |
649 | 649 | ||
650 | bitBlt( this, 0, 0, offscreen, 0, 0, sWidth, sHeight, Qt::CopyROP, true ); | 650 | bitBlt( this, 0, 0, offscreen, 0, 0, sWidth, sHeight, Qt::CopyROP, true ); |
651 | } | 651 | } |
652 | 652 | ||
653 | void SFCave :: draw() | 653 | void SFCave :: draw() |
654 | { | 654 | { |
655 | //printf( "Paint\n" ); | 655 | //printf( "Paint\n" ); |
656 | offscreen->fill( Qt::black ); | 656 | offscreen->fill( Qt::black ); |
657 | 657 | ||
658 | QPainter p( offscreen ); | 658 | QPainter p( offscreen ); |
659 | QFontMetrics fm = p.fontMetrics(); | 659 | QFontMetrics fm = p.fontMetrics(); |
660 | p.setPen( Qt::white ); | 660 | p.setPen( Qt::white ); |
661 | 661 | ||
662 | for ( int i = 0 ; i < MAPSIZE -3; ++i ) | 662 | for ( int i = 0 ; i < MAPSIZE -3; ++i ) |
663 | { | 663 | { |
664 | // Only display top landscape if not running FLY_GAME | 664 | // Only display top landscape if not running FLY_GAME |
665 | if ( CURRENT_GAME_TYPE != FLY_GAME ) | 665 | if ( CURRENT_GAME_TYPE != FLY_GAME ) |
666 | p.drawLine( (i*segSize) - (offset*speed), mapTop[i], ((i+1)*segSize)-(offset*speed), mapTop[i+1] ); | 666 | p.drawLine( (i*segSize) - (offset*speed), mapTop[i], ((i+1)*segSize)-(offset*speed), mapTop[i+1] ); |
667 | 667 | ||
668 | p.drawLine( (i*segSize) - (offset*speed), mapBottom[i], ((i+1)*segSize)-(offset*speed), mapBottom[i+1] ); | 668 | p.drawLine( (i*segSize) - (offset*speed), mapBottom[i], ((i+1)*segSize)-(offset*speed), mapBottom[i+1] ); |
669 | 669 | ||
670 | if ( CURRENT_GAME_TYPE == FLY_GAME && showScoreZones ) | 670 | if ( CURRENT_GAME_TYPE == FLY_GAME && showScoreZones ) |
671 | { | 671 | { |
672 | p.setPen( Qt::blue ); | 672 | p.setPen( Qt::blue ); |
673 | for ( int j = 1 ; j < 10 && FLYSCORES( j, 0 ) != -1 ; ++j ) | 673 | for ( int j = 1 ; j < 10 && FLYSCORES( j, 0 ) != -1 ; ++j ) |
674 | { | 674 | { |
675 | if ( FLYSCORES( j, 2 ) < 0 ) | 675 | if ( FLYSCORES( j, 2 ) < 0 ) |
676 | p.setPen( Qt::red ); | 676 | p.setPen( Qt::red ); |
677 | 677 | ||
678 | p.drawLine( (i*segSize) - (offset*speed), mapBottom[i]-FLYSCORES( j, 0 ), ((i+1)*segSize)-(offset*speed), mapBottom[i+1]-FLYSCORES( j, 0 ) ); | 678 | p.drawLine( (i*segSize) - (offset*speed), mapBottom[i]-FLYSCORES( j, 0 ), ((i+1)*segSize)-(offset*speed), mapBottom[i+1]-FLYSCORES( j, 0 ) ); |
679 | } | 679 | } |
680 | 680 | ||
681 | p.setPen( Qt::white ); | 681 | p.setPen( Qt::white ); |
682 | } | 682 | } |
683 | } | 683 | } |
684 | 684 | ||
685 | // Uncomment this to show user segment (usful for checking collision boundary with landscape | 685 | // Uncomment this to show user segment (usful for checking collision boundary with landscape |
686 | // p.setPen( Qt::red ); | 686 | // p.setPen( Qt::red ); |
687 | // p.drawLine( (11*segSize) - (offset*speed), 0, ((11)*segSize)-(offset*speed), sHeight ); | 687 | // p.drawLine( (11*segSize) - (offset*speed), 0, ((11)*segSize)-(offset*speed), sHeight ); |
688 | // p.setPen( Qt::white ); | 688 | // p.setPen( Qt::white ); |
689 | 689 | ||
690 | // Draw user | 690 | // Draw user |
691 | p.drawRect( user ); | 691 | p.drawRect( user ); |
692 | 692 | ||
693 | // Draw trails | 693 | // Draw trails |
694 | for ( int i = 0 ; i < TRAILSIZE ; ++i ) | 694 | for ( int i = 0 ; i < TRAILSIZE ; ++i ) |
695 | if ( trail[i].x() >= 0 ) | 695 | if ( trail[i].x() >= 0 ) |
696 | { | 696 | { |
697 | if ( showEyeCandy ) | 697 | if ( showEyeCandy ) |
698 | p.setPen( Qt::white.light((int)(100.0-3*(user.x()/100.0)* (user.x()-trail[i].x())) ) ); | 698 | p.setPen( Qt::white.light((int)(100.0-3*(user.x()/100.0)* (user.x()-trail[i].x())) ) ); |
699 | p.drawRect( trail[i].x(), trail[i].y(), 2, 2 ); | 699 | p.drawRect( trail[i].x(), trail[i].y(), 2, 2 ); |
700 | } | 700 | } |
701 | 701 | ||
702 | p.setPen( Qt::white ); | 702 | p.setPen( Qt::white ); |
703 | // Draw blocks | 703 | // Draw blocks |
704 | for ( int i = 0 ; i < BLOCKSIZE ; ++i ) | 704 | for ( int i = 0 ; i < BLOCKSIZE ; ++i ) |
705 | if ( blocks[i].y() != -1 ) | 705 | if ( blocks[i].y() != -1 ) |
706 | { | 706 | { |
707 | p.fillRect( blocks[i], Qt::black ); | 707 | p.fillRect( blocks[i], Qt::black ); |
708 | p.drawRect( blocks[i] ); | 708 | p.drawRect( blocks[i] ); |
709 | } | 709 | } |
710 | 710 | ||
711 | // draw score | 711 | // draw score |
712 | QString s; | 712 | QString s; |
713 | s.sprintf( "score %06d high score %06d", score, highestScore[currentGameType][currentGameDifficulty] ); | 713 | s.sprintf( "score %06d high score %06d", score, highestScore[currentGameType][currentGameDifficulty] ); |
714 | p.drawText( 5, 10, s ); | 714 | p.drawText( 5, 10, s ); |
715 | 715 | ||
716 | 716 | ||
717 | if ( state == STATE_CRASHING || state == STATE_CRASHED ) | 717 | if ( state == STATE_CRASHING || state == STATE_CRASHED ) |
718 | { | 718 | { |
719 | // add next crash line | 719 | // add next crash line |
720 | 720 | ||
721 | if ( crashLineLength != -1 ) | 721 | if ( crashLineLength != -1 ) |
722 | { | 722 | { |
723 | for ( int i = 0 ; i < 36 ; ++i ) | 723 | for ( int i = 0 ; i < 36 ; ++i ) |
724 | { | 724 | { |
725 | int x = (int)(user.x() + (crashLineLength+nextInt(10)) * cos( (M_PI/180) * (10.0 * i) ) ); | 725 | int x = (int)(user.x() + (crashLineLength+nextInt(10)) * cos( (M_PI/180) * (10.0 * i) ) ); |
726 | int y = (int)(user.y() + (crashLineLength+nextInt(10)) * sin( (M_PI/180) * (10.0 * i) ) ); p.drawLine( user.x(), user.y(), x, y ); | 726 | int y = (int)(user.y() + (crashLineLength+nextInt(10)) * sin( (M_PI/180) * (10.0 * i) ) ); p.drawLine( user.x(), user.y(), x, y ); |
727 | } | 727 | } |
728 | } | 728 | } |
729 | 729 | ||
730 | if ( state == STATE_CRASHING && crashLineLength >= 15 ) //|| crashLineLength == -1) ) | 730 | if ( state == STATE_CRASHING && crashLineLength >= 15 ) //|| crashLineLength == -1) ) |
731 | state = STATE_CRASHED; | 731 | state = STATE_CRASHED; |
732 | 732 | ||
733 | if ( state == STATE_CRASHED ) | 733 | if ( state == STATE_CRASHED ) |
734 | { | 734 | { |
735 | QString text = "Press up or down to start"; | 735 | QString text = "Press up or down to start"; |
736 | p.drawText( (sWidth/2) - (fm.width( text )/2), 120, text ); | 736 | p.drawText( (sWidth/2) - (fm.width( text )/2), 120, text ); |
737 | 737 | ||
738 | text = "Press OK for menu"; | 738 | text = "Press OK for menu"; |
739 | p.drawText( (sWidth/2) - (fm.width( text )/2), 135, text ); | 739 | p.drawText( (sWidth/2) - (fm.width( text )/2), 135, text ); |
740 | /* | 740 | /* |
741 | text = "Press r to replay"; | 741 | text = "Press r to replay"; |
742 | p.drawText( (sWidth/2) - (fm.width( text )/2), 150, text ); | 742 | p.drawText( (sWidth/2) - (fm.width( text )/2), 150, text ); |
743 | 743 | ||
744 | text = "Press s to save the replay"; | 744 | text = "Press s to save the replay"; |
745 | p.drawText( (sWidth/2) - (fm.width( text )/2), 165, text ); | 745 | p.drawText( (sWidth/2) - (fm.width( text )/2), 165, text ); |
746 | 746 | ||
747 | text = "Press r to load a saved replay"; | 747 | text = "Press r to load a saved replay"; |
748 | p.drawText( (sWidth/2) - (fm.width( text )/2), 180, text ); | 748 | p.drawText( (sWidth/2) - (fm.width( text )/2), 180, text ); |
749 | */ | 749 | */ |
750 | } | 750 | } |
751 | else | 751 | else |
752 | crashLineLength ++; | 752 | crashLineLength ++; |
753 | } | 753 | } |
754 | 754 | ||
755 | p.end(); | 755 | p.end(); |
756 | bitBlt( this, 0, 0, offscreen, 0, 0, sWidth, sHeight, Qt::CopyROP, true ); | 756 | bitBlt( this, 0, 0, offscreen, 0, 0, sWidth, sHeight, Qt::CopyROP, true ); |
757 | //printf( "endpaint\n" ); | 757 | //printf( "endpaint\n" ); |
758 | } | 758 | } |
759 | 759 | ||
760 | void SFCave :: handleKeys() | 760 | void SFCave :: handleKeys() |
761 | { | 761 | { |
762 | // Find enpty trail and move others | 762 | // Find enpty trail and move others |
763 | bool done = false; | 763 | bool done = false; |
764 | for ( int i = 0 ; i < TRAILSIZE ; ++i ) | 764 | for ( int i = 0 ; i < TRAILSIZE ; ++i ) |
765 | { | 765 | { |
766 | if ( trail[i].x() < 0 ) | 766 | if ( trail[i].x() < 0 ) |
767 | { | 767 | { |
768 | if ( !done ) | 768 | if ( !done ) |
769 | { | 769 | { |
770 | trail[i].setX( user.x() - 5 ); | 770 | trail[i].setX( user.x() - 5 ); |
771 | trail[i].setY( user.y() ); | 771 | trail[i].setY( user.y() ); |
772 | done = true; | 772 | done = true; |
773 | } | 773 | } |
774 | } | 774 | } |
775 | else | 775 | else |
776 | { | 776 | { |
777 | trail[i].setX( trail[i].x() - (2) ); | 777 | trail[i].setX( trail[i].x() - (2) ); |
778 | } | 778 | } |
779 | } | 779 | } |
780 | 780 | ||
781 | if ( speed <= 3 ) | 781 | if ( speed <= 3 ) |
782 | { | 782 | { |
783 | if ( press ) | 783 | if ( press ) |
784 | thrust -= thrustUp; | 784 | thrust -= thrustUp; |
785 | else | 785 | else |
786 | thrust += noThrust; | 786 | thrust += noThrust; |
787 | 787 | ||
788 | if ( thrust > maxDownThrust ) | 788 | if ( thrust > maxDownThrust ) |
789 | thrust = maxDownThrust; | 789 | thrust = maxDownThrust; |
790 | else if ( thrust < maxUpThrust ) | 790 | else if ( thrust < maxUpThrust ) |
791 | thrust = maxUpThrust; | 791 | thrust = maxUpThrust; |
792 | } | 792 | } |
793 | else | 793 | else |
794 | { | 794 | { |
795 | if ( press ) | 795 | if ( press ) |
796 | thrust -= 0.5; | 796 | thrust -= 0.5; |
797 | else | 797 | else |
798 | thrust += 0.8; | 798 | thrust += 0.8; |
799 | 799 | ||
800 | if ( thrust > 5.0 ) | 800 | if ( thrust > 5.0 ) |
801 | thrust = 5.0; | 801 | thrust = 5.0; |
802 | else if ( thrust < -3.5 ) | 802 | else if ( thrust < -3.5 ) |
803 | thrust = -3.5; | 803 | thrust = -3.5; |
804 | } | 804 | } |
805 | user.moveBy( 0, (int)thrust ); | 805 | user.moveBy( 0, (int)thrust ); |
806 | } | 806 | } |
807 | 807 | ||
808 | void SFCave :: keyPressEvent( QKeyEvent *e ) | 808 | void SFCave :: keyPressEvent( QKeyEvent *e ) |
809 | { | 809 | { |
810 | if ( state == STATE_MENU ) | 810 | if ( state == STATE_MENU ) |
811 | handleMenuKeys( e ); | 811 | handleMenuKeys( e ); |
812 | else | 812 | else |
813 | { | 813 | { |
814 | switch( e->key() ) | 814 | switch( e->key() ) |
815 | { | 815 | { |
816 | case Qt::Key_Up: | 816 | case Qt::Key_Up: |
817 | case Qt::Key_F9: | 817 | case Qt::Key_F9: |
818 | case Qt::Key_Space: | 818 | case Qt::Key_Space: |
819 | if ( state == STATE_RUNNING ) | 819 | if ( state == STATE_RUNNING ) |
820 | { | 820 | { |
821 | if ( !replay && !press ) | 821 | if ( !replay && !press ) |
822 | { | 822 | { |
823 | press = true; | 823 | press = true; |
824 | replayList.append( new int( nrFrames ) ); | 824 | replayList.append( new int( nrFrames ) ); |
825 | } | 825 | } |
826 | } | 826 | } |
827 | else if ( state == STATE_CRASHED ) | 827 | else if ( state == STATE_CRASHED ) |
828 | { | 828 | { |
829 | if ( e->key() == Key_Up ) | 829 | if ( e->key() == Key_Up ) |
830 | state = STATE_NEWGAME; | 830 | state = STATE_NEWGAME; |
831 | } | 831 | } |
832 | 832 | ||
833 | break; | 833 | break; |
834 | case Qt::Key_M: | 834 | case Qt::Key_M: |
835 | case Qt::Key_Return: | 835 | case Qt::Key_Return: |
836 | case Qt::Key_Enter: | 836 | case Qt::Key_Enter: |
837 | if ( state == STATE_CRASHED ) | 837 | if ( state == STATE_CRASHED ) |
838 | { | 838 | { |
839 | state = STATE_MENU; | 839 | state = STATE_MENU; |
840 | currentMenuNr = 0; | 840 | currentMenuNr = 0; |
841 | currentMenuOption[currentMenuNr] = 0; | 841 | currentMenuOption[currentMenuNr] = 0; |
842 | } | 842 | } |
843 | break; | 843 | break; |
844 | 844 | ||
845 | case Qt::Key_Z: | 845 | case Qt::Key_Z: |
846 | showScoreZones = !showScoreZones; | 846 | showScoreZones = !showScoreZones; |
847 | break; | 847 | break; |
848 | 848 | ||
849 | default: | 849 | default: |
850 | e->ignore(); | 850 | e->ignore(); |
851 | break; | 851 | break; |
852 | } | 852 | } |
853 | } | 853 | } |
854 | } | 854 | } |
855 | 855 | ||
856 | void SFCave :: keyReleaseEvent( QKeyEvent *e ) | 856 | void SFCave :: keyReleaseEvent( QKeyEvent *e ) |
857 | { | 857 | { |
858 | if ( state == STATE_MENU ) | 858 | if ( state == STATE_MENU ) |
859 | { | 859 | { |
860 | } | 860 | } |
861 | else | 861 | else |
862 | { | 862 | { |
863 | switch( e->key() ) | 863 | switch( e->key() ) |
864 | { | 864 | { |
865 | case Qt::Key_F9: | 865 | case Qt::Key_F9: |
866 | case Qt::Key_Space: | 866 | case Qt::Key_Space: |
867 | case Qt::Key_Up: | 867 | case Qt::Key_Up: |
868 | if ( state == STATE_RUNNING ) | 868 | if ( state == STATE_RUNNING ) |
869 | { | 869 | { |
870 | if ( !replay && press ) | 870 | if ( !replay && press ) |
871 | { | 871 | { |
872 | press = false; | 872 | press = false; |
873 | replayList.append( new int( nrFrames ) ); | 873 | replayList.append( new int( nrFrames ) ); |
874 | } | 874 | } |
875 | } | 875 | } |
876 | break; | 876 | break; |
877 | 877 | ||
878 | case Qt::Key_E: | 878 | case Qt::Key_E: |
879 | showEyeCandy = !showEyeCandy; | 879 | showEyeCandy = !showEyeCandy; |
880 | break; | 880 | break; |
881 | 881 | ||
882 | case Qt::Key_R: | 882 | case Qt::Key_R: |
883 | if ( state == STATE_CRASHED ) | 883 | if ( state == STATE_CRASHED ) |
884 | state = STATE_REPLAY; | 884 | state = STATE_REPLAY; |
885 | break; | 885 | break; |
886 | 886 | ||
887 | case Qt::Key_Down: | 887 | case Qt::Key_Down: |
888 | if ( state == STATE_CRASHED ) | 888 | if ( state == STATE_CRASHED ) |
889 | state = STATE_NEWGAME; | 889 | state = STATE_NEWGAME; |
890 | break; | 890 | break; |
891 | 891 | ||
892 | case Qt::Key_S: | 892 | case Qt::Key_S: |
893 | if ( state == STATE_CRASHED ) | 893 | if ( state == STATE_CRASHED ) |
894 | saveReplay(); | 894 | saveReplay(); |
895 | break; | 895 | break; |
896 | 896 | ||
897 | case Qt::Key_L: | 897 | case Qt::Key_L: |
898 | if ( state == STATE_CRASHED ) | 898 | if ( state == STATE_CRASHED ) |
899 | loadReplay(); | 899 | loadReplay(); |
900 | break; | 900 | break; |
901 | default: | 901 | default: |
902 | e->ignore(); | 902 | e->ignore(); |
903 | break; | 903 | break; |
904 | } | 904 | } |
905 | } | 905 | } |
906 | 906 | ||
907 | } | 907 | } |
908 | 908 | ||
909 | 909 | ||
910 | void SFCave :: saveScore() | 910 | void SFCave :: saveScore() |
911 | { | 911 | { |
912 | #ifdef QWS | 912 | #ifdef QWS |
913 | Config cfg( "sfcave" ); | 913 | Config cfg( "sfcave" ); |
914 | cfg.setGroup( "settings" ); | 914 | cfg.setGroup( "settings" ); |
915 | QString key = "highScore_"; | 915 | QString key = "highScore_"; |
916 | 916 | ||
917 | cfg.writeEntry( key + gameTypes[currentGameType] + "_" + dificultyOption[currentGameDifficulty], highestScore[currentGameType][currentGameDifficulty] ); | 917 | cfg.writeEntry( key + gameTypes[currentGameType] + "_" + dificultyOption[currentGameDifficulty], highestScore[currentGameType][currentGameDifficulty] ); |
918 | key += CURRENT_GAME_TYPE; | 918 | key += CURRENT_GAME_TYPE; |
919 | cfg.writeEntry( key, highestScore[currentGameType] ); | 919 | cfg.writeEntry( key, highestScore[currentGameType] ); |
920 | #endif | 920 | #endif |
921 | } | 921 | } |
922 | 922 | ||
923 | void SFCave :: saveReplay() | 923 | void SFCave :: saveReplay() |
924 | { | 924 | { |
925 | FILE *out; | 925 | FILE *out; |
926 | out = fopen( QFile::encodeName(replayFile).data(), "w" ); | 926 | out = fopen( QFile::encodeName(replayFile).data(), "w" ); |
927 | if ( !out ) | 927 | if ( !out ) |
928 | { | 928 | { |
929 | printf( "Couldn't write to %s\n", QFile::encodeName(replayFile).data() ); | 929 | printf( "Couldn't write to %s\n", QFile::encodeName(replayFile).data() ); |
930 | return; | 930 | return; |
931 | } | 931 | } |
932 | 932 | ||
933 | // Build up string of values | 933 | // Build up string of values |
934 | // Format is:: <landscape seed> <game type> <difficulty> <framenr> <framenr>....... | 934 | // Format is:: <landscape seed> <game type> <difficulty> <framenr> <framenr>....... |
935 | QString val; | 935 | QString val; |
936 | val.sprintf( "%d %d %d ", currentSeed, currentGameType, currentGameDifficulty ); | 936 | val.sprintf( "%d %d %d ", currentSeed, currentGameType, currentGameDifficulty ); |
937 | 937 | ||
938 | QListIterator<int> it( replayList ); | 938 | QListIterator<int> it( replayList ); |
939 | while( it.current() ) | 939 | while( it.current() ) |
940 | { | 940 | { |
941 | QString tmp; | 941 | QString tmp; |
942 | tmp.sprintf( "%d ", (*it.current()) ); | 942 | tmp.sprintf( "%d ", (*it.current()) ); |
943 | val += tmp; | 943 | val += tmp; |
944 | 944 | ||
945 | ++it; | 945 | ++it; |
946 | } | 946 | } |
947 | val += "\n"; | 947 | val += "\n"; |
948 | 948 | ||
949 | QString line; | 949 | QString line; |
950 | line.sprintf( "%d\n", val.length() ); | 950 | line.sprintf( "%d\n", val.length() ); |
951 | fwrite( (const char *)line, 1, line.length(), out ); | 951 | fwrite( (const char *)line, 1, line.length(), out ); |
952 | 952 | ||
953 | fwrite( (const char *)val, 1, val.length(), out ); | 953 | fwrite( (const char *)val, 1, val.length(), out ); |
954 | 954 | ||
955 | fclose( out ); | 955 | fclose( out ); |
956 | 956 | ||
957 | printf( "Replay saved to %s\n", QFile::encodeName(replayFile).data() ); | 957 | printf( "Replay saved to %s\n", QFile::encodeName(replayFile).data() ); |
958 | 958 | ||
959 | } | 959 | } |
960 | 960 | ||
961 | void SFCave :: loadReplay() | 961 | void SFCave :: loadReplay() |
962 | { | 962 | { |
963 | FILE *in = fopen( QFile::encodeName(replayFile).data() , "r" ); | 963 | FILE *in = fopen( QFile::encodeName(replayFile).data() , "r" ); |
964 | 964 | ||
965 | if ( in == 0 ) | 965 | if ( in == 0 ) |
966 | { | 966 | { |
967 | printf( "Couldn't load replay file!\n" ); | 967 | printf( "Couldn't load replay file!\n" ); |
968 | return; | 968 | return; |
969 | } | 969 | } |
970 | 970 | ||
971 | // Read next line - contains the size of the options | 971 | // Read next line - contains the size of the options |
972 | char line[10+1]; | 972 | char line[10+1]; |
973 | fgets( line, 10, in ); | 973 | fgets( line, 10, in ); |
974 | 974 | ||
975 | int length = -1; | 975 | int length = -1; |
976 | sscanf( line, "%d", &length ); | 976 | sscanf( line, "%d", &length ); |
977 | char *data = new char[length+1]; | 977 | char *data = new char[length+1]; |
978 | 978 | ||
979 | fread( data, 1, length, in ); | 979 | fread( data, 1, length, in ); |
980 | // printf( "data - %s", data ); | 980 | // printf( "data - %s", data ); |
981 | 981 | ||
982 | QString sep = " "; | 982 | QString sep = " "; |
983 | QStringList list = QStringList::split( sep, QString( data ) ); | 983 | QStringList list = QStringList::split( sep, QString( data ) ); |
984 | 984 | ||
985 | // print it out | 985 | // print it out |
986 | QStringList::Iterator it = list.begin(); | 986 | QStringList::Iterator it = list.begin(); |
987 | currentSeed = (*it).toInt(); | 987 | currentSeed = (*it).toInt(); |
988 | ++it; | 988 | ++it; |
989 | currentGameType = (*it).toInt(); | 989 | currentGameType = (*it).toInt(); |
990 | ++it; | 990 | ++it; |
991 | currentGameDifficulty = (*it).toInt(); | 991 | currentGameDifficulty = (*it).toInt(); |
992 | ++it; | 992 | ++it; |
993 | 993 | ||
994 | replayList.clear(); | 994 | replayList.clear(); |
995 | for ( ; it != list.end(); ++it ) | 995 | for ( ; it != list.end(); ++it ) |
996 | { | 996 | { |
997 | int v = (*it).toInt(); | 997 | int v = (*it).toInt(); |
998 | replayList.append( new int( v ) ); | 998 | replayList.append( new int( v ) ); |
999 | } | 999 | } |
1000 | 1000 | ||
1001 | delete data; | 1001 | delete data; |
1002 | 1002 | ||
1003 | fclose( in ); | 1003 | fclose( in ); |
1004 | 1004 | ||
1005 | printf( "Replay loaded from %s\n", QFile::encodeName(replayFile).data() ); | 1005 | printf( "Replay loaded from %s\n", QFile::encodeName(replayFile).data() ); |
1006 | } | 1006 | } |
1007 | 1007 | ||
1008 | 1008 | ||
1009 | //--------------- MENU CODE --------------------- | 1009 | //--------------- MENU CODE --------------------- |
1010 | void SFCave :: handleMenuKeys( QKeyEvent *e ) | 1010 | void SFCave :: handleMenuKeys( QKeyEvent *e ) |
1011 | { | 1011 | { |
1012 | switch( e->key() ) | 1012 | switch( e->key() ) |
1013 | { | 1013 | { |
1014 | case Qt::Key_Down: | 1014 | case Qt::Key_Down: |
1015 | currentMenuOption[currentMenuNr] ++; | 1015 | currentMenuOption[currentMenuNr] ++; |
1016 | if ( menuOptions[currentMenuNr][currentMenuOption[currentMenuNr]] == "" ) | 1016 | if ( menuOptions[currentMenuNr][currentMenuOption[currentMenuNr]] == "" ) |
1017 | currentMenuOption[currentMenuNr] = 0; | 1017 | currentMenuOption[currentMenuNr] = 0; |
1018 | break; | 1018 | break; |
1019 | case Qt::Key_Up: | 1019 | case Qt::Key_Up: |
1020 | currentMenuOption[currentMenuNr] --; | 1020 | currentMenuOption[currentMenuNr] --; |
1021 | if ( currentMenuOption[currentMenuNr] < 0 ) | 1021 | if ( currentMenuOption[currentMenuNr] < 0 ) |
1022 | currentMenuOption[currentMenuNr] = nrMenuOptions[currentMenuNr]-1; | 1022 | currentMenuOption[currentMenuNr] = nrMenuOptions[currentMenuNr]-1; |
1023 | break; | 1023 | break; |
1024 | 1024 | ||
1025 | case Qt::Key_Left: | 1025 | case Qt::Key_Left: |
1026 | if ( currentMenuNr == MENU_OPTIONS_MENU ) | 1026 | if ( currentMenuNr == MENU_OPTIONS_MENU ) |
1027 | { | 1027 | { |
1028 | if ( currentMenuOption[currentMenuNr] == MENU_GAME_TYPE ) | 1028 | if ( currentMenuOption[currentMenuNr] == MENU_GAME_TYPE ) |
1029 | { | 1029 | { |
1030 | currentGameType --; | 1030 | currentGameType --; |
1031 | if ( currentGameType < 0 ) | 1031 | if ( currentGameType < 0 ) |
1032 | currentGameType = NR_GAME_TYPES - 1; | 1032 | currentGameType = NR_GAME_TYPES - 1; |
1033 | } | 1033 | } |
1034 | else if ( currentMenuOption[currentMenuNr] == MENU_GAME_DIFFICULTY ) | 1034 | else if ( currentMenuOption[currentMenuNr] == MENU_GAME_DIFFICULTY ) |
1035 | { | 1035 | { |
1036 | currentGameDifficulty --; | 1036 | currentGameDifficulty --; |
1037 | if ( currentGameDifficulty < 0 ) | 1037 | if ( currentGameDifficulty < 0 ) |
1038 | currentGameDifficulty = NR_GAME_DIFFICULTIES - 1; | 1038 | currentGameDifficulty = NR_GAME_DIFFICULTIES - 1; |
1039 | } | 1039 | } |
1040 | } | 1040 | } |
1041 | break; | 1041 | break; |
1042 | 1042 | ||
1043 | case Qt::Key_Right: | 1043 | case Qt::Key_Right: |
1044 | if ( currentMenuNr == MENU_OPTIONS_MENU ) | 1044 | if ( currentMenuNr == MENU_OPTIONS_MENU ) |
1045 | { | 1045 | { |
1046 | if ( currentMenuOption[currentMenuNr] == MENU_GAME_TYPE ) | 1046 | if ( currentMenuOption[currentMenuNr] == MENU_GAME_TYPE ) |
1047 | { | 1047 | { |
1048 | currentGameType ++; | 1048 | currentGameType ++; |
1049 | if ( currentGameType == NR_GAME_TYPES ) | 1049 | if ( currentGameType == NR_GAME_TYPES ) |
1050 | currentGameType = 0; | 1050 | currentGameType = 0; |
1051 | } | 1051 | } |
1052 | else if ( currentMenuOption[currentMenuNr] == MENU_GAME_DIFFICULTY ) | 1052 | else if ( currentMenuOption[currentMenuNr] == MENU_GAME_DIFFICULTY ) |
1053 | { | 1053 | { |
1054 | currentGameDifficulty ++; | 1054 | currentGameDifficulty ++; |
1055 | if ( currentGameDifficulty == NR_GAME_DIFFICULTIES ) | 1055 | if ( currentGameDifficulty == NR_GAME_DIFFICULTIES ) |
1056 | currentGameDifficulty = 0; | 1056 | currentGameDifficulty = 0; |
1057 | } | 1057 | } |
1058 | } | 1058 | } |
1059 | break; | 1059 | break; |
1060 | 1060 | ||
1061 | case Qt::Key_Space: | 1061 | case Qt::Key_Space: |
1062 | case Qt::Key_Return: | 1062 | case Qt::Key_Return: |
1063 | case Qt::Key_Enter: | 1063 | case Qt::Key_Enter: |
1064 | dealWithMenuSelection(); | 1064 | dealWithMenuSelection(); |
1065 | break; | 1065 | break; |
1066 | } | 1066 | } |
1067 | } | 1067 | } |
1068 | 1068 | ||
1069 | void SFCave :: displayMenu() | 1069 | void SFCave :: displayMenu() |
1070 | { | 1070 | { |
1071 | offscreen->fill( Qt::black ); | 1071 | offscreen->fill( Qt::black ); |
1072 | 1072 | ||
1073 | QPainter p( offscreen ); | 1073 | QPainter p( offscreen ); |
1074 | p.setPen( Qt::white ); | 1074 | p.setPen( Qt::white ); |
1075 | 1075 | ||
1076 | QFont f( "Helvetica", 16 ); | 1076 | QFont f( "Helvetica", 16 ); |
1077 | p.setFont( f ); | 1077 | p.setFont( f ); |
1078 | 1078 | ||
1079 | QFontMetrics fm = p.fontMetrics(); | 1079 | QFontMetrics fm = p.fontMetrics(); |
1080 | 1080 | ||
1081 | QString text = "SFCave"; | 1081 | QString text = "SFCave"; |
1082 | p.drawText( (sWidth/2) - (fm.width( text )/2), 60, text ); | 1082 | p.drawText( (sWidth/2) - (fm.width( text )/2), 60, text ); |
1083 | 1083 | ||
1084 | text = "Written by Andy Qua"; | 1084 | text = "Written by Andy Qua"; |
1085 | p.drawText( (sWidth/2) - (fm.width( text )/2), 85, text ); | 1085 | p.drawText( (sWidth/2) - (fm.width( text )/2), 85, text ); |
1086 | 1086 | ||
1087 | // Draw options | 1087 | // Draw options |
1088 | int pos = 140; | 1088 | int pos = 140; |
1089 | for ( int i = 0 ; menuOptions[currentMenuNr][i] != "" ; ++i, pos += 25 ) | 1089 | for ( int i = 0 ; menuOptions[currentMenuNr][i] != "" ; ++i, pos += 25 ) |
1090 | { | 1090 | { |
1091 | if ( currentMenuOption[currentMenuNr] == i ) | 1091 | if ( currentMenuOption[currentMenuNr] == i ) |
1092 | p.setPen( Qt::yellow ); | 1092 | p.setPen( Qt::yellow ); |
1093 | else | 1093 | else |
1094 | p.setPen( Qt::white ); | 1094 | p.setPen( Qt::white ); |
1095 | 1095 | ||
1096 | QString text; | 1096 | QString text; |
1097 | if ( menuOptions[currentMenuNr][i].find( "%s" ) != -1 ) | 1097 | if ( menuOptions[currentMenuNr][i].find( "%s" ) != -1 ) |
1098 | { | 1098 | { |
1099 | QString val; | 1099 | QString val; |
1100 | if ( i == MENU_GAME_TYPE ) | 1100 | if ( i == MENU_GAME_TYPE ) |
1101 | val = gameTypes[currentGameType]; | 1101 | val = gameTypes[currentGameType]; |
1102 | else | 1102 | else |
1103 | val = dificultyOption[currentGameDifficulty]; | 1103 | val = dificultyOption[currentGameDifficulty]; |
1104 | 1104 | ||
1105 | text.sprintf( (const char *)menuOptions[currentMenuNr][i], (const char *)val ); | 1105 | text.sprintf( (const char *)menuOptions[currentMenuNr][i], (const char *)val ); |
1106 | } | 1106 | } |
1107 | else | 1107 | else |
1108 | text = menuOptions[currentMenuNr][i]; | 1108 | text = menuOptions[currentMenuNr][i]; |
1109 | 1109 | ||
1110 | p.drawText( (sWidth/2) - (fm.width( text )/2), pos, text ); | 1110 | p.drawText( (sWidth/2) - (fm.width( text )/2), pos, text ); |
1111 | } | 1111 | } |
1112 | 1112 | ||
1113 | p.end(); | 1113 | p.end(); |
1114 | bitBlt( this, 0, 0, offscreen, 0, 0, sWidth, sHeight, Qt::CopyROP, true ); | 1114 | bitBlt( this, 0, 0, offscreen, 0, 0, sWidth, sHeight, Qt::CopyROP, true ); |
1115 | } | 1115 | } |
1116 | 1116 | ||
1117 | void SFCave :: dealWithMenuSelection() | 1117 | void SFCave :: dealWithMenuSelection() |
1118 | { | 1118 | { |
1119 | switch( currentMenuNr ) | 1119 | switch( currentMenuNr ) |
1120 | { | 1120 | { |
1121 | case MENU_MAIN_MENU: | 1121 | case MENU_MAIN_MENU: |
1122 | { | 1122 | { |
1123 | switch( currentMenuOption[currentMenuNr] ) | 1123 | switch( currentMenuOption[currentMenuNr] ) |
1124 | { | 1124 | { |
1125 | case MENU_START_GAME: | 1125 | case MENU_START_GAME: |
1126 | state = STATE_NEWGAME; | 1126 | state = STATE_NEWGAME; |
1127 | break; | 1127 | break; |
1128 | 1128 | ||
1129 | case MENU_REPLAY: | 1129 | case MENU_REPLAY: |
1130 | currentMenuNr = MENU_REPLAY_MENU; | 1130 | currentMenuNr = MENU_REPLAY_MENU; |
1131 | currentMenuOption[currentMenuNr] = 0; | 1131 | currentMenuOption[currentMenuNr] = 0; |
1132 | break; | 1132 | break; |
1133 | 1133 | ||
1134 | case MENU_OPTIONS: | 1134 | case MENU_OPTIONS: |
1135 | currentMenuNr = MENU_OPTIONS_MENU; | 1135 | currentMenuNr = MENU_OPTIONS_MENU; |
1136 | currentMenuOption[currentMenuNr] = 0; | 1136 | currentMenuOption[currentMenuNr] = 0; |
1137 | break; | 1137 | break; |
1138 | 1138 | ||
1139 | case MENU_HELP: | 1139 | case MENU_HELP: |
1140 | { | 1140 | { |
1141 | // Display Help Menu | 1141 | // Display Help Menu |
1142 | HelpWindow *dlg = new HelpWindow( this ); | 1142 | HelpWindow *win = new HelpWindow( ); |
1143 | dlg->exec(); | 1143 | QPEApplication::showWidget( win ); |
1144 | delete dlg; | ||
1145 | break; | 1144 | break; |
1146 | } | 1145 | } |
1147 | 1146 | ||
1148 | case MENU_QUIT: | 1147 | case MENU_QUIT: |
1149 | QApplication::exit(); | 1148 | QApplication::exit(); |
1150 | break; | 1149 | break; |
1151 | } | 1150 | } |
1152 | 1151 | ||
1153 | break; | 1152 | break; |
1154 | } | 1153 | } |
1155 | 1154 | ||
1156 | case MENU_OPTIONS_MENU: | 1155 | case MENU_OPTIONS_MENU: |
1157 | { | 1156 | { |
1158 | switch( currentMenuOption[currentMenuNr] ) | 1157 | switch( currentMenuOption[currentMenuNr] ) |
1159 | { | 1158 | { |
1160 | case MENU_GAME_TYPE: | 1159 | case MENU_GAME_TYPE: |
1161 | break; | 1160 | break; |
1162 | 1161 | ||
1163 | case MENU_GAME_DIFFICULTY: | 1162 | case MENU_GAME_DIFFICULTY: |
1164 | break; | 1163 | break; |
1165 | 1164 | ||
1166 | case MENU_CLEAR_HIGHSCORES: | 1165 | case MENU_CLEAR_HIGHSCORES: |
1167 | for ( int i = 0 ; i < 3 ; ++i ) | 1166 | for ( int i = 0 ; i < 3 ; ++i ) |
1168 | highestScore[currentGameType][i] = 0; | 1167 | highestScore[currentGameType][i] = 0; |
1169 | break; | 1168 | break; |
1170 | 1169 | ||
1171 | case MENU_BACK: | 1170 | case MENU_BACK: |
1172 | currentMenuNr = MENU_MAIN_MENU; | 1171 | currentMenuNr = MENU_MAIN_MENU; |
1173 | 1172 | ||
1174 | #ifdef QWS | 1173 | #ifdef QWS |
1175 | Config cfg( "sfcave" ); | 1174 | Config cfg( "sfcave" ); |
1176 | cfg.setGroup( "settings" ); | 1175 | cfg.setGroup( "settings" ); |
1177 | cfg.writeEntry( "difficulty", currentGameDifficulty ); | 1176 | cfg.writeEntry( "difficulty", currentGameDifficulty ); |
1178 | cfg.writeEntry( "gameType", currentGameType ); | 1177 | cfg.writeEntry( "gameType", currentGameType ); |
1179 | #endif | 1178 | #endif |
1180 | break; | 1179 | break; |
1181 | } | 1180 | } |
1182 | 1181 | ||
1183 | break; | 1182 | break; |
1184 | } | 1183 | } |
1185 | 1184 | ||
1186 | case MENU_REPLAY_MENU: | 1185 | case MENU_REPLAY_MENU: |
1187 | { | 1186 | { |
1188 | switch( currentMenuOption[currentMenuNr] ) | 1187 | switch( currentMenuOption[currentMenuNr] ) |
1189 | { | 1188 | { |
1190 | case MENU_REPLAY_START: | 1189 | case MENU_REPLAY_START: |
1191 | if ( currentSeed != 0 ) | 1190 | if ( currentSeed != 0 ) |
1192 | state = STATE_REPLAY; | 1191 | state = STATE_REPLAY; |
1193 | // Display No Replay | 1192 | // Display No Replay |
1194 | break; | 1193 | break; |
1195 | 1194 | ||
1196 | case MENU_REPLAY_LOAD: | 1195 | case MENU_REPLAY_LOAD: |
1197 | loadReplay(); | 1196 | loadReplay(); |
1198 | break; | 1197 | break; |
1199 | 1198 | ||
1200 | case MENU_REPLAY_SAVE: | 1199 | case MENU_REPLAY_SAVE: |
1201 | saveReplay(); | 1200 | saveReplay(); |
1202 | break; | 1201 | break; |
1203 | 1202 | ||
1204 | case MENU_REPLAY_BACK: | 1203 | case MENU_REPLAY_BACK: |
1205 | currentMenuNr = MENU_MAIN_MENU; | 1204 | currentMenuNr = MENU_MAIN_MENU; |
1206 | break; | 1205 | break; |
1207 | 1206 | ||
1208 | } | 1207 | } |
1209 | } | 1208 | } |
1210 | } | 1209 | } |
1211 | } | 1210 | } |
1212 | 1211 | ||