From 7e17865c2ada717c975ab65e15bfd591ef2ff060 Mon Sep 17 00:00:00 2001 From: Anna Wiggins Date: Tue, 28 Jun 2011 21:44:28 -0400 Subject: [PATCH] Implemented TitleScreen::init() --- game.cpp | 3 ++- titlescreen.cpp | 19 +++++++++++++++++++ 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/game.cpp b/game.cpp index f81c806..4010cec 100644 --- a/game.cpp +++ b/game.cpp @@ -16,7 +16,8 @@ Game::Game(SDL_Surface* display) Game::~Game() { - SDL_FreeSurface(background); + if (background != NULL) + SDL_FreeSurface(background); } diff --git a/titlescreen.cpp b/titlescreen.cpp index 12d5b17..e9a615a 100644 --- a/titlescreen.cpp +++ b/titlescreen.cpp @@ -1,4 +1,5 @@ #include "titlescreen.h" +#include "drawutils.h" TitleScreen::TitleScreen(SDL_Surface* display) : GameState(display) @@ -20,7 +21,25 @@ GameState::~GameState() bool TitleScreen::init() { + background = DrawUtils::load("background.bmp"); + if (background == NULL) + { +#ifdef DEBUG + std::cerr << "debug: TitleScreen::init(): error: Couldn't load background image\n"; +#endif + return false; + } + + title_banner = DrawUtils::load("title.bmp"); + + if (title_banner == NULL) + { +#ifdef DEBUG + std::cerr << "debug: TitleScreen::init(): error: Couldn't load title banner\n"; +#endif + return false; + } }