summaryrefslogtreecommitdiff
Side-by-side diff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/games/sfcave-sdl/game.cpp6
1 files changed, 5 insertions, 1 deletions
diff --git a/noncore/games/sfcave-sdl/game.cpp b/noncore/games/sfcave-sdl/game.cpp
index e41e510..1ee0230 100644
--- a/noncore/games/sfcave-sdl/game.cpp
+++ b/noncore/games/sfcave-sdl/game.cpp
@@ -8,129 +8,133 @@
#include "constants.h"
#include "game.h"
#include "player.h"
#include "random.h"
#include "sound.h"
#include "stringtokenizer.h"
#include "sfcave_game.h"
#include "gates_game.h"
#include "fly_game.h"
#include "starfield.h"
Game :: Game( SFCave *p, int w, int h, int diff )
{
parent = p;
sHeight = h;
sWidth = w;
difficulty = diff;
replayIt = 0;
replay = false;
terrain = 0;
player = 0;
thrustChannel = -1;
}
Game :: ~Game()
{
if ( terrain )
delete terrain;
if ( player )
delete player;
replayList.clear();
}
void Game :: init()
{
if ( replay )
{
setSeed( currentSeed );
replayIt = replayList.begin();
}
else
{
setSeed( -1 );
replayList.clear();
}
score = 0;
nrFrames = 0;
press = false;
// Load highscore
string key = getGameName() + "_" + getGameDifficultyText() + "_highscore";
highScore = atoi( parent->loadSetting( key, "0" ).c_str() );
terrain->initTerrain();
player->init();
}
void Game :: handleKeys( SDL_KeyboardEvent &key )
{
- if ( !replay && key.keysym.sym == SDLK_SPACE )
+ if ( !replay &&
+ (key.keysym.sym == SDLK_SPACE ||
+ key.keysym.sym == SDLK_KP_ENTER ||
+ key.keysym.sym == SDLK_RETURN ||
+ key.keysym.sym == SDLK_UP) )
{
if ( key.type == SDL_KEYDOWN )
{
if ( !press )
replayList.push_back( nrFrames );
press = true;
}
else
{
if ( press )
replayList.push_back( nrFrames );
press = false;
}
}
}
string Game :: getGameDifficultyText()
{
string ret;
if ( difficulty == MENU_DIFFICULTY_EASY )
ret = "Easy";
else if ( difficulty == MENU_DIFFICULTY_NORMAL )
ret = "Medium";
else if ( difficulty == MENU_DIFFICULTY_HARD )
ret = "Hard";
else if ( difficulty == MENU_DIFFICULTY_CUSTOM )
ret = "Custom";
return ret;
}
void Game :: setDifficulty( string diff )
{
if ( diff == "Easy" )
difficulty = MENU_DIFFICULTY_EASY;
else if ( diff == "Medium" )
difficulty = MENU_DIFFICULTY_NORMAL;
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();
}
void Game :: update( int state )
{
nrFrames ++;
if ( score > highScore )
highScore = score;
if ( state == STATE_PLAYING )