I'm very new to SDL and game programming in general and I'm having a bit of trouble.
My program compiles ok, but when it comes to running it, my window just flashes up for a second.
I have absolutely no idea where to start as I have read a few solutions, but only to find they have not worked for me.
class Initialization
{
public:
int initializeSDL();
int loadFiles();
};
int Initialization::initializeSDL()
{
if( SDL_Init( SDL_INIT_EVERYTHING ) == -1 )
return 1;
screen = SDL_SetVideoMode( SCREEN_WIDTH, SCREEN_HEIGHT, SCREEN_BPP, SDL_SWSURFACE );
if( screen = NULL )
return 1;
SDL_WM_SetCaption( "Game", NULL );
}
int Initialization::loadFiles()
{
character = SDL_LoadBMP( "dot.bmp" );
if(character == NULL )
return 1;
}
void cleanUp()
{
SDL_FreeSurface( character );
SDL_FreeSurface( screen );
SDL_Quit();
}
int main( int argc, char* args[] )
{
Initialization init;
init.initializeSDL();
init.loadFiles();
SDL_BlitSurface( character, NULL, screen, NULL );
SDL_Flip( screen );
SDL_Delay( 3000 );
cleanUp();
return 0;
}
As you can see I'm just having some practice with some classes in SDL too.
Both screen and character Surfaces have been declared as:
SDL_Surface* character = NULL; SDL_Surface* screen = NULL;
I apologise for posting all of my code - I'm just really stumped.
Thanks in advance!
chewii.

New Topic/Question
Reply




MultiQuote





|