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