author | sudonix <sudonix> | 2004-02-26 02:25:15 (UTC) |
---|---|---|
committer | sudonix <sudonix> | 2004-02-26 02:25:15 (UTC) |
commit | b339031e14a607ff18e404e0395b1c2782b92fdc (patch) (side-by-side diff) | |
tree | ecd65299976322166ee5dfb2c30f045dd542c1e1 | |
parent | cb72ff620022306e493421006b024b971449f864 (diff) | |
download | opie-b339031e14a607ff18e404e0395b1c2782b92fdc.zip opie-b339031e14a607ff18e404e0395b1c2782b92fdc.tar.gz opie-b339031e14a607ff18e404e0395b1c2782b92fdc.tar.bz2 |
SDL includes corrected, CRs in some files removed, just for consistency :)
32 files changed, 35 insertions, 36 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,50 +1,50 @@ -#include "SDL.h" -#include "SDL_image.h" +#include <SDL/SDL.h> +#include <SDL/SDL_image.h> #include "constants.h" #include "animatedimage.h" AnimatedImage :: AnimatedImage( string file, int nFrames ) { nrFrames = nFrames; currentFrame = 0; // Load image image = IMG_Load( (const char *)file.c_str() ); if ( !image ) { nrFrames = 0; image = 0; return; } SDL_SetColorKey(image, SDL_SRCCOLORKEY | SDL_RLEACCEL, SDL_MapRGB( image->format, 0, 0, 0 ) ); frameWidth = image->w/nrFrames; frameHeight = image->h; } AnimatedImage :: ~AnimatedImage() { if ( image != 0 ) SDL_FreeSurface( image ); } bool AnimatedImage :: nextFrame() { bool rc = true; currentFrame ++; if ( currentFrame >= nrFrames ) { currentFrame --; rc = false; } return rc; } void AnimatedImage :: draw( SDL_Surface *screen, int x, int y ) { if ( !image ) return; SDL_Rect dst; 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,25 +1,25 @@ #ifndef __ANIMATED_IMAGE_H #define __ANIMATED_IMAGE_H -#include "SDL.h" +#include <SDL/SDL.h> class AnimatedImage { public: AnimatedImage( string file, int nFrames ); ~AnimatedImage(); bool nextFrame(); void draw( SDL_Surface *screen, int x, int y ); bool AtEnd(); void reset() { currentFrame = 0; } private: SDL_Surface *image; int nrFrames; int currentFrame; int frameWidth; int frameHeight; }; #endif 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 @@ -1,60 +1,60 @@ /***********************************************************/ /* */ /* BFONT.c v. 1.0.2 - Billi Font Library by Diego Billi */ /* BFONT++ C++ port by Gianluigi Davassi */ /***********************************************************/ #include "iostream" 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() { int x = 0, i = '!'; Uint32 sentry = GetPixel(0,0); if (SDL_MUSTLOCK(Surface)) SDL_LockSurface(Surface); while ( x < (Surface->w-1)) { if(GetPixel(x,0) != sentry) { Chars[i].x = x; Chars[i].y = 1; Chars[i].h = Surface->h; for (; GetPixel(x, 0) != sentry && x < (Surface->w); ++x) ; Chars[i].w = (x - Chars[i].x); i++; } else { x++; } } Chars[' '].x = 0; Chars[' '].y = 0; Chars[' '].h = Surface->h; Chars[' '].w = Chars['!'].w; if (SDL_MUSTLOCK(Surface)) SDL_UnlockSurface(Surface); h = Surface->h; SDL_SetColorKey(Surface, SDL_SRCCOLORKEY, GetPixel(0, Surface->h-1)); } /* Load the font and stores it in the BFont_Info structure */ void BFont::LoadFont (const char *filename) { SDL_Surface *surface(NULL); int x; // tutta roba inutile in C++.... :-) /* BFont_Info *Font=NULL; Font = (BFont_Info *) malloc(sizeof(BFont_Info));*/ if ((filename != NULL ) && (this != NULL)) { 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 @@ -1,60 +1,60 @@ /************************************************************ BFONT v. 1.0.2 - Billi Font Library by Diego Billi BFONT++ C++ port by Gianluigi Davassi ************************************************************/ #ifndef __BFONT_HEADER_H__ #define __BFONT_HEADER_H__ #include <iostream> -#include "SDL.h" +#include <SDL/SDL.h> class BFont { int h; // font height SDL_Surface *Surface; // font surface SDL_Rect Chars[256]; // characters width const char* name; // font name BFont(const BFont&); void InitFont(); int count(const char *text); public: BFont(const char *__filename) // generator bill : name(__filename) { LoadFont(__filename); } ~BFont() { SDL_FreeSurface(Surface); } // screen must be free by application int FontHeight () // Returns the font height { return h; } void SetFontHeight (int height) // Change the font height { h = height ; } int CharWidth (char c) // Returns the character width of the specified font { return Chars[c].w; } void LoadFont (const char *filename); // Load and store le font in the BFont structure int PutChar (SDL_Surface *screen, int x, int y, char c); // Write a single character on the "Surface" with the current font int TextWidth (const char *text ); // Returns the width, in pixels, of the text calculated with the current font BFont *SetFontColor(Uint8 r, Uint8 g, Uint8 b); // Returns a new font colored with the color (r,g,b) void PutString ( SDL_Surface *screen, int x, int y, const char *text); // Write a string on the "Surface" with the specified font void LeftPutString ( SDL_Surface *screen, int y, const char *text); // Write a left-aligned string on the "Surface" with the specified font void CenteredPutString ( SDL_Surface *screen, int y, const char *text); // Write a center-aligned string on the "Surface" with the specified font void RightPutString ( SDL_Surface *screen, int y, const char *text); // Write a right-aligned string on the "Surface" with the specified font void JustifiedPutString ( SDL_Surface *screen, int y, const char *text); // Write a justify-aligned string on the "Surface" with the specified font // The following functions do the same task but have the classic "printf" sintax void PrintString ( SDL_Surface *screen, int x, int y, char *fmt, ...); void CenteredPrintString ( SDL_Surface *screen, int y, char *fmt, ...); void RightPrintString ( SDL_Surface *screen, int y, char *fmt, ...); void LeftPrintString ( SDL_Surface *screen, int y, char *fmt, ...); void JustifiedPrintString ( SDL_Surface *screen, int y, char *fmt, ...); 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,49 +1,49 @@ -#include "SDL_gfxPrimitives.h" +#include <SDL/SDL_gfxPrimitives.h> #include "constants.h" #include "fly_game.h" #include "random.h" FlyGame :: FlyGame( SFCave *p, int w, int h, int diff ) : Game( p, w, h, diff ) { gameName = "Fly"; difficulty = MENU_DIFFICULTY_EASY; terrain = new FlyTerrain( w, h ); player = new Player( w, h ); highScore = 0; } FlyGame :: ~FlyGame() { // terrain and player get deleted by parent class } void FlyGame :: init() { switch( difficulty ) { case MENU_DIFFICULTY_EASY: player->setMovementInfo( 0.3, 0.2, 1.5, 1.5 ); break; case MENU_DIFFICULTY_NORMAL: player->setMovementInfo( 0.35, 0.4, 2.5, 3 ); break; case MENU_DIFFICULTY_HARD: player->setMovementInfo( 0.4, 0.6, 4, 5 ); break; case MENU_DIFFICULTY_CUSTOM: { double thrust = parent->loadDoubleSetting( "Fly_custom_player_thrust", 0.3 ); double gravity = parent->loadDoubleSetting( "Fly_custom_player_gravity", 0.2 ); double maxUp = parent->loadDoubleSetting( "Fly_custom_player_maxupspeed", 1.5 ); double maxDown = parent->loadDoubleSetting( "Fly_custom_player_maxdownspeed", 1.5 ); player->setMovementInfo( thrust, gravity, maxUp, maxDown ); break; } } startScoring = false; Game :: init(); } 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 @@ -1,28 +1,28 @@ #ifndef __FLY_GAME_H #define __FLY_GAME_H #include "sfcave.h" #include "flyterrain.h" #include "player.h" #include "game.h" -#include "SDL.h" +#include <SDL/SDL.h> class FlyGame : public Game { public: FlyGame( SFCave *p, int w, int h, int diff ); ~FlyGame(); void init(); void update( int state ); void draw( SDL_Surface *screen ); private: // int movePlayer; bool startScoring; bool checkCollisions(); }; #endif 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,50 +1,49 @@ - -#include "SDL_gfxPrimitives.h" +#include <SDL/SDL_gfxPrimitives.h> #include "constants.h" #include "flyterrain.h" #include "random.h" int FlyTerrain :: flyScoreZones[][3] = { { 0, 20, 5 }, { 20, 30, 2 }, { 30, 40, 0 }, { 40, 100, -1 }, { 100, 300, -2 }, { -1, -1, -1 } }; FlyTerrain :: FlyTerrain( int w, int h ) : Terrain( w, h, false, true ) { showScoreZones = true; } FlyTerrain :: ~FlyTerrain() { } void FlyTerrain :: setPoint( int point ) { static int fly_difficulty_levels[] = { 5, 10, 15 }; if ( nextInt(100) >= 75 ) dir *= -1; int prevPoint = mapBottom[point-1]; int nextPoint = prevPoint + (dir * nextInt( fly_difficulty_levels[0] ) ); if ( nextPoint > sHeight ) { nextPoint = sHeight; dir *= -1; } else if ( nextPoint < maxHeight ) { nextPoint = maxHeight; dir *= 1; } mapBottom[point] = nextPoint; } void FlyTerrain :: drawTerrain( SDL_Surface *screen ) 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,29 +1,29 @@ #ifndef __FLYTERRAIN_H #define __FLYTERRAIN_H -#include <SDL.h> +#include <SDL/SDL.h> #include "terrain.h" class FlyTerrain : public Terrain { public: FlyTerrain( int w, int h ); ~FlyTerrain(); void drawTerrain( SDL_Surface *screen ); int getScore( int difficulty, int dist ); void displayScoreZones( bool val ) { showScoreZones = val; } protected: bool showScoreZones; static int flyScoreZones[][3]; void setPoint( int point ); }; #endif 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,33 +1,33 @@ #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 #define FONT_WHITE_TEXT 3 #define FONT_COLOURED_TEXT 4 #define FONT_HELP_FONT 5 class FontHandler { public: static bool init(); static void cleanUp(); static int TextWidth( int font, const char *text ); static int FontHeight( int font ); static void draw( SDL_Surface *screen, int font, const char *text, int x, int y ); static void changeColor( int font, int r, int g, int b ); static BFont *getFont( int font ); private: static BFont *menuSelFont; static BFont *menuUnSelFont; static BFont *whiteFont; static BFont *colouredFont; static BFont *helpFont; }; #endif 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,53 +1,53 @@ #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" #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 { 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,49 +1,49 @@ -#include "SDL_gfxPrimitives.h" +#include <SDL/SDL_gfxPrimitives.h> #include "constants.h" #include "gates_game.h" #include "random.h" GatesGame :: GatesGame( SFCave *p, int w, int h, int diff ) : Game( p, w, h, 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() { blockHeight = 80; blockWidth = 20; lastGateBottomY = 0; gateDistance = 75; nextGate = nextInt( 50 ) + gateDistance; gapHeight = 75; switch( difficulty ) { 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: { 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,45 +1,45 @@ #ifndef __GATES_GAME_H #define __GATES_GAME_H -#include "SDL.h" +#include <SDL/SDL.h> #include "rect.h" #include "sfcave.h" #include "terrain.h" #include "player.h" #include "game.h" class GatesGame : public Game { public: GatesGame( SFCave *p, int w, int h, int diff ); ~GatesGame(); void init(); void update( int state ); void draw( SDL_Surface *screen ); private: int gapHeight; int gateDistance; int nextGate; int lastGateBottomY; int blockDistance; int blockHeight; int blockWidth; int blockUpdateRate; Rect blocks[BLOCKSIZE]; void addGate(); void moveBlocks( int amountToMove ); void drawBlocks( SDL_Surface *screen ); bool checkCollisions(); }; #endif 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,49 +1,49 @@ -#include "SDL.h"
+#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;
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 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,50 +1,50 @@ -#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" #include "menu.h" #include "font.h" #include "starfield.h" MenuOption :: MenuOption( string text, int id ) { menuText = text; menuId = id; nextMenu = 0; highlighted = false; } MenuOption :: ~MenuOption() { } int MenuOption :: draw( SDL_Surface *screen, int y ) { if ( highlighted ) { int x = (240 - FontHandler::TextWidth( FONT_MENU_HIGHLIGHTED, (const char *)menuText.c_str() ))/2; FontHandler::draw( screen, FONT_MENU_HIGHLIGHTED, (const char *)menuText.c_str(), x, y ); return FontHandler::FontHeight( FONT_MENU_HIGHLIGHTED ); } else { int x = (240 - FontHandler::TextWidth( FONT_MENU_UNHIGHLIGHTED, (const char *)menuText.c_str() ))/2; FontHandler::draw( screen, FONT_MENU_UNHIGHLIGHTED, (const char *)menuText.c_str(), x, y ); return FontHandler::FontHeight( FONT_MENU_UNHIGHLIGHTED ); } } void MenuOption :: setNextMenu( Menu *item, bool down ) { nextMenu = item; downMenuTree = down; } //----------------- Menu Class ------------- SDL_Surface * Menu :: sfcaveTextImage; 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 @@ -1,55 +1,55 @@ #ifndef __MENU_H #define __MENU_H #include <list> using namespace std; -#include <SDL.h> +#include <SDL/SDL.h> class SFCave; class StarField; class Menu; class MenuOption { public: MenuOption( string text, int id ); ~MenuOption(); void highlight( bool val ) { highlighted = val; } int draw( SDL_Surface *screen, int y ); void setNextMenu( Menu *item, bool down = true ); Menu *getNextMenu() { return nextMenu; } int getMenuId() { return menuId; } bool isDownMenuTree() { return downMenuTree; } private: int menuId; string menuText; bool highlighted; bool downMenuTree; Menu *nextMenu; }; class Menu { public: Menu( SFCave *p ); ~Menu(); void draw( SDL_Surface *screen ); int handleKeys( SDL_KeyboardEvent & ); MenuOption *addMenuOption( string text, int id ); void resetToTopMenu(); void initCurrentMenu(); void setStatusText( string text ) { statusText = text; } protected: private: static SDL_Surface * sfcaveTextImage; int angle; static Menu *mainMenu; 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,50 +1,50 @@ -#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" #include "animatedimage.h" Player :: Player( int w, int h ) { sWidth = w; sHeight = h; thrust = 0.4; gravity = 0.6; maxUpSpeed = 4.0; maxDownSpeed = 5.0; explosion = new AnimatedImage( IMAGES_PATH "explosion.bmp", 15 ); init(); } Player :: ~Player() { if ( explosion ) delete explosion; } void Player :: init() { // Set player position pos.x( 50 ); pos.y( sWidth/2 ); pos.h( 2 ); pos.w( 4 ); currentThrust = 0; crashing = false; crashLineLength = 0; crashed = false; explosion->reset(); allFaded = false; expNextFrame = false; // Reset Trail for ( int i = 0 ; i < TRAILSIZE ; ++i ) { trail[i].x( -1 ); trail[i].y( 0 ); trail[i].w( 2 ); trail[i].h( 2 ); 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,52 +1,52 @@ #ifndef __RECT_H
#define __RECT_H
-#include "SDL.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) &&
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 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 @@ -1,56 +1,56 @@ #include <stdio.h> #include <stdlib.h> #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" #include "menu.h" #include "help.h" #include "game.h" #include "terrain.h" #include "random.h" #include "sfcave.h" #include "font.h" #include "settings.h" #include "util.h" #include "sfcave_game.h" #include "gates_game.h" #include "fly_game.h" void start( int argc, char *argv[] ) { SFCave *app = new SFCave( argc, argv ); app->mainEventLoop(); delete app; } #ifdef __cplusplus extern "C" #endif int main(int argc, char *argv[]) { start( argc, argv ); return 0; } SFCave :: SFCave( int argc, char *argv[] ) { setupOK = false; // Load settings string diff = loadSetting( "GameDifficulty", "Easy" ); string game = loadSetting( "GameType", "SFCave" ); musicPath = loadSetting( "MusicPath", SOUND_PATH ); musicType = loadSetting( "MusicType", "mod,ogg" ); bool soundOn = loadBoolSetting( "SoundOn", true ); bool musicOn = loadBoolSetting( "MusicOn", true ); if ( musicPath[musicPath.size()-1] != '/' ) musicPath += "/"; 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,52 +1,52 @@ #ifndef __SFCAVE_H #define __SFCAVE_H -#include "SDL.h" +#include <SDL/SDL.h> #include "terrain.h" class Game; class Menu; class Help; class SFCave { public: SFCave( int argc, char *argv[] ); ~SFCave(); void initSDL( int argc, char *argv[] ); void mainEventLoop(); void setCrashed( bool val ); void changeState( int s ); int getState() { return state; } Game *getCurrentGame() { return currentGame; } int getFPS() { return actualFPS; } bool showFPS() { return showFps; } void setMenuStatusText( string statusText ); void saveSetting( string key, string val ); void saveSetting( string key, int val ); void saveSetting( string key, long val ); void saveSetting( string key, double val ); string loadSetting( string key, string defaultVal = "" ); bool loadBoolSetting( string key, bool defaultVal); int loadIntSetting( string key, int defaultVal ); double loadDoubleSetting( string key, double defaultVal ); private: SDL_Surface *screen; bool setupOK; Game *currentGame; Menu *menu; Help *help; int state; bool showFps; string musicPath; string musicType; bool finish; bool limitFPS; 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,49 +1,49 @@ -#include "SDL_gfxPrimitives.h" +#include <SDL/SDL_gfxPrimitives.h> #include "constants.h" #include "sfcave_game.h" #include "random.h" SFCaveGame :: SFCaveGame( SFCave *p, int w, int h, int diff ) : Game( p, w, h, diff ) { gameName = "SFCave"; difficulty = MENU_DIFFICULTY_EASY; blockUpdateRate = 200; terrain = new Terrain( w, h ); player = new Player( w, h ); highScore = 0; } SFCaveGame :: ~SFCaveGame() { } void SFCaveGame :: init() { blockDistance = 50; blockHeight = 80; blockWidth = 20; switch( difficulty ) { case MENU_DIFFICULTY_EASY: blockDistance = 50; break; case MENU_DIFFICULTY_NORMAL: blockDistance = 40; break; case MENU_DIFFICULTY_HARD: blockDistance = 30; break; case MENU_DIFFICULTY_CUSTOM: { // Read custom difficulty settings for this game blockDistance = parent->loadIntSetting( "SFCave_custom_blockdistance", 50 ); double thrust = parent->loadDoubleSetting( "SFCave_custom_player_thrust", 0.4 ); double gravity = parent->loadDoubleSetting( "SFCave_custom_player_gravity", 0.6 ); double maxUp = parent->loadDoubleSetting( "SFCave_custom_player_maxupspeed", 4.0 ); double maxDown = parent->loadDoubleSetting( "SFCave_custom_player_maxdownspeed", 5.0 ); player->setMovementInfo( thrust, gravity, maxUp, maxDown ); 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,39 +1,39 @@ #ifndef __SFCAVE_GAME_H #define __SFCAVE_GAME_H -#include "SDL.h" +#include <SDL/SDL.h> #include "rect.h" #include "sfcave.h" #include "terrain.h" #include "player.h" #include "game.h" class SFCaveGame : public Game { public: SFCaveGame( SFCave *p, int w, int h, int diff ); ~SFCaveGame(); void init(); void update( int state ); void draw( SDL_Surface *screen ); private: int blockDistance; int blockHeight; int blockWidth; int blockUpdateRate; Rect blocks[BLOCKSIZE]; void addBlock(); void moveBlocks( int amountToMove ); void drawBlocks( SDL_Surface *screen ); bool checkCollisions(); }; #endif 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 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"
+#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,50 +1,50 @@ -#include "SDL.h"
-#include "SDL_gfxPrimitives.h"
+#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();
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 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 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,51 +1,51 @@ -#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" #include "util.h" #include "starfield.h" Terrain :: Terrain( int w, int h, bool drawTop, bool drawBottom ) { sWidth = w; sHeight = h; speed = 1; segSize = sWidth/(MAPSIZE-2)+1; this->drawTop = drawTop; this->drawBottom = drawBottom; stars = new StarField( true ); SDL_Surface *tmp = SDL_CreateRGBSurface(SDL_SWSURFACE, sWidth + 20, sHeight, 32, 0x000000ff,0x0000ff00, 0x00ff0000, 0xff000000); terrainSurface = SDL_DisplayFormat( tmp ); SDL_FreeSurface( tmp ); initTerrain(); } Terrain :: ~Terrain() { SDL_FreeSurface( terrainSurface ); delete stars; } void Terrain :: initTerrain() { dir = 1; offset = 0; maxHeight = 50; mapTop[0] = (int)(nextInt(50)) + 5; mapBottom[0] = sHeight - (maxHeight - mapTop[0]); for ( int i = 1 ; i < MAPSIZE ; ++i ) setPoint( i ); SDL_FillRect( terrainSurface, 0, 0 ); // Draw Terrain into surface 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,50 +1,50 @@ #ifndef __TERRAIN_H #define __TERRAIN_H -#include <SDL.h> +#include <SDL/SDL.h> class StarField; class Terrain { public: Terrain( int w, int h, bool drawTop = true, bool drawBottom = true ); virtual ~Terrain(); virtual void initTerrain(); virtual void moveTerrain( int amountToMove ); virtual bool checkCollision( int x, int y, int h ); virtual void drawTerrain( SDL_Surface *screen ); int getMapTop( int pos ) { return mapTop[pos]; } int getMapBottom( int pos ) { return mapBottom[pos]; } int getMaxHeight() { return maxHeight; } void increaseMaxHeight( int amount ); int offset; protected: int sWidth; int sHeight; int drawTop; int drawBottom; int mapTop[MAPSIZE]; int mapBottom[MAPSIZE]; int maxTop; int maxBottom; int maxHeight; int dir; int speed; int segSize; SDL_Surface *terrainSurface; StarField *stars; void setPoint( int point ); }; #endif 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,49 +1,49 @@ -#include "SDL.h"
+#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;
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 |