summaryrefslogtreecommitdiff
authorandyq <andyq>2002-12-13 15:04:03 (UTC)
committer andyq <andyq>2002-12-13 15:04:03 (UTC)
commit67fa6ca335f261cf60fcf1477514f4cf108d6122 (patch) (unidiff)
treeeecf0eb133b1f8f29f0748f00c2f570f572c0dea
parent28a78f938ae995fbc29f76afa84b1bee62178a79 (diff)
downloadopie-67fa6ca335f261cf60fcf1477514f4cf108d6122.zip
opie-67fa6ca335f261cf60fcf1477514f4cf108d6122.tar.gz
opie-67fa6ca335f261cf60fcf1477514f4cf108d6122.tar.bz2
Upped the version
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/games/sfcave/sfcave.cpp2
1 files changed, 1 insertions, 1 deletions
diff --git a/noncore/games/sfcave/sfcave.cpp b/noncore/games/sfcave/sfcave.cpp
index 0160d34..929dc41 100644
--- a/noncore/games/sfcave/sfcave.cpp
+++ b/noncore/games/sfcave/sfcave.cpp
@@ -1,273 +1,273 @@
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.10 by AndyQ" 17#define CAPTION "SFCave 1.11 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
77QString SFCave::dificultyOption[] = { EASY, NORMAL, HARD }; 77QString SFCave::dificultyOption[] = { EASY, NORMAL, HARD };
78QString SFCave::gameTypes[] = { SFCAVE_GAME, GATES_GAME, FLY_GAME }; 78QString SFCave::gameTypes[] = { SFCAVE_GAME, GATES_GAME, FLY_GAME };
79 79
80QString SFCave::menuOptions[NR_MENUS][MAX_MENU_OPTIONS] = { { "Start Game", "Replays", "Options", "Help", "Quit", "", "", "" }, 80QString 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
84int SFCave::nrMenuOptions[NR_MENUS] = { 5, 4, 4 }; 84int SFCave::nrMenuOptions[NR_MENUS] = { 5, 4, 4 };
85int SFCave ::currentMenuOption[NR_MENUS] = { 0, 0, 0 }; 85int 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
91double SFCave::UpThrustVals[3][3] = {{ 0.6, 0.6, 0.6 }, // SFCave 91double 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
95double SFCave::DownThrustVals[3][3] = {{ 0.8, 0.8, 0.8 }, // SFCave 95double 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
99double SFCave::MaxUpThrustVals[3][3] = {{ -3.5, -3.5, -3.5 }, // SFCave 99double 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
103double SFCave::MaxDownThrustVals[3][3] = {{ 4.0, 4.0, 4.0 }, // SFCave 103double 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
107int SFCave::initialGateGaps[] = { 75, 50, 25 }; 107int SFCave::initialGateGaps[] = { 75, 50, 25 };
108 108
109 109
110bool movel; 110bool movel;
111 111
112 112
113int main( int argc, char *argv[] ) 113int main( int argc, char *argv[] )
114{ 114{
115 movel = true; 115 movel = true;
116#ifdef QWS 116#ifdef QWS
117 QPEApplication a( argc, argv ); 117 QPEApplication a( argc, argv );
118#else 118#else
119 QApplication a( argc, argv ); 119 QApplication a( argc, argv );
120#endif 120#endif
121 121
122 int speed = 3; 122 int speed = 3;
123 for ( int i = 0 ; i < argc ; ++i ) 123 for ( int i = 0 ; i < argc ; ++i )
124 { 124 {
125 if ( strcmp( argv[i], "-s" ) == 0 ) 125 if ( strcmp( argv[i], "-s" ) == 0 )
126 { 126 {
127 if ( i+1 < argc ) 127 if ( i+1 < argc )
128 speed = atoi( argv[i+1] ); 128 speed = atoi( argv[i+1] );
129 } 129 }
130 } 130 }
131 131
132 SFCave app( speed ); 132 SFCave app( speed );
133 a.setMainWidget( &app ); 133 a.setMainWidget( &app );
134 app.show(); 134 app.show();
135 app.start(); 135 app.start();
136 a.exec(); 136 a.exec();
137} 137}
138 138
139SFCave :: SFCave( int spd, QWidget *w, char *name ) 139SFCave :: SFCave( int spd, QWidget *w, char *name )
140 : QMainWindow( w, name ) 140 : QMainWindow( w, name )
141 141
142{ 142{
143 replayIt = 0; 143 replayIt = 0;
144#ifdef QWS 144#ifdef QWS
145 showMaximized(); 145 showMaximized();
146#else 146#else
147 resize( 240, 284 ); 147 resize( 240, 284 );
148#endif 148#endif
149 149
150 replayFile = QDir::home().path(); 150 replayFile = QDir::home().path();
151 replayFile += "/sfcave.replay"; 151 replayFile += "/sfcave.replay";
152 printf( "%s\n", (const char *)replayFile ); 152 printf( "%s\n", (const char *)replayFile );
153 153
154 sWidth = width(); 154 sWidth = width();
155 sHeight = height(); 155 sHeight = height();
156 segSize = sWidth/(MAPSIZE-1)+1; 156 segSize = sWidth/(MAPSIZE-1)+1;
157 157
158 currentMenuNr = 0; 158 currentMenuNr = 0;
159 currentGameType = 0; 159 currentGameType = 0;
160 currentGameDifficulty = 0; 160 currentGameDifficulty = 0;
161 161
162 setCaption( CAPTION ); 162 setCaption( CAPTION );
163 showScoreZones = false; 163 showScoreZones = false;
164 164
165#ifdef QWS 165#ifdef QWS
166 Config cfg( "sfcave" ); 166 Config cfg( "sfcave" );
167 cfg.setGroup( "settings" ); 167 cfg.setGroup( "settings" );
168 QString key = "highScore_"; 168 QString key = "highScore_";
169 169
170 for ( int i = 0 ; i < 3 ; ++i ) 170 for ( int i = 0 ; i < 3 ; ++i )
171 { 171 {
172 for ( int j = 0 ; j < 3 ; ++j ) 172 for ( int j = 0 ; j < 3 ; ++j )
173 highestScore[i][j] = cfg.readNumEntry( key + gameTypes[i] + "_" + dificultyOption[j], 0 ); 173 highestScore[i][j] = cfg.readNumEntry( key + gameTypes[i] + "_" + dificultyOption[j], 0 );
174 } 174 }
175 175
176 currentGameType = cfg.readNumEntry( "gameType", 0 ); 176 currentGameType = cfg.readNumEntry( "gameType", 0 );
177 currentGameDifficulty = cfg.readNumEntry( "difficulty", 0 ); 177 currentGameDifficulty = cfg.readNumEntry( "difficulty", 0 );
178#endif 178#endif
179 speed = spd; // Change to 2 for PC 179 speed = spd; // Change to 2 for PC
180 press = false; 180 press = false;
181 181
182 offscreen = new QPixmap( sWidth, sHeight ); 182 offscreen = new QPixmap( sWidth, sHeight );
183 offscreen->fill( Qt::black ); 183 offscreen->fill( Qt::black );
184 184
185// setUp(); 185// setUp();
186 crashLineLength = -1; 186 crashLineLength = -1;
187 state = STATE_MENU; 187 state = STATE_MENU;
188 prevState = STATE_MENU; 188 prevState = STATE_MENU;
189 189
190 gameTimer = new QTimer( this, "game timer" ); 190 gameTimer = new QTimer( this, "game timer" );
191 connect( gameTimer, SIGNAL( timeout() ), 191 connect( gameTimer, SIGNAL( timeout() ),
192 this, SLOT( run() ) ); 192 this, SLOT( run() ) );
193} 193}
194 194
195SFCave :: ~SFCave() 195SFCave :: ~SFCave()
196{ 196{
197} 197}
198 198
199void SFCave :: start() 199void SFCave :: start()
200{ 200{
201 gameTimer->start( 10 ); 201 gameTimer->start( 10 );
202 202
203} 203}
204 204
205void SFCave :: setSeed( int seed ) 205void SFCave :: setSeed( int seed )
206{ 206{
207 if ( seed == -1 ) 207 if ( seed == -1 )
208 currentSeed = ((unsigned long) time((time_t *) NULL)); 208 currentSeed = ((unsigned long) time((time_t *) NULL));
209 else 209 else
210 currentSeed = seed; 210 currentSeed = seed;
211 PutSeed( currentSeed ); 211 PutSeed( currentSeed );
212} 212}
213 213
214int SFCave :: nextInt( int range ) 214int SFCave :: nextInt( int range )
215{ 215{
216 int val = (int)(Random( ) * range); 216 int val = (int)(Random( ) * range);
217 217
218 return val; 218 return val;
219 219
220} 220}
221 221
222void SFCave :: setUp() 222void SFCave :: setUp()
223{ 223{
224 score = 0; 224 score = 0;
225 offset = 0; 225 offset = 0;
226 nrFrames = 0; 226 nrFrames = 0;
227 dir = 1; 227 dir = 1;
228 thrust = 0; 228 thrust = 0;
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 else if ( CURRENT_GAME_TYPE == GATES_GAME ) 237 else if ( CURRENT_GAME_TYPE == GATES_GAME )
238 { 238 {
239 thrustUp = UpThrustVals[GATES_GAME_TYPE][currentGameDifficulty];; 239 thrustUp = UpThrustVals[GATES_GAME_TYPE][currentGameDifficulty];;
240 noThrust = DownThrustVals[GATES_GAME_TYPE][currentGameDifficulty];; 240 noThrust = DownThrustVals[GATES_GAME_TYPE][currentGameDifficulty];;
241 maxUpThrust = MaxUpThrustVals[GATES_GAME_TYPE][currentGameDifficulty];; 241 maxUpThrust = MaxUpThrustVals[GATES_GAME_TYPE][currentGameDifficulty];;
242 maxDownThrust = MaxDownThrustVals[GATES_GAME_TYPE][currentGameDifficulty];; 242 maxDownThrust = MaxDownThrustVals[GATES_GAME_TYPE][currentGameDifficulty];;
243 } 243 }
244 else 244 else
245 { 245 {
246 thrustUp = UpThrustVals[FLY_GAME_TYPE][currentGameDifficulty]; 246 thrustUp = UpThrustVals[FLY_GAME_TYPE][currentGameDifficulty];
247 noThrust = DownThrustVals[FLY_GAME_TYPE][currentGameDifficulty]; 247 noThrust = DownThrustVals[FLY_GAME_TYPE][currentGameDifficulty];
248 maxUpThrust = MaxUpThrustVals[FLY_GAME_TYPE][currentGameDifficulty]; 248 maxUpThrust = MaxUpThrustVals[FLY_GAME_TYPE][currentGameDifficulty];
249 maxDownThrust = MaxDownThrustVals[FLY_GAME_TYPE][currentGameDifficulty]; 249 maxDownThrust = MaxDownThrustVals[FLY_GAME_TYPE][currentGameDifficulty];
250 } 250 }
251 251
252 crashLineLength = 0; 252 crashLineLength = 0;
253 lastGateBottomY = 0; 253 lastGateBottomY = 0;
254 254
255 user.setRect( 50, sWidth/2, 4, 4 ); 255 user.setRect( 50, sWidth/2, 4, 4 );
256 256
257 blockWidth = 20; 257 blockWidth = 20;
258 blockHeight = 70; 258 blockHeight = 70;
259 gapHeight = initialGateGaps[currentGameDifficulty]; 259 gapHeight = initialGateGaps[currentGameDifficulty];
260 gateDistance = 75; 260 gateDistance = 75;
261 nextGate = nextInt( 50 ) + gateDistance; 261 nextGate = nextInt( 50 ) + gateDistance;
262 262
263 for ( int i = 0 ; i < TRAILSIZE ; ++i ) 263 for ( int i = 0 ; i < TRAILSIZE ; ++i )
264 { 264 {
265 trail[i].setX( -1 ); 265 trail[i].setX( -1 );
266 trail[i].setY( 0 ); 266 trail[i].setY( 0 );
267 } 267 }
268 268
269 if ( CURRENT_GAME_TYPE != FLY_GAME ) 269 if ( CURRENT_GAME_TYPE != FLY_GAME )
270 { 270 {
271 maxHeight = 50; 271 maxHeight = 50;
272 272
273 mapTop[0] = (int)(nextInt(50)) + 5; 273 mapTop[0] = (int)(nextInt(50)) + 5;