summaryrefslogtreecommitdiff
path: root/noncore/games/sfcave-sdl/help.cpp
Unidiff
Diffstat (limited to 'noncore/games/sfcave-sdl/help.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/games/sfcave-sdl/help.cpp472
1 files changed, 236 insertions, 236 deletions
diff --git a/noncore/games/sfcave-sdl/help.cpp b/noncore/games/sfcave-sdl/help.cpp
index f1728f6..0a7924b 100644
--- a/noncore/games/sfcave-sdl/help.cpp
+++ b/noncore/games/sfcave-sdl/help.cpp
@@ -1,236 +1,236 @@
1#include "SDL.h" 1#include <SDL/SDL.h>
2#include "constants.h" 2#include "constants.h"
3 3
4#include "font.h" 4#include "font.h"
5#include "help.h" 5#include "help.h"
6#include "sfcave.h" 6#include "sfcave.h"
7#include "starfield.h" 7#include "starfield.h"
8 8
9Help :: Help( SFCave *p ) 9Help :: Help( SFCave *p )
10{ 10{
11 parent = p; 11 parent = p;
12 stars = new StarField( false, 200 ); 12 stars = new StarField( false, 200 );
13 13
14 loadText(); 14 loadText();
15 15
16 init(); 16 init();
17} 17}
18 18
19Help :: ~Help() 19Help :: ~Help()
20{ 20{
21 delete stars; 21 delete stars;
22} 22}
23 23
24void Help :: handleKeys( SDL_KeyboardEvent &key ) 24void Help :: handleKeys( SDL_KeyboardEvent &key )
25{ 25{
26 if ( key.type == SDL_KEYDOWN ) 26 if ( key.type == SDL_KEYDOWN )
27 { 27 {
28 if ( key.keysym.sym == SDLK_SPACE ) 28 if ( key.keysym.sym == SDLK_SPACE )
29 parent->changeState( STATE_MENU ); 29 parent->changeState( STATE_MENU );
30 else if ( key.keysym.sym == SDLK_DOWN ) 30 else if ( key.keysym.sym == SDLK_DOWN )
31 textSpeed = 5; 31 textSpeed = 5;
32 else if ( key.keysym.sym == SDLK_UP ) 32 else if ( key.keysym.sym == SDLK_UP )
33 { 33 {
34 if ( textSpeed > 0 ) 34 if ( textSpeed > 0 )
35 textSpeed = 0; 35 textSpeed = 0;
36 else textSpeed = 1; 36 else textSpeed = 1;
37 } 37 }
38 38
39 } 39 }
40 else if ( key.type == SDL_KEYUP ) 40 else if ( key.type == SDL_KEYUP )
41 { 41 {
42 if ( key.keysym.sym == SDLK_DOWN ) 42 if ( key.keysym.sym == SDLK_DOWN )
43 textSpeed = 1; 43 textSpeed = 1;
44 } 44 }
45} 45}
46void Help :: init() 46void Help :: init()
47{ 47{
48 startPos = 320; 48 startPos = 320;
49 currLine = 0; 49 currLine = 0;
50 textSpeed = 1; 50 textSpeed = 1;
51 51
52 // Create our coloured font 52 // Create our coloured font
53 FontHandler :: changeColor( FONT_HELP_FONT, 0, 0, 255 ); 53 FontHandler :: changeColor( FONT_HELP_FONT, 0, 0, 255 );
54} 54}
55 55
56void Help :: draw( SDL_Surface *screen ) 56void Help :: draw( SDL_Surface *screen )
57{ 57{
58 stars->draw( screen ); 58 stars->draw( screen );
59 59
60 list<string>::iterator it = textList.begin(); 60 list<string>::iterator it = textList.begin();
61 61
62 // Move to start of text 62 // Move to start of text
63 for ( int i = 0 ; i < currLine && it != textList.end() ; ++i ) 63 for ( int i = 0 ; i < currLine && it != textList.end() ; ++i )
64 it++; 64 it++;
65 65
66 int pos = startPos; 66 int pos = startPos;
67 while ( pos < 320 && it != textList.end() ) 67 while ( pos < 320 && it != textList.end() )
68 { 68 {
69 // get next line 69 // get next line
70 string text = *it; 70 string text = *it;
71 71
72 // draw text 72 // draw text
73 FontHandler::draw( screen, FONT_COLOURED_TEXT, text.c_str(), -1, pos ); 73 FontHandler::draw( screen, FONT_COLOURED_TEXT, text.c_str(), -1, pos );
74 pos += FontHandler::FontHeight( FONT_COLOURED_TEXT ); 74 pos += FontHandler::FontHeight( FONT_COLOURED_TEXT );
75 it ++; 75 it ++;
76 } 76 }
77 77
78} 78}
79 79
80void Help :: update() 80void Help :: update()
81{ 81{
82 stars->move(); 82 stars->move();
83 83
84 startPos -= textSpeed; 84 startPos -= textSpeed;
85 if ( startPos <= -FontHandler::FontHeight( FONT_COLOURED_TEXT ) ) 85 if ( startPos <= -FontHandler::FontHeight( FONT_COLOURED_TEXT ) )
86 { 86 {
87 startPos = 0; 87 startPos = 0;
88 currLine ++; 88 currLine ++;
89 89
90 if ( currLine > textList.size() ) 90 if ( currLine > textList.size() )
91 { 91 {
92 startPos = 320; 92 startPos = 320;
93 currLine = 0; 93 currLine = 0;
94 } 94 }
95 } 95 }
96 96
97} 97}
98 98
99void Help :: loadText() 99void Help :: loadText()
100{ 100{
101 textList.push_back( "SFCave" ); 101 textList.push_back( "SFCave" );
102 textList.push_back( "Written By AndyQ" ); 102 textList.push_back( "Written By AndyQ" );
103 textList.push_back( "" ); 103 textList.push_back( "" );
104 textList.push_back( "Instructions" ); 104 textList.push_back( "Instructions" );
105 textList.push_back( "To return to the menu" ); 105 textList.push_back( "To return to the menu" );
106 textList.push_back( "press the space or " ); 106 textList.push_back( "press the space or " );
107 textList.push_back( "middle button." ); 107 textList.push_back( "middle button." );
108 textList.push_back( "" ); 108 textList.push_back( "" );
109 textList.push_back( "To speed up the text" ); 109 textList.push_back( "To speed up the text" );
110 textList.push_back( "hold the down button" ); 110 textList.push_back( "hold the down button" );
111 textList.push_back( "(releasing will return" ); 111 textList.push_back( "(releasing will return" );
112 textList.push_back( "to normal speed)" ); 112 textList.push_back( "to normal speed)" );
113 textList.push_back( "" ); 113 textList.push_back( "" );
114 textList.push_back( "" ); 114 textList.push_back( "" );
115 textList.push_back( "SFCave is a flying game" ); 115 textList.push_back( "SFCave is a flying game" );
116 textList.push_back( "writtin originally for the" ); 116 textList.push_back( "writtin originally for the" );
117 textList.push_back( "Sharp Zaurus." ); 117 textList.push_back( "Sharp Zaurus." );
118 textList.push_back( "" ); 118 textList.push_back( "" );
119 textList.push_back( "The aim is to stay alive" ); 119 textList.push_back( "The aim is to stay alive" );
120 textList.push_back( "for as long as possible," ); 120 textList.push_back( "for as long as possible," );
121 textList.push_back( "and get the highest score" ); 121 textList.push_back( "and get the highest score" );
122 textList.push_back( "you can." ); 122 textList.push_back( "you can." );
123 textList.push_back( "" ); 123 textList.push_back( "" );
124 textList.push_back( "There are currently three" ); 124 textList.push_back( "There are currently three" );
125 textList.push_back( "game types - SFCave," ); 125 textList.push_back( "game types - SFCave," );
126 textList.push_back( "Gates, and Fly." ); 126 textList.push_back( "Gates, and Fly." );
127 textList.push_back( "" ); 127 textList.push_back( "" );
128 textList.push_back( "SFCave is a remake of" ); 128 textList.push_back( "SFCave is a remake of" );
129 textList.push_back( "the classic SFCave game." ); 129 textList.push_back( "the classic SFCave game." );
130 textList.push_back( "Fly through the cavern" ); 130 textList.push_back( "Fly through the cavern" );
131 textList.push_back( "avoiding all the blocks" ); 131 textList.push_back( "avoiding all the blocks" );
132 textList.push_back( "that just happen to be" ); 132 textList.push_back( "that just happen to be" );
133 textList.push_back( "hanging in mid-air" ); 133 textList.push_back( "hanging in mid-air" );
134 textList.push_back( "" ); 134 textList.push_back( "" );
135 textList.push_back( "Gates is similar to" ); 135 textList.push_back( "Gates is similar to" );
136 textList.push_back( "SFCave but instead of" ); 136 textList.push_back( "SFCave but instead of" );
137 textList.push_back( "avoiding blocks you must" ); 137 textList.push_back( "avoiding blocks you must" );
138 textList.push_back( "fly through gates without" ); 138 textList.push_back( "fly through gates without" );
139 textList.push_back( "crashing." ); 139 textList.push_back( "crashing." );
140 textList.push_back( "" ); 140 textList.push_back( "" );
141 textList.push_back( "Fly is a different kettle of" ); 141 textList.push_back( "Fly is a different kettle of" );
142 textList.push_back( "fish altogether. Instead," ); 142 textList.push_back( "fish altogether. Instead," );
143 textList.push_back( "you are flying in the " ); 143 textList.push_back( "you are flying in the " );
144 textList.push_back( "open air above a" ); 144 textList.push_back( "open air above a" );
145 textList.push_back( "scrolling landscape and" ); 145 textList.push_back( "scrolling landscape and" );
146 textList.push_back( "the aim is to fly as close" ); 146 textList.push_back( "the aim is to fly as close" );
147 textList.push_back( "to the land as possible." ); 147 textList.push_back( "to the land as possible." );
148 textList.push_back( "The closer to the land" ); 148 textList.push_back( "The closer to the land" );
149 textList.push_back( "you fly the more points" ); 149 textList.push_back( "you fly the more points" );
150 textList.push_back( "you score. But beware," ); 150 textList.push_back( "you score. But beware," );
151 textList.push_back( "fly too high above the" ); 151 textList.push_back( "fly too high above the" );
152 textList.push_back( "land and points get" ); 152 textList.push_back( "land and points get" );
153 textList.push_back( "deducted." ); 153 textList.push_back( "deducted." );
154 textList.push_back( "" ); 154 textList.push_back( "" );
155 textList.push_back( "How to play" ); 155 textList.push_back( "How to play" );
156 textList.push_back( "Press the space or middle" ); 156 textList.push_back( "Press the space or middle" );
157 textList.push_back( "button (Zaurus only) to " ); 157 textList.push_back( "button (Zaurus only) to " );
158 textList.push_back( "apply thrust (makes you" ); 158 textList.push_back( "apply thrust (makes you" );
159 textList.push_back( "go up) and release it" ); 159 textList.push_back( "go up) and release it" );
160 textList.push_back( "to go down." ); 160 textList.push_back( "to go down." );
161 textList.push_back( "" ); 161 textList.push_back( "" );
162 textList.push_back( "Have fun" ); 162 textList.push_back( "Have fun" );
163 textList.push_back( "AndyQ" ); 163 textList.push_back( "AndyQ" );
164} 164}
165 165
166// Test 166// Test
167#ifdef DEBUG_HELP 167#ifdef DEBUG_HELP
168SDL_Surface *screen; 168SDL_Surface *screen;
169Help *help; 169Help *help;
170 170
171void go() 171void go()
172{ 172{
173 FontHandler :: init(); 173 FontHandler :: init();
174 174
175 /* Initialize SDL */ 175 /* Initialize SDL */
176 if ( SDL_Init(SDL_INIT_VIDEO) < 0 ) 176 if ( SDL_Init(SDL_INIT_VIDEO) < 0 )
177 { 177 {
178 fprintf(stderr, "Couldn't initialize SDL: %s\n",SDL_GetError()); 178 fprintf(stderr, "Couldn't initialize SDL: %s\n",SDL_GetError());
179 exit(1); 179 exit(1);
180 } 180 }
181 atexit(SDL_Quit); 181 atexit(SDL_Quit);
182 182
183 int videoflags = SDL_SWSURFACE ; 183 int videoflags = SDL_SWSURFACE ;
184 184
185 if ( (screen=SDL_SetVideoMode(240, 320,32,videoflags)) == NULL ) 185 if ( (screen=SDL_SetVideoMode(240, 320,32,videoflags)) == NULL )
186 { 186 {
187 fprintf(stderr, "Couldn't set %ix%i video mode: %s\n",240,320,SDL_GetError()); 187 fprintf(stderr, "Couldn't set %ix%i video mode: %s\n",240,320,SDL_GetError());
188 exit(2); 188 exit(2);
189 } 189 }
190 190
191 help = new Help(); 191 help = new Help();
192 192
193 bool done = false; 193 bool done = false;
194 while ( !done ) 194 while ( !done )
195 { 195 {
196 SDL_FillRect( screen, 0, 0 ); 196 SDL_FillRect( screen, 0, 0 );
197 help->draw( screen ); 197 help->draw( screen );
198 help->update( ); 198 help->update( );
199 199
200 SDL_Flip( screen ); 200 SDL_Flip( screen );
201 201
202 SDL_Delay( 10 ); 202 SDL_Delay( 10 );
203 203
204 SDL_Event event; 204 SDL_Event event;
205 while ( SDL_PollEvent(&event) ) 205 while ( SDL_PollEvent(&event) )
206 { 206 {
207 switch (event.type) 207 switch (event.type)
208 { 208 {
209 case SDL_KEYDOWN: 209 case SDL_KEYDOWN:
210 // Escape keypress quits the app 210 // Escape keypress quits the app
211 if ( event.key.keysym.sym != SDLK_ESCAPE ) 211 if ( event.key.keysym.sym != SDLK_ESCAPE )
212 { 212 {
213 break; 213 break;
214 } 214 }
215 case SDL_QUIT: 215 case SDL_QUIT:
216 done = 1; 216 done = 1;
217 break; 217 break;
218 default: 218 default:
219 break; 219 break;
220 } 220 }
221 } 221 }
222 } 222 }
223 } 223 }
224 224
225 225
226 226
227 227
228#ifdef __cplusplus 228#ifdef __cplusplus
229extern "C" 229extern "C"
230#endif 230#endif
231int main( int argc, char *argv[] ) 231int main( int argc, char *argv[] )
232{ 232{
233 go(); 233 go();
234} 234}
235 235
236#endif 236#endif