author | andyq <andyq> | 2003-01-21 20:37:00 (UTC) |
---|---|---|
committer | andyq <andyq> | 2003-01-21 20:37:00 (UTC) |
commit | 0a6563fcc2f49857c581d9def24407a3a4ef526c (patch) (side-by-side diff) | |
tree | f1b82a4bd7582ef2cb722cffb87eecff1e1f96e6 /noncore/games/sfcave-sdl/game.cpp | |
parent | 50b5915b48fc5cbacf23e4d2b75d7a266f141a4a (diff) | |
download | opie-0a6563fcc2f49857c581d9def24407a3a4ef526c.zip opie-0a6563fcc2f49857c581d9def24407a3a4ef526c.tar.gz opie-0a6563fcc2f49857c581d9def24407a3a4ef526c.tar.bz2 |
Clean up of code - fixed memory leaks (most of them) and added new custom config menu
Diffstat (limited to 'noncore/games/sfcave-sdl/game.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/games/sfcave-sdl/game.cpp | 50 |
1 files changed, 23 insertions, 27 deletions
diff --git a/noncore/games/sfcave-sdl/game.cpp b/noncore/games/sfcave-sdl/game.cpp index a644696..e41e510 100644 --- a/noncore/games/sfcave-sdl/game.cpp +++ b/noncore/games/sfcave-sdl/game.cpp @@ -55,5 +55,5 @@ void Game :: init() replayList.clear(); } - + score = 0; nrFrames = 0; @@ -77,7 +77,4 @@ void Game :: handleKeys( SDL_KeyboardEvent &key ) replayList.push_back( nrFrames ); press = true; - -// if ( thrustChannel == -1 && parent->getState() == STATE_PLAYING ) -// thrustChannel = SoundHandler :: playSound( SND_THRUST, -1, -1, false ); } else @@ -87,9 +84,4 @@ void Game :: handleKeys( SDL_KeyboardEvent &key ) press = false; - if ( thrustChannel != -1 ) - { -// SoundHandler :: stopSound( thrustChannel, true, 300 ); -// thrustChannel = -1; - } } } @@ -98,7 +90,7 @@ void Game :: handleKeys( SDL_KeyboardEvent &key ) -QString Game :: getGameDifficultyText() +string Game :: getGameDifficultyText() { - QString ret; + string ret; if ( difficulty == MENU_DIFFICULTY_EASY ) @@ -108,4 +100,6 @@ QString Game :: getGameDifficultyText() else if ( difficulty == MENU_DIFFICULTY_HARD ) ret = "Hard"; + else if ( difficulty == MENU_DIFFICULTY_CUSTOM ) + ret = "Custom"; return ret; @@ -120,4 +114,14 @@ void Game :: setDifficulty( string diff ) else if ( diff == "Hard" ) difficulty = MENU_DIFFICULTY_HARD; + else if ( diff == "Custom" ) + difficulty = MENU_DIFFICULTY_CUSTOM; + + init(); +} + +void Game :: setDifficulty( int diff ) +{ + difficulty = diff; + init(); } @@ -132,5 +136,5 @@ void Game :: update( int state ) if ( state == STATE_PLAYING ) { - if ( replay ) + if ( replay ) { while( replayIt != replayList.end() && (*replayIt) == nrFrames-1 ) @@ -167,12 +171,11 @@ void Game :: draw( SDL_Surface *screen ) { char tmp[100]; - QString scoreText; + string scoreText; sprintf( tmp, "Score: %06ld High Score: %06ld", score, highScore ); -// printf( "%s\n", (const char *)scoreText ); FontHandler::draw( screen, FONT_WHITE_TEXT, tmp, 3, 10 ); if ( parent->getState() == STATE_CRASHED ) { - QString crashText; + string crashText; crashText = "Game Over"; int x = (240 - FontHandler::TextWidth( FONT_WHITE_TEXT, (const char *)crashText.c_str() )) / 2; @@ -224,5 +227,5 @@ void Game :: setSeed( int seed ) } -void Game :: saveReplay( QString file ) +void Game :: saveReplay( string file ) { FILE *out; @@ -237,5 +240,5 @@ void Game :: saveReplay( QString file ) // Build up string of values // Format is:: <landscape seed> <game type> <difficulty> <framenr> <framenr>....... - QString val; + string val; char tmp[20]; sprintf( tmp, "%d %d ", currentSeed, difficulty ); @@ -252,5 +255,5 @@ void Game :: saveReplay( QString file ) val += "\n"; - QString line; + string line; sprintf( tmp, "%d\n", val.length() ); line = tmp; @@ -260,10 +263,7 @@ void Game :: saveReplay( QString file ) fclose( out ); - - printf( "Replay saved to %s\n", (const char *)file.c_str() ); - } -void Game :: loadReplay( QString file ) +void Game :: loadReplay( string file ) { @@ -286,7 +286,6 @@ void Game :: loadReplay( QString file ) fread( data, 1, length, in ); -// printf( "data - %s", data ); - QString sep = " "; + string sep = " "; StringTokenizer st( data, sep ); @@ -309,7 +308,4 @@ void Game :: loadReplay( QString file ) fclose( in ); - - printf( "Replay loaded from %s\n", (const char *)file.c_str() ); - } |