1
0
mirror of https://github.com/krislamo/Trololo synced 2024-11-10 00:30:35 +00:00

Added indicator.bmp image, and a simple nonfunctional menu

This commit is contained in:
Kris Lamoureux 2013-01-02 16:37:58 -08:00
parent 30c6d96244
commit 1b797b3d69
4 changed files with 51 additions and 17 deletions

View File

@ -1,5 +1,9 @@
Bibliography Bibliography
Green Arrow up. Digital image. Symbols & Shapes - Green Arrow up - Public Domain
Clip Art. N.p., n.d. Web. 2 Jan. 2013. <http://www.pdclipart.org
/displayimage.php?album=141&pos=145>.
Kratochvil, Petr. Pool Tiles Underwater. Digital image. Free Stock Photo - Public Kratochvil, Petr. Pool Tiles Underwater. Digital image. Free Stock Photo - Public
Domain Pictures. N.p., n.d. Web. 28 Oct. 2012. Domain Pictures. N.p., n.d. Web. 28 Oct. 2012.
<http://www.publicdomainpictures.net/view-image.php?image=5182& <http://www.publicdomainpictures.net/view-image.php?image=5182&
@ -11,4 +15,3 @@ OCAL. Illustration Of A Blue Codfish. Digital image. Free Stock Photos. N.p., n.
Trollface. Digital image. Wikipedia. N.p., n.d. Web. 28 Oct. 2012. Trollface. Digital image. Wikipedia. N.p., n.d. Web. 28 Oct. 2012.
<http://upload.wikimedia.org/wikipedia/en/thumb/7/78/Trollface.svg/200px- <http://upload.wikimedia.org/wikipedia/en/thumb/7/78/Trollface.svg/200px-
Trollface.svg.png>. Trollface.svg.png>.

BIN
bin/indicator.bmp Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.1 KiB

View File

@ -56,8 +56,6 @@ namespace scrnfunk
} }
namespace scrns namespace scrns
{ {
// Returns 1 (true) on success, 0 (false) on error. // Returns 1 (true) on success, 0 (false) on error.
@ -121,6 +119,7 @@ namespace scrns
// Image filenames // Image filenames
const char *background_image = "bin/stage1.bmp"; const char *background_image = "bin/stage1.bmp";
const char *characters_image = "bin/characters.bmp"; const char *characters_image = "bin/characters.bmp";
//const char *indicator_image = "bin/indicator.bmp";
// Char // Char
SDL_Rect clip[2]; SDL_Rect clip[2];
@ -162,33 +161,66 @@ namespace scrns
// Blit codfish image // Blit codfish image
scrnfunk::apply_image(150, 300, characters, screen, &clip[1]); scrnfunk::apply_image(150, 300, characters, screen, &clip[1]);
// Setup welcome text // Open font at title size.
SDL_Color whitecolor = { 255, 255, 255 };
TTF_Font *font = TTF_OpenFont("bin/CaviarDreams.ttf", 80); TTF_Font *font = TTF_OpenFont("bin/CaviarDreams.ttf", 80);
const char* text = "Welcome to Trololo";
if(!font) if(!font)
{ {
fprintf(stderr, "TTF_OpenFont: %s\n", TTF_GetError()); fprintf(stderr, "TTF_OpenFont: %s\n", TTF_GetError());
return NULL;
} }
/* // Setup Title text
Checks if font or text is 0 due to the documentation: const char* title_text = "Welcome to Trololo";
0 font into this function will cause a segfault. SDL_Color whitecolor = { 255, 255, 255 };
0 text into this function will result in undefined behavior.
*/ // Get Title text render
if(font != 0 && text != 0) if(font != 0 && title_text != 0) // 0 into the text or font causes segfaults and undefined behavior
message = TTF_RenderText_Solid(font, text, whitecolor); message = TTF_RenderText_Solid(font, title_text, whitecolor);
else else
fprintf(stderr, "TFF Render Text Solid Error: init error\n"); fprintf(stderr, "TFF Render Text Solid Error: init error\n");
// Apply message // Apply Title text render
if(message != 0) if(message != 0)
scrnfunk::apply_image(100, 200, message, screen); scrnfunk::apply_image(100, 200, message, screen);
else else
fprintf(stderr, "TFF Render Text Solid Error: apply error\n"); fprintf(stderr, "TFF Render Text Solid Error: apply error\n");
// Setup option 1 (New game)
const char* option1_text = "New game";
SDL_Color blackcolor = { 0,0,0 };
font = TTF_OpenFont("bin/CaviarDreams.ttf", 55); // reopen to resize
// Apply option 1 (New game)
if(font != 0 && option1_text != 0)
message = TTF_RenderText_Solid(font, option1_text, blackcolor);
else
fprintf(stderr, "TFF Render Text Solid Error: init error\n");
// Apply message option 1 (New game)
if(message != 0)
scrnfunk::apply_image(620, 300, message, screen);
else
fprintf(stderr, "TFF Render Text Solid Error: apply error\n");
// Setup exit option (Exit)
const char* exit_text = "Exit";
font = TTF_OpenFont("bin/CaviarDreams.ttf", 55); // reopen to resize
// Apply exit option (Exit)
if(font != 0 && option1_text != 0)
message = TTF_RenderText_Solid(font, exit_text, blackcolor);
else
fprintf(stderr, "TFF Render Text Solid Error: init error\n");
// Apply exit option (Exit)
if(message != 0)
scrnfunk::apply_image(620, 370, message, screen);
else
fprintf(stderr, "TFF Render Text Solid Error: apply error\n");
// Update screen with all applied images
if(screen != 0) if(screen != 0)
SDL_Flip(screen); SDL_Flip(screen);
else else

View File

@ -6,7 +6,6 @@ int main(int argc, char* args[])
int quit = 1; int quit = 1;
SDL_Surface *screen; SDL_Surface *screen;
screen = scrns::MainMenu(); screen = scrns::MainMenu();
if(screen == NULL) if(screen == NULL)