Game's constructor makes a Level
authorMatt Mullins <mokomull@gmail.com>
Sun, 12 Jul 2009 20:04:49 +0000 (15:04 -0500)
committerMatt Mullins <mokomull@gmail.com>
Sun, 12 Jul 2009 20:04:49 +0000 (15:04 -0500)
Game.cpp
Game.h
Level.cpp

index a93b60f..4bd9ca2 100644 (file)
--- a/Game.cpp
+++ b/Game.cpp
@@ -26,14 +26,16 @@ Game::Game() : mCurrentLevel(0), mScreen(0)
        // To see prcisely what this toggle does, just comment the line and recompile
        // the code...
        SDL_EnableKeyRepeat(25, 20);
-}
 
-Game::Game(SDL_Surface* screen) : mCurrentLevel(0), mScreen(screen)
-{
+       // Create the first level
+       mLevels.push_back(new Level(mScreen));
 }
 
 Game::~Game()
 {
+       for (size_t i = 0; i < mLevels.size(); ++i) {
+               delete mLevels[i];
+       }
 }
 
 Level* Game::getCurrentLevel()
diff --git a/Game.h b/Game.h
index 2a4db57..ae01b02 100644 (file)
--- a/Game.h
+++ b/Game.h
@@ -18,7 +18,6 @@ class Game
 {
 public:
        Game();
-       Game(SDL_Surface *screen);
        ~Game();
 
        /**
index fc31120..2ba05e9 100644 (file)
--- a/Level.cpp
+++ b/Level.cpp
@@ -8,6 +8,10 @@ Level::Level(SDL_Surface* screen) :
        mBackground = LoadImage("Backgrounds/bg.bmp");
 }
 
+Level::~Level()
+{
+}
+
 void Level::DrawIMG(SDL_Surface *img, int x, int y)
 {
     SDL_Rect dest;