summaryrefslogtreecommitdiff
authorandyq <andyq>2003-02-28 23:56:03 (UTC)
committer andyq <andyq>2003-02-28 23:56:03 (UTC)
commit7dd36872a3eb63eb1c3c7a17549f3eeba92f1b32 (patch) (unidiff)
treeb0628e9a3c75129d24301e30c44c55a23f03d963
parent64423f1852a13178f23365f2bba995ef2c355b3b (diff)
downloadopie-7dd36872a3eb63eb1c3c7a17549f3eeba92f1b32.zip
opie-7dd36872a3eb63eb1c3c7a17549f3eeba92f1b32.tar.gz
opie-7dd36872a3eb63eb1c3c7a17549f3eeba92f1b32.tar.bz2
Changed keyboard handling to accept UP, ENTER and RETURN for moving ship
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
@@ -24,97 +24,101 @@ Game :: Game( SFCave *p, int w, int h, int diff )
24 sHeight = h; 24 sHeight = h;
25 sWidth = w; 25 sWidth = w;
26 difficulty = diff; 26 difficulty = diff;
27 replayIt = 0; 27 replayIt = 0;
28 replay = false; 28 replay = false;
29 terrain = 0; 29 terrain = 0;
30 player = 0; 30 player = 0;
31 thrustChannel = -1; 31 thrustChannel = -1;
32} 32}
33 33
34Game :: ~Game() 34Game :: ~Game()
35{ 35{
36 if ( terrain ) 36 if ( terrain )
37 delete terrain; 37 delete terrain;
38 38
39 if ( player ) 39 if ( player )
40 delete player; 40 delete player;
41 41
42 replayList.clear(); 42 replayList.clear();
43} 43}
44 44
45void Game :: init() 45void Game :: init()
46{ 46{
47 if ( replay ) 47 if ( replay )
48 { 48 {
49 setSeed( currentSeed ); 49 setSeed( currentSeed );
50 replayIt = replayList.begin(); 50 replayIt = replayList.begin();
51 } 51 }
52 else 52 else
53 { 53 {
54 setSeed( -1 ); 54 setSeed( -1 );
55 replayList.clear(); 55 replayList.clear();
56 } 56 }
57 57
58 score = 0; 58 score = 0;
59 nrFrames = 0; 59 nrFrames = 0;
60 press = false; 60 press = false;
61 61
62 // Load highscore 62 // Load highscore
63 string key = getGameName() + "_" + getGameDifficultyText() + "_highscore"; 63 string key = getGameName() + "_" + getGameDifficultyText() + "_highscore";
64 highScore = atoi( parent->loadSetting( key, "0" ).c_str() ); 64 highScore = atoi( parent->loadSetting( key, "0" ).c_str() );
65 65
66 terrain->initTerrain(); 66 terrain->initTerrain();
67 player->init(); 67 player->init();
68} 68}
69 69
70void Game :: handleKeys( SDL_KeyboardEvent &key ) 70void Game :: handleKeys( SDL_KeyboardEvent &key )
71{ 71{
72 if ( !replay && key.keysym.sym == SDLK_SPACE ) 72 if ( !replay &&
73 (key.keysym.sym == SDLK_SPACE ||
74 key.keysym.sym == SDLK_KP_ENTER ||
75 key.keysym.sym == SDLK_RETURN ||
76 key.keysym.sym == SDLK_UP) )
73 { 77 {
74 if ( key.type == SDL_KEYDOWN ) 78 if ( key.type == SDL_KEYDOWN )
75 { 79 {
76 if ( !press ) 80 if ( !press )
77 replayList.push_back( nrFrames ); 81 replayList.push_back( nrFrames );
78 press = true; 82 press = true;
79 } 83 }
80 else 84 else
81 { 85 {
82 if ( press ) 86 if ( press )
83 replayList.push_back( nrFrames ); 87 replayList.push_back( nrFrames );
84 press = false; 88 press = false;
85 89
86 } 90 }
87 } 91 }
88} 92}
89 93
90 94
91 95
92string Game :: getGameDifficultyText() 96string Game :: getGameDifficultyText()
93{ 97{
94 string ret; 98 string ret;
95 99
96 if ( difficulty == MENU_DIFFICULTY_EASY ) 100 if ( difficulty == MENU_DIFFICULTY_EASY )
97 ret = "Easy"; 101 ret = "Easy";
98 else if ( difficulty == MENU_DIFFICULTY_NORMAL ) 102 else if ( difficulty == MENU_DIFFICULTY_NORMAL )
99 ret = "Medium"; 103 ret = "Medium";
100 else if ( difficulty == MENU_DIFFICULTY_HARD ) 104 else if ( difficulty == MENU_DIFFICULTY_HARD )
101 ret = "Hard"; 105 ret = "Hard";
102 else if ( difficulty == MENU_DIFFICULTY_CUSTOM ) 106 else if ( difficulty == MENU_DIFFICULTY_CUSTOM )
103 ret = "Custom"; 107 ret = "Custom";
104 108
105 return ret; 109 return ret;
106} 110}
107 111
108void Game :: setDifficulty( string diff ) 112void Game :: setDifficulty( string diff )
109{ 113{
110 if ( diff == "Easy" ) 114 if ( diff == "Easy" )
111 difficulty = MENU_DIFFICULTY_EASY; 115 difficulty = MENU_DIFFICULTY_EASY;
112 else if ( diff == "Medium" ) 116 else if ( diff == "Medium" )
113 difficulty = MENU_DIFFICULTY_NORMAL; 117 difficulty = MENU_DIFFICULTY_NORMAL;
114 else if ( diff == "Hard" ) 118 else if ( diff == "Hard" )
115 difficulty = MENU_DIFFICULTY_HARD; 119 difficulty = MENU_DIFFICULTY_HARD;
116 else if ( diff == "Custom" ) 120 else if ( diff == "Custom" )
117 difficulty = MENU_DIFFICULTY_CUSTOM; 121 difficulty = MENU_DIFFICULTY_CUSTOM;
118 122
119 init(); 123 init();
120} 124}