mirror of
https://github.com/krislamo/Trololo
synced 2024-12-16 10:40:36 +00:00
A working state
This commit is contained in:
parent
874cc17c40
commit
895eb5ba37
24
core.cpp
24
core.cpp
@ -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()
|
||||||
@ -125,10 +124,10 @@ namespace scrns
|
|||||||
|
|
||||||
// Char
|
// Char
|
||||||
SDL_Rect clip[2];
|
SDL_Rect clip[2];
|
||||||
|
|
||||||
|
screen = initiateSDL(screen, 900, 675);
|
||||||
|
|
||||||
initiateSDL(screen, 900, 675);
|
if(screen == NULL)
|
||||||
|
|
||||||
if(screen == 0)
|
|
||||||
{
|
{
|
||||||
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;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
5
main.cpp
5
main.cpp
@ -8,7 +8,10 @@ int main(int argc, char* args[])
|
|||||||
SDL_Surface *screen;
|
SDL_Surface *screen;
|
||||||
|
|
||||||
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)
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user