1
0
mirror of https://github.com/krislamo/Trololo synced 2024-09-19 20:20:36 +00:00

A working state

This commit is contained in:
Kris Lamoureux 2012-12-31 22:53:58 -08:00
parent 874cc17c40
commit 895eb5ba37
3 changed files with 16 additions and 15 deletions

View File

@ -61,7 +61,7 @@ namespace scrnfunk
namespace scrns
{
// Returns 1 (true) on success, 0 (false) on error.
bool initiateSDL(SDL_Surface *screen, int x, int y)
SDL_Surface * initiateSDL(SDL_Surface *screen, int x, int y)
{
SDL_Surface *vid_init;
int init, ttf_ret;
@ -71,7 +71,7 @@ namespace scrns
if(init < 0)
{
fprintf(stderr, "Unable to initiate SDL: %s\n", SDL_GetError());
return false;
return NULL;
}
@ -80,19 +80,18 @@ namespace scrns
if(vid_init == 0)
{
fprintf(stderr, "Video initialization failed: %s", SDL_GetError());
return false;
return NULL;
}
// Get video surface and check
screen = SDL_GetVideoSurface();
if(screen == 0)
if(screen == NULL)
{
fprintf(stderr, "Failed to get video surface: %s", SDL_GetError());
return false;
return NULL;
}
// Set window title
SDL_WM_SetCaption(WINDOW_TITLE, 0);
@ -102,11 +101,11 @@ namespace scrns
if(ttf_ret == -1)
{
fprintf(stderr, "True Type Font initialization failed: %s", SDL_GetError());
return false;
return NULL;
}
// Success: return video surface
return true;
// Success
return screen;
}
SDL_Surface * MainMenu()
@ -125,10 +124,10 @@ namespace scrns
// Char
SDL_Rect clip[2];
screen = initiateSDL(screen, 900, 675);
initiateSDL(screen, 900, 675);
if(screen == 0)
if(screen == NULL)
{
fprintf(stderr, "Start up failure.\n");
return NULL;
@ -199,4 +198,3 @@ namespace scrns
return screen;
}
}

View File

@ -8,7 +8,10 @@ int main(int argc, char* args[])
SDL_Surface *screen;
screen = scrns::MainMenu();
if(screen == NULL)
return 1;
// Check if user quit
while(quit == 1)
{

2
main.h
View File

@ -11,7 +11,7 @@
namespace scrns
{
bool initiateSDL(SDL_Surface *screen, int x, int y);
SDL_Surface * initiateSDL(SDL_Surface *screen, int x, int y);
SDL_Surface * MainMenu();
}