summaryrefslogtreecommitdiff
Side-by-side diff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/games/sfcave-sdl/animatedimage.cpp4
-rw-r--r--noncore/games/sfcave-sdl/animatedimage.h2
-rw-r--r--noncore/games/sfcave-sdl/bfont.cpp2
-rw-r--r--noncore/games/sfcave-sdl/bfont.h2
-rw-r--r--noncore/games/sfcave-sdl/fly_game.cpp2
-rw-r--r--noncore/games/sfcave-sdl/fly_game.h2
-rw-r--r--noncore/games/sfcave-sdl/flyterrain.cpp3
-rw-r--r--noncore/games/sfcave-sdl/flyterrain.h2
-rw-r--r--noncore/games/sfcave-sdl/font.h2
-rw-r--r--noncore/games/sfcave-sdl/game.cpp4
-rw-r--r--noncore/games/sfcave-sdl/gates_game.cpp2
-rw-r--r--noncore/games/sfcave-sdl/gates_game.h2
-rw-r--r--noncore/games/sfcave-sdl/help.cpp472
-rw-r--r--noncore/games/sfcave-sdl/help.h70
-rw-r--r--noncore/games/sfcave-sdl/menu.cpp4
-rw-r--r--noncore/games/sfcave-sdl/menu.h2
-rw-r--r--noncore/games/sfcave-sdl/player.cpp4
-rw-r--r--noncore/games/sfcave-sdl/rect.h122
-rw-r--r--noncore/games/sfcave-sdl/sfcave-sdl.pro108
-rw-r--r--noncore/games/sfcave-sdl/sfcave.cpp4
-rw-r--r--noncore/games/sfcave-sdl/sfcave.h2
-rw-r--r--noncore/games/sfcave-sdl/sfcave_game.cpp2
-rw-r--r--noncore/games/sfcave-sdl/sfcave_game.h2
-rw-r--r--noncore/games/sfcave-sdl/sound.cpp314
-rw-r--r--noncore/games/sfcave-sdl/sound.h70
-rw-r--r--noncore/games/sfcave-sdl/starfield.cpp590
-rw-r--r--noncore/games/sfcave-sdl/starfield.h82
-rw-r--r--noncore/games/sfcave-sdl/stringtokenizer.h46
-rw-r--r--noncore/games/sfcave-sdl/terrain.cpp6
-rw-r--r--noncore/games/sfcave-sdl/terrain.h2
-rw-r--r--noncore/games/sfcave-sdl/util.cpp150
-rw-r--r--noncore/games/sfcave-sdl/util.h20
32 files changed, 1050 insertions, 1051 deletions
diff --git a/noncore/games/sfcave-sdl/animatedimage.cpp b/noncore/games/sfcave-sdl/animatedimage.cpp
index 441c647..680b603 100644
--- a/noncore/games/sfcave-sdl/animatedimage.cpp
+++ b/noncore/games/sfcave-sdl/animatedimage.cpp
@@ -1,6 +1,6 @@
-#include "SDL.h"
-#include "SDL_image.h"
+#include <SDL/SDL.h>
+#include <SDL/SDL_image.h>
#include "constants.h"
#include "animatedimage.h"
diff --git a/noncore/games/sfcave-sdl/animatedimage.h b/noncore/games/sfcave-sdl/animatedimage.h
index 3c03f52..ecebf03 100644
--- a/noncore/games/sfcave-sdl/animatedimage.h
+++ b/noncore/games/sfcave-sdl/animatedimage.h
@@ -1,8 +1,8 @@
#ifndef __ANIMATED_IMAGE_H
#define __ANIMATED_IMAGE_H
-#include "SDL.h"
+#include <SDL/SDL.h>
class AnimatedImage
{
public:
diff --git a/noncore/games/sfcave-sdl/bfont.cpp b/noncore/games/sfcave-sdl/bfont.cpp
index 7dec8f5..3ba0f4f 100644
--- a/noncore/games/sfcave-sdl/bfont.cpp
+++ b/noncore/games/sfcave-sdl/bfont.cpp
@@ -8,9 +8,9 @@ using namespace std;
#include "string.h"
#include "stdlib.h"
#include "stdarg.h"
-#include "SDL_image.h"
+#include <SDL/SDL_image.h>
#include "bfont.h"
void BFont::InitFont()
{
diff --git a/noncore/games/sfcave-sdl/bfont.h b/noncore/games/sfcave-sdl/bfont.h
index dee97f1..5c2d7e7 100644
--- a/noncore/games/sfcave-sdl/bfont.h
+++ b/noncore/games/sfcave-sdl/bfont.h
@@ -8,9 +8,9 @@
#ifndef __BFONT_HEADER_H__
#define __BFONT_HEADER_H__
#include <iostream>
-#include "SDL.h"
+#include <SDL/SDL.h>
class BFont
{
int h; // font height
diff --git a/noncore/games/sfcave-sdl/fly_game.cpp b/noncore/games/sfcave-sdl/fly_game.cpp
index 8b05d8f..69413ba 100644
--- a/noncore/games/sfcave-sdl/fly_game.cpp
+++ b/noncore/games/sfcave-sdl/fly_game.cpp
@@ -1,5 +1,5 @@
-#include "SDL_gfxPrimitives.h"
+#include <SDL/SDL_gfxPrimitives.h>
#include "constants.h"
#include "fly_game.h"
#include "random.h"
diff --git a/noncore/games/sfcave-sdl/fly_game.h b/noncore/games/sfcave-sdl/fly_game.h
index 1ab081a..f648deb 100644
--- a/noncore/games/sfcave-sdl/fly_game.h
+++ b/noncore/games/sfcave-sdl/fly_game.h
@@ -4,9 +4,9 @@
#include "sfcave.h"
#include "flyterrain.h"
#include "player.h"
#include "game.h"
-#include "SDL.h"
+#include <SDL/SDL.h>
class FlyGame : public Game
{
public:
diff --git a/noncore/games/sfcave-sdl/flyterrain.cpp b/noncore/games/sfcave-sdl/flyterrain.cpp
index b1b8db5..bffe5c9 100644
--- a/noncore/games/sfcave-sdl/flyterrain.cpp
+++ b/noncore/games/sfcave-sdl/flyterrain.cpp
@@ -1,6 +1,5 @@
-
-#include "SDL_gfxPrimitives.h"
+#include <SDL/SDL_gfxPrimitives.h>
#include "constants.h"
#include "flyterrain.h"
#include "random.h"
diff --git a/noncore/games/sfcave-sdl/flyterrain.h b/noncore/games/sfcave-sdl/flyterrain.h
index 63b5731..6258fa0 100644
--- a/noncore/games/sfcave-sdl/flyterrain.h
+++ b/noncore/games/sfcave-sdl/flyterrain.h
@@ -1,8 +1,8 @@
#ifndef __FLYTERRAIN_H
#define __FLYTERRAIN_H
-#include <SDL.h>
+#include <SDL/SDL.h>
#include "terrain.h"
class FlyTerrain : public Terrain
diff --git a/noncore/games/sfcave-sdl/font.h b/noncore/games/sfcave-sdl/font.h
index 5f0674a..ed9c590 100644
--- a/noncore/games/sfcave-sdl/font.h
+++ b/noncore/games/sfcave-sdl/font.h
@@ -1,8 +1,8 @@
#ifndef __FONT_H
#define __FONT_H
-#include "SDL.h"
+#include <SDL/SDL.h>
#include "bfont.h"
#define FONT_MENU_HIGHLIGHTED 1
#define FONT_MENU_UNHIGHLIGHTED 2
diff --git a/noncore/games/sfcave-sdl/game.cpp b/noncore/games/sfcave-sdl/game.cpp
index 1ee0230..bf9c46f 100644
--- a/noncore/games/sfcave-sdl/game.cpp
+++ b/noncore/games/sfcave-sdl/game.cpp
@@ -1,9 +1,9 @@
#include <stdio.h>
#include <time.h>
-#include <SDL.h>
-#include <SDL_image.h>
+#include <SDL/SDL.h>
+#include <SDL/SDL_image.h>
#include "font.h"
#include "constants.h"
diff --git a/noncore/games/sfcave-sdl/gates_game.cpp b/noncore/games/sfcave-sdl/gates_game.cpp
index 700a6ec..638658b 100644
--- a/noncore/games/sfcave-sdl/gates_game.cpp
+++ b/noncore/games/sfcave-sdl/gates_game.cpp
@@ -1,5 +1,5 @@
-#include "SDL_gfxPrimitives.h"
+#include <SDL/SDL_gfxPrimitives.h>
#include "constants.h"
#include "gates_game.h"
#include "random.h"
diff --git a/noncore/games/sfcave-sdl/gates_game.h b/noncore/games/sfcave-sdl/gates_game.h
index 8499ff9..b44336a 100644
--- a/noncore/games/sfcave-sdl/gates_game.h
+++ b/noncore/games/sfcave-sdl/gates_game.h
@@ -1,8 +1,8 @@
#ifndef __GATES_GAME_H
#define __GATES_GAME_H
-#include "SDL.h"
+#include <SDL/SDL.h>
#include "rect.h"
#include "sfcave.h"
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 @@
-#include "SDL.h"
-#include "constants.h"
-
-#include "font.h"
-#include "help.h"
-#include "sfcave.h"
-#include "starfield.h"
-
-Help :: Help( SFCave *p )
-{
- parent = p;
- stars = new StarField( false, 200 );
-
- loadText();
-
- init();
-}
-
-Help :: ~Help()
-{
- delete stars;
-}
-
-void Help :: handleKeys( SDL_KeyboardEvent &key )
-{
- if ( key.type == SDL_KEYDOWN )
- {
- if ( key.keysym.sym == SDLK_SPACE )
- parent->changeState( STATE_MENU );
- else if ( key.keysym.sym == SDLK_DOWN )
- textSpeed = 5;
- else if ( key.keysym.sym == SDLK_UP )
- {
- if ( textSpeed > 0 )
- textSpeed = 0;
- else textSpeed = 1;
- }
-
- }
- else if ( key.type == SDL_KEYUP )
- {
- if ( key.keysym.sym == SDLK_DOWN )
- textSpeed = 1;
- }
-}
-void Help :: init()
-{
- startPos = 320;
- currLine = 0;
- textSpeed = 1;
-
- // Create our coloured font
- FontHandler :: changeColor( FONT_HELP_FONT, 0, 0, 255 );
-}
-
-void Help :: draw( SDL_Surface *screen )
-{
- stars->draw( screen );
-
- list<string>::iterator it = textList.begin();
-
- // Move to start of text
- for ( int i = 0 ; i < currLine && it != textList.end() ; ++i )
- it++;
-
- int pos = startPos;
- while ( pos < 320 && it != textList.end() )
- {
- // get next line
- string text = *it;
-
- // draw text
- FontHandler::draw( screen, FONT_COLOURED_TEXT, text.c_str(), -1, pos );
- pos += FontHandler::FontHeight( FONT_COLOURED_TEXT );
- it ++;
- }
-
-}
-
-void Help :: update()
-{
- stars->move();
-
- startPos -= textSpeed;
- if ( startPos <= -FontHandler::FontHeight( FONT_COLOURED_TEXT ) )
- {
- startPos = 0;
- currLine ++;
-
- if ( currLine > textList.size() )
- {
- startPos = 320;
- currLine = 0;
- }
- }
-
-}
-
-void Help :: loadText()
-{
- textList.push_back( "SFCave" );
- textList.push_back( "Written By AndyQ" );
- textList.push_back( "" );
- textList.push_back( "Instructions" );
- textList.push_back( "To return to the menu" );
- textList.push_back( "press the space or " );
- textList.push_back( "middle button." );
- textList.push_back( "" );
- textList.push_back( "To speed up the text" );
- textList.push_back( "hold the down button" );
- textList.push_back( "(releasing will return" );
- textList.push_back( "to normal speed)" );
- textList.push_back( "" );
- textList.push_back( "" );
- textList.push_back( "SFCave is a flying game" );
- textList.push_back( "writtin originally for the" );
- textList.push_back( "Sharp Zaurus." );
- textList.push_back( "" );
- textList.push_back( "The aim is to stay alive" );
- textList.push_back( "for as long as possible," );
- textList.push_back( "and get the highest score" );
- textList.push_back( "you can." );
- textList.push_back( "" );
- textList.push_back( "There are currently three" );
- textList.push_back( "game types - SFCave," );
- textList.push_back( "Gates, and Fly." );
- textList.push_back( "" );
- textList.push_back( "SFCave is a remake of" );
- textList.push_back( "the classic SFCave game." );
- textList.push_back( "Fly through the cavern" );
- textList.push_back( "avoiding all the blocks" );
- textList.push_back( "that just happen to be" );
- textList.push_back( "hanging in mid-air" );
- textList.push_back( "" );
- textList.push_back( "Gates is similar to" );
- textList.push_back( "SFCave but instead of" );
- textList.push_back( "avoiding blocks you must" );
- textList.push_back( "fly through gates without" );
- textList.push_back( "crashing." );
- textList.push_back( "" );
- textList.push_back( "Fly is a different kettle of" );
- textList.push_back( "fish altogether. Instead," );
- textList.push_back( "you are flying in the " );
- textList.push_back( "open air above a" );
- textList.push_back( "scrolling landscape and" );
- textList.push_back( "the aim is to fly as close" );
- textList.push_back( "to the land as possible." );
- textList.push_back( "The closer to the land" );
- textList.push_back( "you fly the more points" );
- textList.push_back( "you score. But beware," );
- textList.push_back( "fly too high above the" );
- textList.push_back( "land and points get" );
- textList.push_back( "deducted." );
- textList.push_back( "" );
- textList.push_back( "How to play" );
- textList.push_back( "Press the space or middle" );
- textList.push_back( "button (Zaurus only) to " );
- textList.push_back( "apply thrust (makes you" );
- textList.push_back( "go up) and release it" );
- textList.push_back( "to go down." );
- textList.push_back( "" );
- textList.push_back( "Have fun" );
- textList.push_back( "AndyQ" );
-}
-
-// Test
-#ifdef DEBUG_HELP
-SDL_Surface *screen;
-Help *help;
-
-void go()
-{
- FontHandler :: init();
-
- /* Initialize SDL */
- if ( SDL_Init(SDL_INIT_VIDEO) < 0 )
- {
- fprintf(stderr, "Couldn't initialize SDL: %s\n",SDL_GetError());
- exit(1);
- }
- atexit(SDL_Quit);
-
- int videoflags = SDL_SWSURFACE ;
-
- if ( (screen=SDL_SetVideoMode(240, 320,32,videoflags)) == NULL )
- {
- fprintf(stderr, "Couldn't set %ix%i video mode: %s\n",240,320,SDL_GetError());
- exit(2);
- }
-
- help = new Help();
-
- bool done = false;
- while ( !done )
- {
- SDL_FillRect( screen, 0, 0 );
- help->draw( screen );
- help->update( );
-
- SDL_Flip( screen );
-
- SDL_Delay( 10 );
-
- SDL_Event event;
- while ( SDL_PollEvent(&event) )
- {
- switch (event.type)
- {
- case SDL_KEYDOWN:
- // Escape keypress quits the app
- if ( event.key.keysym.sym != SDLK_ESCAPE )
- {
- break;
- }
- case SDL_QUIT:
- done = 1;
- break;
- default:
- break;
- }
- }
- }
- }
-
-
-
-
-#ifdef __cplusplus
-extern "C"
-#endif
-int main( int argc, char *argv[] )
-{
- go();
-}
-
-#endif
+#include <SDL/SDL.h>
+#include "constants.h"
+
+#include "font.h"
+#include "help.h"
+#include "sfcave.h"
+#include "starfield.h"
+
+Help :: Help( SFCave *p )
+{
+ parent = p;
+ stars = new StarField( false, 200 );
+
+ loadText();
+
+ init();
+}
+
+Help :: ~Help()
+{
+ delete stars;
+}
+
+void Help :: handleKeys( SDL_KeyboardEvent &key )
+{
+ if ( key.type == SDL_KEYDOWN )
+ {
+ if ( key.keysym.sym == SDLK_SPACE )
+ parent->changeState( STATE_MENU );
+ else if ( key.keysym.sym == SDLK_DOWN )
+ textSpeed = 5;
+ else if ( key.keysym.sym == SDLK_UP )
+ {
+ if ( textSpeed > 0 )
+ textSpeed = 0;
+ else textSpeed = 1;
+ }
+
+ }
+ else if ( key.type == SDL_KEYUP )
+ {
+ if ( key.keysym.sym == SDLK_DOWN )
+ textSpeed = 1;
+ }
+}
+void Help :: init()
+{
+ startPos = 320;
+ currLine = 0;
+ textSpeed = 1;
+
+ // Create our coloured font
+ FontHandler :: changeColor( FONT_HELP_FONT, 0, 0, 255 );
+}
+
+void Help :: draw( SDL_Surface *screen )
+{
+ stars->draw( screen );
+
+ list<string>::iterator it = textList.begin();
+
+ // Move to start of text
+ for ( int i = 0 ; i < currLine && it != textList.end() ; ++i )
+ it++;
+
+ int pos = startPos;
+ while ( pos < 320 && it != textList.end() )
+ {
+ // get next line
+ string text = *it;
+
+ // draw text
+ FontHandler::draw( screen, FONT_COLOURED_TEXT, text.c_str(), -1, pos );
+ pos += FontHandler::FontHeight( FONT_COLOURED_TEXT );
+ it ++;
+ }
+
+}
+
+void Help :: update()
+{
+ stars->move();
+
+ startPos -= textSpeed;
+ if ( startPos <= -FontHandler::FontHeight( FONT_COLOURED_TEXT ) )
+ {
+ startPos = 0;
+ currLine ++;
+
+ if ( currLine > textList.size() )
+ {
+ startPos = 320;
+ currLine = 0;
+ }
+ }
+
+}
+
+void Help :: loadText()
+{
+ textList.push_back( "SFCave" );
+ textList.push_back( "Written By AndyQ" );
+ textList.push_back( "" );
+ textList.push_back( "Instructions" );
+ textList.push_back( "To return to the menu" );
+ textList.push_back( "press the space or " );
+ textList.push_back( "middle button." );
+ textList.push_back( "" );
+ textList.push_back( "To speed up the text" );
+ textList.push_back( "hold the down button" );
+ textList.push_back( "(releasing will return" );
+ textList.push_back( "to normal speed)" );
+ textList.push_back( "" );
+ textList.push_back( "" );
+ textList.push_back( "SFCave is a flying game" );
+ textList.push_back( "writtin originally for the" );
+ textList.push_back( "Sharp Zaurus." );
+ textList.push_back( "" );
+ textList.push_back( "The aim is to stay alive" );
+ textList.push_back( "for as long as possible," );
+ textList.push_back( "and get the highest score" );
+ textList.push_back( "you can." );
+ textList.push_back( "" );
+ textList.push_back( "There are currently three" );
+ textList.push_back( "game types - SFCave," );
+ textList.push_back( "Gates, and Fly." );
+ textList.push_back( "" );
+ textList.push_back( "SFCave is a remake of" );
+ textList.push_back( "the classic SFCave game." );
+ textList.push_back( "Fly through the cavern" );
+ textList.push_back( "avoiding all the blocks" );
+ textList.push_back( "that just happen to be" );
+ textList.push_back( "hanging in mid-air" );
+ textList.push_back( "" );
+ textList.push_back( "Gates is similar to" );
+ textList.push_back( "SFCave but instead of" );
+ textList.push_back( "avoiding blocks you must" );
+ textList.push_back( "fly through gates without" );
+ textList.push_back( "crashing." );
+ textList.push_back( "" );
+ textList.push_back( "Fly is a different kettle of" );
+ textList.push_back( "fish altogether. Instead," );
+ textList.push_back( "you are flying in the " );
+ textList.push_back( "open air above a" );
+ textList.push_back( "scrolling landscape and" );
+ textList.push_back( "the aim is to fly as close" );
+ textList.push_back( "to the land as possible." );
+ textList.push_back( "The closer to the land" );
+ textList.push_back( "you fly the more points" );
+ textList.push_back( "you score. But beware," );
+ textList.push_back( "fly too high above the" );
+ textList.push_back( "land and points get" );
+ textList.push_back( "deducted." );
+ textList.push_back( "" );
+ textList.push_back( "How to play" );
+ textList.push_back( "Press the space or middle" );
+ textList.push_back( "button (Zaurus only) to " );
+ textList.push_back( "apply thrust (makes you" );
+ textList.push_back( "go up) and release it" );
+ textList.push_back( "to go down." );
+ textList.push_back( "" );
+ textList.push_back( "Have fun" );
+ textList.push_back( "AndyQ" );
+}
+
+// Test
+#ifdef DEBUG_HELP
+SDL_Surface *screen;
+Help *help;
+
+void go()
+{
+ FontHandler :: init();
+
+ /* Initialize SDL */
+ if ( SDL_Init(SDL_INIT_VIDEO) < 0 )
+ {
+ fprintf(stderr, "Couldn't initialize SDL: %s\n",SDL_GetError());
+ exit(1);
+ }
+ atexit(SDL_Quit);
+
+ int videoflags = SDL_SWSURFACE ;
+
+ if ( (screen=SDL_SetVideoMode(240, 320,32,videoflags)) == NULL )
+ {
+ fprintf(stderr, "Couldn't set %ix%i video mode: %s\n",240,320,SDL_GetError());
+ exit(2);
+ }
+
+ help = new Help();
+
+ bool done = false;
+ while ( !done )
+ {
+ SDL_FillRect( screen, 0, 0 );
+ help->draw( screen );
+ help->update( );
+
+ SDL_Flip( screen );
+
+ SDL_Delay( 10 );
+
+ SDL_Event event;
+ while ( SDL_PollEvent(&event) )
+ {
+ switch (event.type)
+ {
+ case SDL_KEYDOWN:
+ // Escape keypress quits the app
+ if ( event.key.keysym.sym != SDLK_ESCAPE )
+ {
+ break;
+ }
+ case SDL_QUIT:
+ done = 1;
+ break;
+ default:
+ break;
+ }
+ }
+ }
+ }
+
+
+
+
+#ifdef __cplusplus
+extern "C"
+#endif
+int main( int argc, char *argv[] )
+{
+ go();
+}
+
+#endif
diff --git a/noncore/games/sfcave-sdl/help.h b/noncore/games/sfcave-sdl/help.h
index dc9e80e..2cc32cd 100644
--- a/noncore/games/sfcave-sdl/help.h
+++ b/noncore/games/sfcave-sdl/help.h
@@ -1,35 +1,35 @@
-
-#ifndef __HELP_H
-#define __help_h
-
-#include <list>
-#include <string>
-using namespace std;
-
-class SFCave;
-class StarField;
-
-class Help
-{
-public:
- Help( SFCave *p );
- ~Help();
-
- void init();
- void handleKeys( SDL_KeyboardEvent &key );
- void draw( SDL_Surface *screen );
- void update();
-private:
-
- SFCave *parent;
- StarField *stars;
-
- int textSpeed;
- list<string> textList;
- int startPos;
- int currLine;
-
- void loadText();
-};
-
-#endif
+
+#ifndef __HELP_H
+#define __help_h
+
+#include <list>
+#include <string>
+using namespace std;
+
+class SFCave;
+class StarField;
+
+class Help
+{
+public:
+ Help( SFCave *p );
+ ~Help();
+
+ void init();
+ void handleKeys( SDL_KeyboardEvent &key );
+ void draw( SDL_Surface *screen );
+ void update();
+private:
+
+ SFCave *parent;
+ StarField *stars;
+
+ int textSpeed;
+ list<string> textList;
+ int startPos;
+ int currLine;
+
+ void loadText();
+};
+
+#endif
diff --git a/noncore/games/sfcave-sdl/menu.cpp b/noncore/games/sfcave-sdl/menu.cpp
index a4a4216..fb2a635 100644
--- a/noncore/games/sfcave-sdl/menu.cpp
+++ b/noncore/games/sfcave-sdl/menu.cpp
@@ -1,6 +1,6 @@
-#include <SDL_image.h>
-#include "SDL_rotozoom.h"
+#include <SDL/SDL_image.h>
+#include <SDL/SDL_rotozoom.h>
#include "constants.h"
#include "sfcave.h"
#include "game.h"
diff --git a/noncore/games/sfcave-sdl/menu.h b/noncore/games/sfcave-sdl/menu.h
index 6a5ef40..c263bcc 100644
--- a/noncore/games/sfcave-sdl/menu.h
+++ b/noncore/games/sfcave-sdl/menu.h
@@ -3,9 +3,9 @@
#include <list>
using namespace std;
-#include <SDL.h>
+#include <SDL/SDL.h>
class SFCave;
class StarField;
class Menu;
diff --git a/noncore/games/sfcave-sdl/player.cpp b/noncore/games/sfcave-sdl/player.cpp
index f024d6b..b491e53 100644
--- a/noncore/games/sfcave-sdl/player.cpp
+++ b/noncore/games/sfcave-sdl/player.cpp
@@ -1,6 +1,6 @@
-#include <SDL.h>
-#include "SDL_gfxPrimitives.h"
+#include <SDL/SDL.h>
+#include <SDL/SDL_gfxPrimitives.h>
#include "constants.h"
#include "player.h"
#include "random.h"
diff --git a/noncore/games/sfcave-sdl/rect.h b/noncore/games/sfcave-sdl/rect.h
index dc9c9d5..30f082c 100644
--- a/noncore/games/sfcave-sdl/rect.h
+++ b/noncore/games/sfcave-sdl/rect.h
@@ -1,61 +1,61 @@
-#ifndef __RECT_H
-#define __RECT_H
-
-#include "SDL.h"
-
-class Rect
-{
-public:
- Rect() { r.x = r.y = r.w = r.h = 0; }
- Rect( int x, int y, int w, int h ) { setRect( x, y, w, h ); }
- ~Rect() {}
-
- void setRect( int x, int y, int w, int h ) { r.x = x; r.y = y; r.w = w; r.h = h; }
- SDL_Rect getRect() { return r; }
- int x() { return r.x; }
- int y() { return r.y; }
- int w() { return r.w; }
- int h() { return r.h; }
-
- void x( int x) { r.x = x; }
- void y( int y) { r.y = y; }
- void w( int w) { r.w = w; }
- void h( int h) { r.h = h; }
-
- void moveBy( int x, int y )
- {
- r.x += x;
- r.y += y;
- }
-
- bool intersects( Rect r2 )
- {
- int tw = r.w;
- int th = r.h;
- int rw = r2.w();
- int rh = r2.h();
- if (rw <= 0 || rh <= 0 || tw <= 0 || th <= 0) {
- return false;
- }
- int tx = r.x;
- int ty = r.y;
- int rx = r2.x();
- int ry = r2.y();
- rw += rx;
- rh += ry;
- tw += tx;
- th += ty;
-
- // overflow || intersect
- return ((rw < rx || rw > tx) &&
- (rh < ry || rh > ty) &&
- (tw < tx || tw > rx) &&
- (th < ty || th > ry));
- }
-
-private:
- SDL_Rect r;
-};
-
-#endif
-
+#ifndef __RECT_H
+#define __RECT_H
+
+#include <SDL/SDL.h>
+
+class Rect
+{
+public:
+ Rect() { r.x = r.y = r.w = r.h = 0; }
+ Rect( int x, int y, int w, int h ) { setRect( x, y, w, h ); }
+ ~Rect() {}
+
+ void setRect( int x, int y, int w, int h ) { r.x = x; r.y = y; r.w = w; r.h = h; }
+ SDL_Rect getRect() { return r; }
+ int x() { return r.x; }
+ int y() { return r.y; }
+ int w() { return r.w; }
+ int h() { return r.h; }
+
+ void x( int x) { r.x = x; }
+ void y( int y) { r.y = y; }
+ void w( int w) { r.w = w; }
+ void h( int h) { r.h = h; }
+
+ void moveBy( int x, int y )
+ {
+ r.x += x;
+ r.y += y;
+ }
+
+ bool intersects( Rect r2 )
+ {
+ int tw = r.w;
+ int th = r.h;
+ int rw = r2.w();
+ int rh = r2.h();
+ if (rw <= 0 || rh <= 0 || tw <= 0 || th <= 0) {
+ return false;
+ }
+ int tx = r.x;
+ int ty = r.y;
+ int rx = r2.x();
+ int ry = r2.y();
+ rw += rx;
+ rh += ry;
+ tw += tx;
+ th += ty;
+
+ // overflow || intersect
+ return ((rw < rx || rw > tx) &&
+ (rh < ry || rh > ty) &&
+ (tw < tx || tw > rx) &&
+ (th < ty || th > ry));
+ }
+
+private:
+ SDL_Rect r;
+};
+
+#endif
+
diff --git a/noncore/games/sfcave-sdl/sfcave-sdl.pro b/noncore/games/sfcave-sdl/sfcave-sdl.pro
index a4eb918..a02eeb3 100644
--- a/noncore/games/sfcave-sdl/sfcave-sdl.pro
+++ b/noncore/games/sfcave-sdl/sfcave-sdl.pro
@@ -1,55 +1,55 @@
-TEMPLATE = app
-CONFIG += qt warn_on release
-DESTDIR = $(OPIEDIR)/bin
-TARGET = sfcave-sdl
-
-DEFINES = _REENTRANT main=SDL_main
-
-INCLUDEPATH += $(OPIEDIR)/include
-INCLUDEPATH += $(OPIEDIR)/include/SDL
-DEPENDPATH += $(OPIEDIR)/include
-
-LIBS += -lqpe -L${SDLDIR}/lib -lSDL -lSDLmain -lSDL_gfx -lSDL_image -lSDL_mixer -lstdc++
-
-SOURCES = animatedimage.cpp \
- bfont.cpp \
- font.cpp \
- game.cpp \
- menu.cpp \
- help.cpp \
- player.cpp \
- random.cpp \
- sfcave.cpp \
- sfcave_game.cpp \
- gates_game.cpp \
- fly_game.cpp \
- flyterrain.cpp \
- sound.cpp \
- terrain.cpp \
- settings.cpp \
- starfield.cpp \
- util.cpp
-
-HEADERS = animatedimage.h \
- bfont.h \
- constants.h \
- font.h \
- game.h \
- menu.h \
- player.h \
- random.h \
- rect.h \
- sfcave.h \
- help.h \
- sfcave_game.h \
- gates_game.h \
- fly_game.h \
- flyterrain.h \
- sound.h \
- terrain.h \
- stringtokenizer.h \
- settings.h \
- starfield.h \
- util.h
-
+TEMPLATE = app
+CONFIG += qt warn_on release
+DESTDIR = $(OPIEDIR)/bin
+TARGET = sfcave-sdl
+
+DEFINES = _REENTRANT main=SDL_main
+
+INCLUDEPATH += $(OPIEDIR)/include
+INCLUDEPATH += $(OPIEDIR)/include/SDL
+DEPENDPATH += $(OPIEDIR)/include
+
+LIBS += -lqpe -L${SDLDIR}/lib -lSDL -lSDLmain -lSDL_gfx -lSDL_image -lSDL_mixer -lstdc++
+
+SOURCES = animatedimage.cpp \
+ bfont.cpp \
+ font.cpp \
+ game.cpp \
+ menu.cpp \
+ help.cpp \
+ player.cpp \
+ random.cpp \
+ sfcave.cpp \
+ sfcave_game.cpp \
+ gates_game.cpp \
+ fly_game.cpp \
+ flyterrain.cpp \
+ sound.cpp \
+ terrain.cpp \
+ settings.cpp \
+ starfield.cpp \
+ util.cpp
+
+HEADERS = animatedimage.h \
+ bfont.h \
+ constants.h \
+ font.h \
+ game.h \
+ menu.h \
+ player.h \
+ random.h \
+ rect.h \
+ sfcave.h \
+ help.h \
+ sfcave_game.h \
+ gates_game.h \
+ fly_game.h \
+ flyterrain.h \
+ sound.h \
+ terrain.h \
+ stringtokenizer.h \
+ settings.h \
+ starfield.h \
+ util.h
+
include ( $(OPIEDIR)/include.pro ) \ No newline at end of file
diff --git a/noncore/games/sfcave-sdl/sfcave.cpp b/noncore/games/sfcave-sdl/sfcave.cpp
index dbd788c..5d1cdd5 100644
--- a/noncore/games/sfcave-sdl/sfcave.cpp
+++ b/noncore/games/sfcave-sdl/sfcave.cpp
@@ -3,10 +3,10 @@
#include <time.h>
#include <sys/timeb.h>
-#include "SDL.h"
-#include "SDL_gfxPrimitives.h"
+#include <SDL/SDL.h>
+#include <SDL/SDL_gfxPrimitives.h>
#include "constants.h"
#include "sound.h"
diff --git a/noncore/games/sfcave-sdl/sfcave.h b/noncore/games/sfcave-sdl/sfcave.h
index c707919..4e45ec2 100644
--- a/noncore/games/sfcave-sdl/sfcave.h
+++ b/noncore/games/sfcave-sdl/sfcave.h
@@ -1,8 +1,8 @@
#ifndef __SFCAVE_H
#define __SFCAVE_H
-#include "SDL.h"
+#include <SDL/SDL.h>
#include "terrain.h"
class Game;
diff --git a/noncore/games/sfcave-sdl/sfcave_game.cpp b/noncore/games/sfcave-sdl/sfcave_game.cpp
index 8fdbbe5..ccdd625 100644
--- a/noncore/games/sfcave-sdl/sfcave_game.cpp
+++ b/noncore/games/sfcave-sdl/sfcave_game.cpp
@@ -1,5 +1,5 @@
-#include "SDL_gfxPrimitives.h"
+#include <SDL/SDL_gfxPrimitives.h>
#include "constants.h"
#include "sfcave_game.h"
#include "random.h"
diff --git a/noncore/games/sfcave-sdl/sfcave_game.h b/noncore/games/sfcave-sdl/sfcave_game.h
index 92a0f5d..6dddf5e 100644
--- a/noncore/games/sfcave-sdl/sfcave_game.h
+++ b/noncore/games/sfcave-sdl/sfcave_game.h
@@ -1,8 +1,8 @@
#ifndef __SFCAVE_GAME_H
#define __SFCAVE_GAME_H
-#include "SDL.h"
+#include <SDL/SDL.h>
#include "rect.h"
#include "sfcave.h"
diff --git a/noncore/games/sfcave-sdl/sound.cpp b/noncore/games/sfcave-sdl/sound.cpp
index 855f2e6..0be1abf 100644
--- a/noncore/games/sfcave-sdl/sound.cpp
+++ b/noncore/games/sfcave-sdl/sound.cpp
@@ -1,157 +1,157 @@
-#include "constants.h"
-#include "sound.h"
-
-Mix_Chunk *SoundHandler :: sounds[NR_SOUNDS];
-Mix_Music *SoundHandler :: music;
-int SoundHandler :: soundChannels[NR_SOUNDS];
-bool SoundHandler :: soundOn;
-bool SoundHandler :: musicOn;
-
-bool SoundHandler :: init( )
-{
- // We're going to be requesting certain things from our audio
- // device, so we set them up beforehand
- int audio_rate = 22050;
- Uint16 audio_format = AUDIO_S16; //AUDIO_S16; /* 16-bit stereo */
- int audio_channels = 2;
- int audio_buffers = 1024;//4096;
-
- // This is where we open up our audio device. Mix_OpenAudio takes
- // as its parameters the audio format we'd /like/ to have.
- if(Mix_OpenAudio(audio_rate, audio_format, audio_channels, audio_buffers))
- {
- printf("Unable to open audio!\n");
- return false;
- }
-
- // We're going to pre-load the sound effects that we need right here
- sounds[SND_EXPLOSION] = Mix_LoadWAV( SOUND_PATH "explosion.wav");
- sounds[SND_THRUST] = Mix_LoadWAV( SOUND_PATH "thrust.wav");
-
- music = 0;
-
- soundOn = true;
- musicOn = true;
-
- return true;
-}
-
-void SoundHandler :: cleanUp()
-{
- // Free audio sounds
- if ( sounds[SND_EXPLOSION] )
- Mix_FreeChunk( sounds[SND_EXPLOSION] );
- if ( sounds[SND_THRUST] )
- Mix_FreeChunk( sounds[SND_THRUST] );
-
- if ( music )
- Mix_FreeMusic( music );
-
- Mix_CloseAudio();
-}
-
-int SoundHandler :: playSound( int soundNr, int channel, int nrLoops, int playBeforeFinished )
-{
- if ( !soundOn )
- return -1;
-
- if ( soundNr >= NR_SOUNDS || !sounds[soundNr] )
- return -1;
-
- Mix_Chunk *chunk = sounds[soundNr];
- if( channel == -1 || !Mix_Playing( channel ) )
- channel = Mix_PlayChannel(-1, sounds[soundNr], nrLoops);
-
- Mix_Volume( channel, MIX_MAX_VOLUME );
- return channel;
-}
-
-void SoundHandler :: stopSound( int channel, bool fadeOut, int nrMilliSecs )
-{
- if ( !soundOn )
- return;
-
- if ( !fadeOut )
- Mix_HaltChannel( channel );
- else
- {
- Mix_FadeOutChannel( channel, nrMilliSecs );
- }
-}
-
-void SoundHandler :: playMusic( string musicFile )
-{
- if ( !soundOn )
- return;
-
- // If music already exists - stop it playing if necessary and free it up
- if ( music )
- {
- stopMusic();
- Mix_FreeMusic( music );
- }
-
- // Load music
- music = Mix_LoadMUS( musicFile.c_str() );
- if(!music)
- {
- printf("Mix_LoadMUS(%s): %s\n", musicFile.c_str(), Mix_GetError());
- // this might be a critical error...
- }
-
- playMusic();
-}
-
-void SoundHandler :: playMusic( bool fade )
-{
- if ( !musicOn )
- return;
-
- if ( music )
- {
- Mix_VolumeMusic( MIX_MAX_VOLUME );
- Mix_RewindMusic();
-
- if ( fade )
- Mix_FadeInMusic( music, -1, 1000 );
- else
- Mix_PlayMusic( music, -1 );
-
- }
-}
-
-void SoundHandler :: stopMusic( bool fadeOut )
-{
- if ( !music || !Mix_PlayingMusic() )
- return;
-
- if ( fadeOut && Mix_FadingMusic() == MIX_NO_FADING )
- {
- Mix_FadeOutMusic( 1000 );
- }
- else
- {
- Mix_HaltMusic();
- }
-
-}
-
-void SoundHandler :: setMusicVolume( int vol )
-{
- Mix_VolumeMusic( vol );
-}
-
-void SoundHandler :: setSoundsOn( bool val )
-{
- soundOn = val;
-}
-
-void SoundHandler :: setMusicOn( bool val )
-{
- musicOn = val;
-
- if ( !musicOn )
- stopMusic();
- else
- playMusic( true );
-}
+#include "constants.h"
+#include "sound.h"
+
+Mix_Chunk *SoundHandler :: sounds[NR_SOUNDS];
+Mix_Music *SoundHandler :: music;
+int SoundHandler :: soundChannels[NR_SOUNDS];
+bool SoundHandler :: soundOn;
+bool SoundHandler :: musicOn;
+
+bool SoundHandler :: init( )
+{
+ // We're going to be requesting certain things from our audio
+ // device, so we set them up beforehand
+ int audio_rate = 22050;
+ Uint16 audio_format = AUDIO_S16; //AUDIO_S16; /* 16-bit stereo */
+ int audio_channels = 2;
+ int audio_buffers = 1024;//4096;
+
+ // This is where we open up our audio device. Mix_OpenAudio takes
+ // as its parameters the audio format we'd /like/ to have.
+ if(Mix_OpenAudio(audio_rate, audio_format, audio_channels, audio_buffers))
+ {
+ printf("Unable to open audio!\n");
+ return false;
+ }
+
+ // We're going to pre-load the sound effects that we need right here
+ sounds[SND_EXPLOSION] = Mix_LoadWAV( SOUND_PATH "explosion.wav");
+ sounds[SND_THRUST] = Mix_LoadWAV( SOUND_PATH "thrust.wav");
+
+ music = 0;
+
+ soundOn = true;
+ musicOn = true;
+
+ return true;
+}
+
+void SoundHandler :: cleanUp()
+{
+ // Free audio sounds
+ if ( sounds[SND_EXPLOSION] )
+ Mix_FreeChunk( sounds[SND_EXPLOSION] );
+ if ( sounds[SND_THRUST] )
+ Mix_FreeChunk( sounds[SND_THRUST] );
+
+ if ( music )
+ Mix_FreeMusic( music );
+
+ Mix_CloseAudio();
+}
+
+int SoundHandler :: playSound( int soundNr, int channel, int nrLoops, int playBeforeFinished )
+{
+ if ( !soundOn )
+ return -1;
+
+ if ( soundNr >= NR_SOUNDS || !sounds[soundNr] )
+ return -1;
+
+ Mix_Chunk *chunk = sounds[soundNr];
+ if( channel == -1 || !Mix_Playing( channel ) )
+ channel = Mix_PlayChannel(-1, sounds[soundNr], nrLoops);
+
+ Mix_Volume( channel, MIX_MAX_VOLUME );
+ return channel;
+}
+
+void SoundHandler :: stopSound( int channel, bool fadeOut, int nrMilliSecs )
+{
+ if ( !soundOn )
+ return;
+
+ if ( !fadeOut )
+ Mix_HaltChannel( channel );
+ else
+ {
+ Mix_FadeOutChannel( channel, nrMilliSecs );
+ }
+}
+
+void SoundHandler :: playMusic( string musicFile )
+{
+ if ( !soundOn )
+ return;
+
+ // If music already exists - stop it playing if necessary and free it up
+ if ( music )
+ {
+ stopMusic();
+ Mix_FreeMusic( music );
+ }
+
+ // Load music
+ music = Mix_LoadMUS( musicFile.c_str() );
+ if(!music)
+ {
+ printf("Mix_LoadMUS(%s): %s\n", musicFile.c_str(), Mix_GetError());
+ // this might be a critical error...
+ }
+
+ playMusic();
+}
+
+void SoundHandler :: playMusic( bool fade )
+{
+ if ( !musicOn )
+ return;
+
+ if ( music )
+ {
+ Mix_VolumeMusic( MIX_MAX_VOLUME );
+ Mix_RewindMusic();
+
+ if ( fade )
+ Mix_FadeInMusic( music, -1, 1000 );
+ else
+ Mix_PlayMusic( music, -1 );
+
+ }
+}
+
+void SoundHandler :: stopMusic( bool fadeOut )
+{
+ if ( !music || !Mix_PlayingMusic() )
+ return;
+
+ if ( fadeOut && Mix_FadingMusic() == MIX_NO_FADING )
+ {
+ Mix_FadeOutMusic( 1000 );
+ }
+ else
+ {
+ Mix_HaltMusic();
+ }
+
+}
+
+void SoundHandler :: setMusicVolume( int vol )
+{
+ Mix_VolumeMusic( vol );
+}
+
+void SoundHandler :: setSoundsOn( bool val )
+{
+ soundOn = val;
+}
+
+void SoundHandler :: setMusicOn( bool val )
+{
+ musicOn = val;
+
+ if ( !musicOn )
+ stopMusic();
+ else
+ playMusic( true );
+}
diff --git a/noncore/games/sfcave-sdl/sound.h b/noncore/games/sfcave-sdl/sound.h
index d46b5bc..180429a 100644
--- a/noncore/games/sfcave-sdl/sound.h
+++ b/noncore/games/sfcave-sdl/sound.h
@@ -1,35 +1,35 @@
-#ifndef __SOUND_H
-#define __SOUND_H
-
-#include <SDL.h>
-#include "SDL_mixer.h"
-
-#define NR_SOUNDS 3
-
-class SoundHandler
-{
-public:
- static bool init();
- static void cleanUp();
-
- static int playSound( int soundNr, int channel = -1, int nrLoops = 0, int playBeforeFinished = false );
- static void stopSound( int channel, bool fadeOut, int nrMilliSecs = 1000 );
- static void setSoundsOn( bool val );
- static void setMusicOn( bool val );
- static void playMusic( string musicFile );
- static void playMusic( bool fadeIn = false );
- static void stopMusic( bool fadeOut = false );
- static void setMusicVolume( int vol );
-
-
-private:
- static Mix_Music *music;
- static Mix_Chunk *sounds[NR_SOUNDS];
- static int soundChannels[NR_SOUNDS];
- static bool soundOn;
- static bool musicOn;
-
- SoundHandler() {}
-};
-
-#endif
+#ifndef __SOUND_H
+#define __SOUND_H
+
+#include <SDL/SDL.h>
+#include <SDL/SDL_mixer.h>
+
+#define NR_SOUNDS 3
+
+class SoundHandler
+{
+public:
+ static bool init();
+ static void cleanUp();
+
+ static int playSound( int soundNr, int channel = -1, int nrLoops = 0, int playBeforeFinished = false );
+ static void stopSound( int channel, bool fadeOut, int nrMilliSecs = 1000 );
+ static void setSoundsOn( bool val );
+ static void setMusicOn( bool val );
+ static void playMusic( string musicFile );
+ static void playMusic( bool fadeIn = false );
+ static void stopMusic( bool fadeOut = false );
+ static void setMusicVolume( int vol );
+
+
+private:
+ static Mix_Music *music;
+ static Mix_Chunk *sounds[NR_SOUNDS];
+ static int soundChannels[NR_SOUNDS];
+ static bool soundOn;
+ static bool musicOn;
+
+ SoundHandler() {}
+};
+
+#endif
diff --git a/noncore/games/sfcave-sdl/starfield.cpp b/noncore/games/sfcave-sdl/starfield.cpp
index 82edfc1..3b26895 100644
--- a/noncore/games/sfcave-sdl/starfield.cpp
+++ b/noncore/games/sfcave-sdl/starfield.cpp
@@ -1,295 +1,295 @@
-#include "SDL.h"
-#include "SDL_gfxPrimitives.h"
-
-#include <stdlib.h>
-
-#include "starfield.h"
-#include "random.h"
-#include "util.h"
-
-#define VERTICAL_VELOCITY 0
-
-StarField :: StarField( bool side, int nStars, int mx, int my, int minz, int maxz )
-{
- nrStars = nStars;
- maxX = mx;
- maxY = my;
- minZ = minz;
- maxZ = maxz;
-
- min_brightness = 50;
- top_star_speed = 6;
-
- sideways = side;
-
- if ( !sideways )
- {
- x = new int[nrStars];
- y = new int[nrStars];
- z = new int[nrStars];
-
- star_color = 0;
- vel_x = 0;
- vel_y = 0;
- pos_x = 0;
- pos_y = 0;
- }
- else
- {
- star_color = new int[nrStars];
- vel_x = new int[nrStars];
- vel_y = new int[nrStars];
- pos_x = new int[nrStars];
- pos_y = new int[nrStars];
-
- x = 0;
- y = 0;
- z = 0;
- }
-
- init();
-}
-
-StarField :: ~StarField()
-{
- if ( star_color )
- delete []star_color;
- if ( vel_x )
- delete []vel_x;
- if ( vel_y )
- delete []vel_y;
- if ( pos_x )
- delete []pos_x;
- if ( pos_y )
- delete []pos_y;
-
- if ( x )
- delete []x;
- if ( y )
- delete []y;
- if ( z )
- delete []z;
-}
-
-void StarField :: init()
-{
- if ( !sideways )
- {
- for ( int i = 0 ; i < nrStars ; ++i )
- {
- newStar( i );
- z[i] = (int)(Random() * (double)(maxZ - minZ)) + minZ ;
- }
- }
- else
- {
- int brightness;
-
- //Initialise each star
- for(int i = 0; i < nrStars ; i++)
- {
- //Inialise velocities
- vel_x[i] = -(int)floor( (Random() * top_star_speed)+1 );
- vel_y[i] = VERTICAL_VELOCITY;
-
- //Initialise positions randomly
- pos_x[i] = (int)floor((Random() * 240));
- pos_y[i] = (int)floor((Random() * 320));
-
- //The Faster it goes, the Dimmer it is
- if (vel_x[i] != 0)
- {
- brightness = (int)(255 / fabs(vel_x[i]) );
- if (brightness < min_brightness)
- brightness = min_brightness;
- }
- else
- brightness = 255;
-
- star_color[i] = brightness;
- }
- }
-}
-
-void StarField :: newStar( int starNr )
-{
- if ( !sideways )
- {
- x[starNr] = (int)(Random() * (double)maxX) + 1;
- y[starNr] = (int)(Random() * (double)maxY) + 1;
- z[starNr] = maxZ;
-
- int i = (int)(Random() * 4.0);
- if(i < 2)
- x[starNr] = -x[starNr];
- if(i == 0 || i == 2)
- y[starNr] = -y[starNr];
- }
-}
-
-void StarField :: move( )
-{
- if ( !sideways )
- {
- int amountToMove = 16;
- for(int i = 0; i < nrStars; i++)
- {
- // Rotate star
- z[i] = z[i] - amountToMove;
- if(z[i] < minZ)
- newStar(i);
- }
- }
- else
- {
- for(int i = 0; i < nrStars ; i++)
- {
- //Check speed limits x
- if (vel_x[i] > top_star_speed)
- vel_x[i] = top_star_speed;
- else if (vel_x[i] < -top_star_speed)
- vel_x[i] = -top_star_speed;
-
- //Check speed limits y
- if (vel_y[i] > top_star_speed)
- vel_y[i] = top_star_speed;
- else if (vel_y[i] < -top_star_speed)
- vel_y[i] = -top_star_speed;
-
-
-
- //Move Star
- pos_x[i] += vel_x[i];
- pos_y[i] += vel_y[i];
-
- if (pos_x[i] < 0)
- pos_x[i] = pos_x[i] + 240;
-
- if (pos_x[i] > 240)
- pos_x[i] = pos_x[i] - 240;
- if (pos_y[i] < 0)
- pos_y[i] = pos_y[i] + 320;
-
- if (pos_y[i] > 320)
- pos_y[i] = pos_y[i] - 320;
- }
- }
-}
-
-void StarField :: draw( SDL_Surface *screen, int w, int h )
-{
- if ( !sideways )
- {
- int scrW = w / 2;
- int scrH = h / 2;
- for(int i = 0; i < nrStars; i++)
- {
- int sx = (x[i] * 256) / z[i] + scrW;
- int sy = (y[i] * 256) / z[i] + scrH;
- if(sx < 0 || sx > w || sy < 0 || sy > h)
- {
- newStar(i);
- }
- else
- {
- int size = (z[i] * 3) / maxZ;
-
- SDL_Rect r;
- r.x = sx;
- r.y = sy;
- r.w = 3 - size;
- r.h = 3 - size;
-
- SDL_FillRect( screen, &r, SDL_MapRGB( screen->format, 255, 255, 255 ) );
- }
- }
- }
- else
- {
- SDL_LockSurface( screen );
- for(int i = 0; i < nrStars ; i++)
- {
-
- Uint32 c = getpixel( screen, pos_x[i], pos_y[i] );
-
-
- if ( c == 0 )
- lineRGBA( screen, pos_x[i], pos_y[i], pos_x [i]+ vel_x[i], pos_y[i] + vel_y[i], star_color[i], star_color[i], star_color[i], 255 );
-
- //*** NOTE : if the velocity of the stars never changes then the values such as 'pos_x[i] + vel_x[i]' could be precalculated for each star ***
- }
- SDL_UnlockSurface( screen );
- }
-}
-
-
-
-// Test
-#ifdef DEBUG_STARS
-SDL_Surface *screen;
-StarField *stars;
-
-void go()
-{
- /* Initialize SDL */
- if ( SDL_Init(SDL_INIT_VIDEO) < 0 )
- {
- fprintf(stderr, "Couldn't initialize SDL: %s\n",SDL_GetError());
- exit(1);
- }
- atexit(SDL_Quit);
-
- int videoflags = SDL_SWSURFACE ;
-
- if ( (screen=SDL_SetVideoMode(240, 320,32,videoflags)) == NULL )
- {
- fprintf(stderr, "Couldn't set %ix%i video mode: %s\n",240,320,SDL_GetError());
- exit(2);
- }
-
- stars = new StarField( false, 200 );
-
- bool done = false;
- while ( !done )
- {
- SDL_FillRect( screen, 0, 0 );
- stars->draw( screen );
- stars->move( );
-
- SDL_Flip( screen );
-
- SDL_Delay( 10 );
-
- SDL_Event event;
- while ( SDL_PollEvent(&event) )
- {
- switch (event.type)
- {
- case SDL_KEYDOWN:
- // Escape keypress quits the app
- if ( event.key.keysym.sym != SDLK_ESCAPE )
- {
- break;
- }
- case SDL_QUIT:
- done = 1;
- break;
- default:
- break;
- }
- }
- }
- }
-
-
-
-
-#ifdef __cplusplus
-extern "C"
-#endif
-int main( int argc, char *argv[] )
-{
- go();
-}
-
-#endif
+#include <SDL/SDL.h>
+#include <SDL/SDL_gfxPrimitives.h>
+
+#include <stdlib.h>
+
+#include "starfield.h"
+#include "random.h"
+#include "util.h"
+
+#define VERTICAL_VELOCITY 0
+
+StarField :: StarField( bool side, int nStars, int mx, int my, int minz, int maxz )
+{
+ nrStars = nStars;
+ maxX = mx;
+ maxY = my;
+ minZ = minz;
+ maxZ = maxz;
+
+ min_brightness = 50;
+ top_star_speed = 6;
+
+ sideways = side;
+
+ if ( !sideways )
+ {
+ x = new int[nrStars];
+ y = new int[nrStars];
+ z = new int[nrStars];
+
+ star_color = 0;
+ vel_x = 0;
+ vel_y = 0;
+ pos_x = 0;
+ pos_y = 0;
+ }
+ else
+ {
+ star_color = new int[nrStars];
+ vel_x = new int[nrStars];
+ vel_y = new int[nrStars];
+ pos_x = new int[nrStars];
+ pos_y = new int[nrStars];
+
+ x = 0;
+ y = 0;
+ z = 0;
+ }
+
+ init();
+}
+
+StarField :: ~StarField()
+{
+ if ( star_color )
+ delete []star_color;
+ if ( vel_x )
+ delete []vel_x;
+ if ( vel_y )
+ delete []vel_y;
+ if ( pos_x )
+ delete []pos_x;
+ if ( pos_y )
+ delete []pos_y;
+
+ if ( x )
+ delete []x;
+ if ( y )
+ delete []y;
+ if ( z )
+ delete []z;
+}
+
+void StarField :: init()
+{
+ if ( !sideways )
+ {
+ for ( int i = 0 ; i < nrStars ; ++i )
+ {
+ newStar( i );
+ z[i] = (int)(Random() * (double)(maxZ - minZ)) + minZ ;
+ }
+ }
+ else
+ {
+ int brightness;
+
+ //Initialise each star
+ for(int i = 0; i < nrStars ; i++)
+ {
+ //Inialise velocities
+ vel_x[i] = -(int)floor( (Random() * top_star_speed)+1 );
+ vel_y[i] = VERTICAL_VELOCITY;
+
+ //Initialise positions randomly
+ pos_x[i] = (int)floor((Random() * 240));
+ pos_y[i] = (int)floor((Random() * 320));
+
+ //The Faster it goes, the Dimmer it is
+ if (vel_x[i] != 0)
+ {
+ brightness = (int)(255 / fabs(vel_x[i]) );
+ if (brightness < min_brightness)
+ brightness = min_brightness;
+ }
+ else
+ brightness = 255;
+
+ star_color[i] = brightness;
+ }
+ }
+}
+
+void StarField :: newStar( int starNr )
+{
+ if ( !sideways )
+ {
+ x[starNr] = (int)(Random() * (double)maxX) + 1;
+ y[starNr] = (int)(Random() * (double)maxY) + 1;
+ z[starNr] = maxZ;
+
+ int i = (int)(Random() * 4.0);
+ if(i < 2)
+ x[starNr] = -x[starNr];
+ if(i == 0 || i == 2)
+ y[starNr] = -y[starNr];
+ }
+}
+
+void StarField :: move( )
+{
+ if ( !sideways )
+ {
+ int amountToMove = 16;
+ for(int i = 0; i < nrStars; i++)
+ {
+ // Rotate star
+ z[i] = z[i] - amountToMove;
+ if(z[i] < minZ)
+ newStar(i);
+ }
+ }
+ else
+ {
+ for(int i = 0; i < nrStars ; i++)
+ {
+ //Check speed limits x
+ if (vel_x[i] > top_star_speed)
+ vel_x[i] = top_star_speed;
+ else if (vel_x[i] < -top_star_speed)
+ vel_x[i] = -top_star_speed;
+
+ //Check speed limits y
+ if (vel_y[i] > top_star_speed)
+ vel_y[i] = top_star_speed;
+ else if (vel_y[i] < -top_star_speed)
+ vel_y[i] = -top_star_speed;
+
+
+
+ //Move Star
+ pos_x[i] += vel_x[i];
+ pos_y[i] += vel_y[i];
+
+ if (pos_x[i] < 0)
+ pos_x[i] = pos_x[i] + 240;
+
+ if (pos_x[i] > 240)
+ pos_x[i] = pos_x[i] - 240;
+ if (pos_y[i] < 0)
+ pos_y[i] = pos_y[i] + 320;
+
+ if (pos_y[i] > 320)
+ pos_y[i] = pos_y[i] - 320;
+ }
+ }
+}
+
+void StarField :: draw( SDL_Surface *screen, int w, int h )
+{
+ if ( !sideways )
+ {
+ int scrW = w / 2;
+ int scrH = h / 2;
+ for(int i = 0; i < nrStars; i++)
+ {
+ int sx = (x[i] * 256) / z[i] + scrW;
+ int sy = (y[i] * 256) / z[i] + scrH;
+ if(sx < 0 || sx > w || sy < 0 || sy > h)
+ {
+ newStar(i);
+ }
+ else
+ {
+ int size = (z[i] * 3) / maxZ;
+
+ SDL_Rect r;
+ r.x = sx;
+ r.y = sy;
+ r.w = 3 - size;
+ r.h = 3 - size;
+
+ SDL_FillRect( screen, &r, SDL_MapRGB( screen->format, 255, 255, 255 ) );
+ }
+ }
+ }
+ else
+ {
+ SDL_LockSurface( screen );
+ for(int i = 0; i < nrStars ; i++)
+ {
+
+ Uint32 c = getpixel( screen, pos_x[i], pos_y[i] );
+
+
+ if ( c == 0 )
+ lineRGBA( screen, pos_x[i], pos_y[i], pos_x [i]+ vel_x[i], pos_y[i] + vel_y[i], star_color[i], star_color[i], star_color[i], 255 );
+
+ //*** NOTE : if the velocity of the stars never changes then the values such as 'pos_x[i] + vel_x[i]' could be precalculated for each star ***
+ }
+ SDL_UnlockSurface( screen );
+ }
+}
+
+
+
+// Test
+#ifdef DEBUG_STARS
+SDL_Surface *screen;
+StarField *stars;
+
+void go()
+{
+ /* Initialize SDL */
+ if ( SDL_Init(SDL_INIT_VIDEO) < 0 )
+ {
+ fprintf(stderr, "Couldn't initialize SDL: %s\n",SDL_GetError());
+ exit(1);
+ }
+ atexit(SDL_Quit);
+
+ int videoflags = SDL_SWSURFACE ;
+
+ if ( (screen=SDL_SetVideoMode(240, 320,32,videoflags)) == NULL )
+ {
+ fprintf(stderr, "Couldn't set %ix%i video mode: %s\n",240,320,SDL_GetError());
+ exit(2);
+ }
+
+ stars = new StarField( false, 200 );
+
+ bool done = false;
+ while ( !done )
+ {
+ SDL_FillRect( screen, 0, 0 );
+ stars->draw( screen );
+ stars->move( );
+
+ SDL_Flip( screen );
+
+ SDL_Delay( 10 );
+
+ SDL_Event event;
+ while ( SDL_PollEvent(&event) )
+ {
+ switch (event.type)
+ {
+ case SDL_KEYDOWN:
+ // Escape keypress quits the app
+ if ( event.key.keysym.sym != SDLK_ESCAPE )
+ {
+ break;
+ }
+ case SDL_QUIT:
+ done = 1;
+ break;
+ default:
+ break;
+ }
+ }
+ }
+ }
+
+
+
+
+#ifdef __cplusplus
+extern "C"
+#endif
+int main( int argc, char *argv[] )
+{
+ go();
+}
+
+#endif
diff --git a/noncore/games/sfcave-sdl/starfield.h b/noncore/games/sfcave-sdl/starfield.h
index ae9bd34..133cb54 100644
--- a/noncore/games/sfcave-sdl/starfield.h
+++ b/noncore/games/sfcave-sdl/starfield.h
@@ -1,41 +1,41 @@
-#ifndef __STARFIELD_H
-#define __STARFIELD_H
-
-class StarField
-{
-public:
- StarField( bool side = false, int nrStars = 100, int mx = 240, int my = 320, int minz = 32, int maxz = 725 );
- ~StarField();
-
- void init();
- void move( );
- void draw( SDL_Surface *screen, int w = 240, int h = 320 );
-
-private:
- // 3d effect
- int *x;
- int *y;
- int *z;
-
- int maxX;
- int maxY;
- int minZ;
- int maxZ;
-
- // Sideways
- int *star_color;
- int *vel_x;
- int *vel_y;
- int *pos_x;
- int *pos_y;
- int min_brightness;
- int top_star_speed;
-
- bool sideways;
- int nrStars;
-
- void newStar( int i );
-};
-
-
-#endif
+#ifndef __STARFIELD_H
+#define __STARFIELD_H
+
+class StarField
+{
+public:
+ StarField( bool side = false, int nrStars = 100, int mx = 240, int my = 320, int minz = 32, int maxz = 725 );
+ ~StarField();
+
+ void init();
+ void move( );
+ void draw( SDL_Surface *screen, int w = 240, int h = 320 );
+
+private:
+ // 3d effect
+ int *x;
+ int *y;
+ int *z;
+
+ int maxX;
+ int maxY;
+ int minZ;
+ int maxZ;
+
+ // Sideways
+ int *star_color;
+ int *vel_x;
+ int *vel_y;
+ int *pos_x;
+ int *pos_y;
+ int min_brightness;
+ int top_star_speed;
+
+ bool sideways;
+ int nrStars;
+
+ void newStar( int i );
+};
+
+
+#endif
diff --git a/noncore/games/sfcave-sdl/stringtokenizer.h b/noncore/games/sfcave-sdl/stringtokenizer.h
index 3f299a6..51daa42 100644
--- a/noncore/games/sfcave-sdl/stringtokenizer.h
+++ b/noncore/games/sfcave-sdl/stringtokenizer.h
@@ -1,23 +1,23 @@
-#ifndef __STRINGTOKENIZER_H
-#define __STRINGTOKENIZER_H
-
-#include <vector>
-using namespace std;
-
-class StringTokenizer : public vector<string>
-{
- public:
- StringTokenizer(const string &rStr, const string &rDelimiters = " ,\n")
- {
- string::size_type lastPos(rStr.find_first_not_of(rDelimiters, 0));
- string::size_type pos(rStr.find_first_of(rDelimiters, lastPos));
- while (string::npos != pos || string::npos != lastPos)
- {
- push_back(rStr.substr(lastPos, pos - lastPos));
- lastPos = rStr.find_first_not_of(rDelimiters, pos);
- pos = rStr.find_first_of(rDelimiters, lastPos);
- }
- }
-};
-
-#endif
+#ifndef __STRINGTOKENIZER_H
+#define __STRINGTOKENIZER_H
+
+#include <vector>
+using namespace std;
+
+class StringTokenizer : public vector<string>
+{
+ public:
+ StringTokenizer(const string &rStr, const string &rDelimiters = " ,\n")
+ {
+ string::size_type lastPos(rStr.find_first_not_of(rDelimiters, 0));
+ string::size_type pos(rStr.find_first_of(rDelimiters, lastPos));
+ while (string::npos != pos || string::npos != lastPos)
+ {
+ push_back(rStr.substr(lastPos, pos - lastPos));
+ lastPos = rStr.find_first_not_of(rDelimiters, pos);
+ pos = rStr.find_first_of(rDelimiters, lastPos);
+ }
+ }
+};
+
+#endif
diff --git a/noncore/games/sfcave-sdl/terrain.cpp b/noncore/games/sfcave-sdl/terrain.cpp
index b243f45..5943275 100644
--- a/noncore/games/sfcave-sdl/terrain.cpp
+++ b/noncore/games/sfcave-sdl/terrain.cpp
@@ -1,7 +1,7 @@
-#include "SDL.h"
-#include "SDL_rotozoom.h"
-#include "SDL_gfxPrimitives.h"
+#include <SDL/SDL.h>
+#include <SDL/SDL_rotozoom.h>
+#include <SDL/SDL_gfxPrimitives.h>
#include "constants.h"
#include "terrain.h"
#include "random.h"
diff --git a/noncore/games/sfcave-sdl/terrain.h b/noncore/games/sfcave-sdl/terrain.h
index 4070318..3cc9691 100644
--- a/noncore/games/sfcave-sdl/terrain.h
+++ b/noncore/games/sfcave-sdl/terrain.h
@@ -1,8 +1,8 @@
#ifndef __TERRAIN_H
#define __TERRAIN_H
-#include <SDL.h>
+#include <SDL/SDL.h>
class StarField;
class Terrain
{
diff --git a/noncore/games/sfcave-sdl/util.cpp b/noncore/games/sfcave-sdl/util.cpp
index f73e256..743f16e 100644
--- a/noncore/games/sfcave-sdl/util.cpp
+++ b/noncore/games/sfcave-sdl/util.cpp
@@ -1,75 +1,75 @@
-#include "SDL.h"
-
-#include <dirent.h>
-
-#include <vector>
-using namespace std;
-
-#include "util.h"
-#include "random.h"
-
-Uint32 getpixel(SDL_Surface *surface, int x, int y)
-{
- int bpp = surface->format->BytesPerPixel;
- /* Here p is the address to the pixel we want to retrieve */
- Uint8 *p = (Uint8 *)surface->pixels + y * surface->pitch + x * bpp;
-
- switch(bpp) {
- case 1:
- return *p;
-
- case 2:
- return *(Uint16 *)p;
-
- case 3:
- if(SDL_BYTEORDER == SDL_BIG_ENDIAN)
- return p[0] << 16 | p[1] << 8 | p[2];
- else
- return p[0] | p[1] << 8 | p[2] << 16;
-
- case 4:
- return *(Uint32 *)p;
-
- default:
- return 0; /* shouldn't happen, but avoids warnings */
- }
-}
-
-string chooseRandomFile( string path, string fileType )
-{
- vector<string> files;
- DIR *d = opendir( path.c_str() );
- if ( !d )
- return "";
-
- struct dirent *item = readdir( d );
- while ( item )
- {
- string file = string( path ) + item->d_name;
-
- // Rip extension from file
- int pos = file.find( ".", 1 ) + 1;
- string tmp = file.substr( pos );
- if ( tmp.size() > 0 && fileType.find( tmp ) != -1 )
- {
- files.push_back( file );
- }
- item = readdir( d );
- }
-
- closedir( d );
- return files[nextInt( files.size() )];
-}
-
-
-string getHomeDir()
-{
- string home;
-#ifdef QWS
- home = getenv( "HOME" );
-#else
- home = ".";
-#endif
-
- return home;
-}
+#include <SDL/SDL.h>
+
+#include <dirent.h>
+
+#include <vector>
+using namespace std;
+
+#include "util.h"
+#include "random.h"
+
+Uint32 getpixel(SDL_Surface *surface, int x, int y)
+{
+ int bpp = surface->format->BytesPerPixel;
+ /* Here p is the address to the pixel we want to retrieve */
+ Uint8 *p = (Uint8 *)surface->pixels + y * surface->pitch + x * bpp;
+
+ switch(bpp) {
+ case 1:
+ return *p;
+
+ case 2:
+ return *(Uint16 *)p;
+
+ case 3:
+ if(SDL_BYTEORDER == SDL_BIG_ENDIAN)
+ return p[0] << 16 | p[1] << 8 | p[2];
+ else
+ return p[0] | p[1] << 8 | p[2] << 16;
+
+ case 4:
+ return *(Uint32 *)p;
+
+ default:
+ return 0; /* shouldn't happen, but avoids warnings */
+ }
+}
+
+string chooseRandomFile( string path, string fileType )
+{
+ vector<string> files;
+ DIR *d = opendir( path.c_str() );
+ if ( !d )
+ return "";
+
+ struct dirent *item = readdir( d );
+ while ( item )
+ {
+ string file = string( path ) + item->d_name;
+
+ // Rip extension from file
+ int pos = file.find( ".", 1 ) + 1;
+ string tmp = file.substr( pos );
+ if ( tmp.size() > 0 && fileType.find( tmp ) != -1 )
+ {
+ files.push_back( file );
+ }
+ item = readdir( d );
+ }
+
+ closedir( d );
+ return files[nextInt( files.size() )];
+}
+
+
+string getHomeDir()
+{
+ string home;
+#ifdef QWS
+ home = getenv( "HOME" );
+#else
+ home = ".";
+#endif
+
+ return home;
+}
diff --git a/noncore/games/sfcave-sdl/util.h b/noncore/games/sfcave-sdl/util.h
index e3aa31a..a67707b 100644
--- a/noncore/games/sfcave-sdl/util.h
+++ b/noncore/games/sfcave-sdl/util.h
@@ -1,10 +1,10 @@
-#ifndef __UTIL_H
-#define __UTIL_H
-
-#include <string>
-using namespace std;
-
-Uint32 getpixel(SDL_Surface *surface, int x, int y);
-string chooseRandomFile( string path, string fileType );
-string getHomeDir();
-#endif
+#ifndef __UTIL_H
+#define __UTIL_H
+
+#include <string>
+using namespace std;
+
+Uint32 getpixel(SDL_Surface *surface, int x, int y);
+string chooseRandomFile( string path, string fileType );
+string getHomeDir();
+#endif