1
0
mirror of https://github.com/krislamo/Trololo synced 2024-12-16 10:40: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 namespace scrns
{ {
// Returns 1 (true) on success, 0 (false) on error. // 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; SDL_Surface *vid_init;
int init, ttf_ret; int init, ttf_ret;
@ -71,7 +71,7 @@ namespace scrns
if(init < 0) if(init < 0)
{ {
fprintf(stderr, "Unable to initiate SDL: %s\n", SDL_GetError()); fprintf(stderr, "Unable to initiate SDL: %s\n", SDL_GetError());
return false; return NULL;
} }
@ -80,19 +80,18 @@ namespace scrns
if(vid_init == 0) if(vid_init == 0)
{ {
fprintf(stderr, "Video initialization failed: %s", SDL_GetError()); fprintf(stderr, "Video initialization failed: %s", SDL_GetError());
return false; return NULL;
} }
// Get video surface and check // Get video surface and check
screen = SDL_GetVideoSurface(); screen = SDL_GetVideoSurface();
if(screen == 0) if(screen == NULL)
{ {
fprintf(stderr, "Failed to get video surface: %s", SDL_GetError()); fprintf(stderr, "Failed to get video surface: %s", SDL_GetError());
return false; return NULL;
} }
// Set window title // Set window title
SDL_WM_SetCaption(WINDOW_TITLE, 0); SDL_WM_SetCaption(WINDOW_TITLE, 0);
@ -102,11 +101,11 @@ namespace scrns
if(ttf_ret == -1) if(ttf_ret == -1)
{ {
fprintf(stderr, "True Type Font initialization failed: %s", SDL_GetError()); fprintf(stderr, "True Type Font initialization failed: %s", SDL_GetError());
return false; return NULL;
} }
// Success: return video surface // Success
return true; return screen;
} }
SDL_Surface * MainMenu() SDL_Surface * MainMenu()
@ -126,9 +125,9 @@ namespace scrns
// Char // Char
SDL_Rect clip[2]; SDL_Rect clip[2];
initiateSDL(screen, 900, 675); screen = initiateSDL(screen, 900, 675);
if(screen == 0) if(screen == NULL)
{ {
fprintf(stderr, "Start up failure.\n"); fprintf(stderr, "Start up failure.\n");
return NULL; return NULL;
@ -199,4 +198,3 @@ namespace scrns
return screen; return screen;
} }
} }

View File

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

2
main.h
View File

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