summaryrefslogtreecommitdiff
path: root/noncore/games/sfcave-sdl/game.cpp
authorandyq <andyq>2003-01-21 20:37:00 (UTC)
committer andyq <andyq>2003-01-21 20:37:00 (UTC)
commit0a6563fcc2f49857c581d9def24407a3a4ef526c (patch) (side-by-side diff)
treef1b82a4bd7582ef2cb722cffb87eecff1e1f96e6 /noncore/games/sfcave-sdl/game.cpp
parent50b5915b48fc5cbacf23e4d2b75d7a266f141a4a (diff)
downloadopie-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.cpp50
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
@@ -56,3 +56,3 @@ void Game :: init()
}
-
+
score = 0;
@@ -78,5 +78,2 @@ void Game :: handleKeys( SDL_KeyboardEvent &key )
press = true;
-
-// if ( thrustChannel == -1 && parent->getState() == STATE_PLAYING )
-// thrustChannel = SoundHandler :: playSound( SND_THRUST, -1, -1, false );
}
@@ -88,7 +85,2 @@ void Game :: handleKeys( SDL_KeyboardEvent &key )
- if ( thrustChannel != -1 )
- {
-// SoundHandler :: stopSound( thrustChannel, true, 300 );
-// thrustChannel = -1;
- }
}
@@ -99,5 +91,5 @@ void Game :: handleKeys( SDL_KeyboardEvent &key )
-QString Game :: getGameDifficultyText()
+string Game :: getGameDifficultyText()
{
- QString ret;
+ string ret;
@@ -109,2 +101,4 @@ QString Game :: getGameDifficultyText()
ret = "Hard";
+ else if ( difficulty == MENU_DIFFICULTY_CUSTOM )
+ ret = "Custom";
@@ -121,2 +115,12 @@ void Game :: setDifficulty( string diff )
difficulty = MENU_DIFFICULTY_HARD;
+ else if ( diff == "Custom" )
+ difficulty = MENU_DIFFICULTY_CUSTOM;
+
+ init();
+}
+
+void Game :: setDifficulty( int diff )
+{
+ difficulty = diff;
+ init();
}
@@ -133,3 +137,3 @@ void Game :: update( int state )
{
- if ( replay )
+ if ( replay )
{
@@ -168,5 +172,4 @@ 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 );
@@ -175,3 +178,3 @@ void Game :: draw( SDL_Surface *screen )
{
- QString crashText;
+ string crashText;
crashText = "Game Over";
@@ -225,3 +228,3 @@ void Game :: setSeed( int seed )
-void Game :: saveReplay( QString file )
+void Game :: saveReplay( string file )
{
@@ -238,3 +241,3 @@ void Game :: saveReplay( QString file )
// Format is:: <landscape seed> <game type> <difficulty> <framenr> <framenr>.......
- QString val;
+ string val;
char tmp[20];
@@ -253,3 +256,3 @@ void Game :: saveReplay( QString file )
- QString line;
+ string line;
sprintf( tmp, "%d\n", val.length() );
@@ -261,8 +264,5 @@ 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 )
{
@@ -287,5 +287,4 @@ void Game :: loadReplay( QString file )
fread( data, 1, length, in );
-// printf( "data - %s", data );
- QString sep = " ";
+ string sep = " ";
@@ -310,5 +309,2 @@ void Game :: loadReplay( QString file )
fclose( in );
-
- printf( "Replay loaded from %s\n", (const char *)file.c_str() );
-
}