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/sfcave_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/sfcave_game.cpp') (more/less context) (show whitespace changes)
-rw-r--r-- | noncore/games/sfcave-sdl/sfcave_game.cpp | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/noncore/games/sfcave-sdl/sfcave_game.cpp b/noncore/games/sfcave-sdl/sfcave_game.cpp index 72c5ce3..1b00e14 100644 --- a/noncore/games/sfcave-sdl/sfcave_game.cpp +++ b/noncore/games/sfcave-sdl/sfcave_game.cpp @@ -18,78 +18,90 @@ SFCaveGame :: SFCaveGame( SFCave *p, int w, int h, int diff ) SFCaveGame :: ~SFCaveGame() { } void SFCaveGame :: init() { Game :: init(); blockDistance = 50; blockHeight = 80; blockWidth = 20; switch( difficulty ) { case MENU_DIFFICULTY_EASY: blockDistance = 50; break; case MENU_DIFFICULTY_NORMAL: blockDistance = 40; break; case MENU_DIFFICULTY_HARD: blockDistance = 30; break; + case MENU_DIFFICULTY_CUSTOM: + { + // Read custom difficulty settings for this game + blockDistance = parent->loadIntSetting( "SFCave_custom_blockdistance", 50 ); + + double thrust = parent->loadDoubleSetting( "SFCave_custom_player_thrust", 0.4 ); + double gravity = parent->loadDoubleSetting( "SFCave_custom_player_gravity", 0.6 ); + double maxUp = parent->loadDoubleSetting( "SFCave_custom_player_maxupspeed", 4.0 ); + double maxDown = parent->loadDoubleSetting( "SFCave_custom_player_maxdownspeed", 5.0 ); + player->setMovementInfo( thrust, gravity, maxUp, maxDown ); + + break; + } } for ( int i = 0 ; i < BLOCKSIZE ; ++i ) blocks[i].y( -1 ); } void SFCaveGame :: update( int state ) { Game::update( state ); if ( state == STATE_PLAYING ) { if ( nrFrames % 3 == 0 ) score ++; if ( nrFrames % 200 == 0 ) { if ( terrain->getMaxHeight() < sHeight - 100 ) { terrain->increaseMaxHeight( 10 ); // Reduce block height if ( terrain->getMaxHeight() > sHeight - 150 ) blockHeight -= 5; } } if ( checkCollisions() ) { -// printf( "Crashed!\n" ); parent->changeState( STATE_CRASHING ); return; } if ( nrFrames % blockDistance == 0 ) addBlock(); // Game logic goes here terrain->moveTerrain( 5 ); moveBlocks( 5 ); player->move( press ); } } void SFCaveGame :: draw( SDL_Surface *screen ) { Game::preDraw( screen ); if ( parent->getState() == STATE_PLAYING ) { // Screen drawing goes here terrain->drawTerrain( screen ); player->draw( screen ); |