summaryrefslogtreecommitdiff
path: root/noncore/games/sfcave-sdl/gates_game.cpp
Side-by-side diff
Diffstat (limited to 'noncore/games/sfcave-sdl/gates_game.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/games/sfcave-sdl/gates_game.cpp15
1 files changed, 14 insertions, 1 deletions
diff --git a/noncore/games/sfcave-sdl/gates_game.cpp b/noncore/games/sfcave-sdl/gates_game.cpp
index 1a9bc89..762801d 100644
--- a/noncore/games/sfcave-sdl/gates_game.cpp
+++ b/noncore/games/sfcave-sdl/gates_game.cpp
@@ -9,24 +9,25 @@ GatesGame :: GatesGame( SFCave *p, int w, int h, int diff )
{
gameName = "Gates";
difficulty = MENU_DIFFICULTY_EASY;
blockUpdateRate = 200;
terrain = new Terrain( w, h );
player = new Player( w, h );
highScore = 0;
}
GatesGame :: ~GatesGame()
{
+ // terrain and player get deleted by parent class
}
void GatesGame :: init()
{
Game :: init();
blockHeight = 80;
blockWidth = 20;
lastGateBottomY = 0;
gateDistance = 75;
nextGate = nextInt( 50 ) + gateDistance;
@@ -37,24 +38,37 @@ void GatesGame :: init()
case MENU_DIFFICULTY_EASY:
gapHeight = 75;
player->setMovementInfo( 0.4, 0.6, 4, 5 );
break;
case MENU_DIFFICULTY_NORMAL:
gapHeight = 50;
player->setMovementInfo( 0.4, 0.6, 4, 5 );
break;
case MENU_DIFFICULTY_HARD:
gapHeight = 25;
player->setMovementInfo( 0.6, 0.8, 6, 7 );
break;
+ case MENU_DIFFICULTY_CUSTOM:
+ {
+ // Read custom difficulty settings for this game
+ gapHeight = parent->loadIntSetting( "Gates_custom_gapHeight", 75 );
+
+ double thrust = parent->loadDoubleSetting( "Gates_custom_player_thrust", 0.4 );
+ double gravity = parent->loadDoubleSetting( "Gates_custom_player_gravity", 0.6 );
+ double maxUp = parent->loadDoubleSetting( "Gates_custom_player_maxupspeed", 4.0 );
+ double maxDown = parent->loadDoubleSetting( "Gates_custom_player_maxdownspeed", 5.0 );
+ player->setMovementInfo( thrust, gravity, maxUp, maxDown );
+
+ break;
+ }
}
for ( int i = 0 ; i < BLOCKSIZE ; ++i )
blocks[i].y( -1 );
}
void GatesGame :: update( int state )
{
Game::update( state );
// Game logic goes here
if ( state == STATE_PLAYING )
@@ -68,25 +82,24 @@ void GatesGame :: update( int state )
gapHeight -= 5;
}
// Slightly random gap distance
if ( nrFrames >= nextGate )
{
nextGate = nrFrames + nextInt( 50 ) + gateDistance;
addGate();
}
if ( checkCollisions() )
{
-// printf( "Crashed!\n" );
parent->changeState( STATE_CRASHING );
return;
}
terrain->moveTerrain( 5 );
moveBlocks( 5 );
player->move( press );
}
}
void GatesGame :: draw( SDL_Surface *screen )
{