From: Ivan Hernandez Date: Sun, 12 Jul 2009 20:29:18 +0000 (-0500) Subject: Broken but Level and Sprite classes have defaut constructors X-Git-Url: http://git.mmlx.us/?a=commitdiff_plain;h=fedc7562d8638afd3db573e9ae8774662e2fc76a;p=IvanGame.git Broken but Level and Sprite classes have defaut constructors --- diff --git a/Animation.cpp b/Animation.cpp index d85c159..a7a878d 100644 --- a/Animation.cpp +++ b/Animation.cpp @@ -11,6 +11,11 @@ #include "fns.h" using namespace std; +Animation::Animation(std::string animFile) +{ + loadAnimation(animFile); +} + int Animation::loadAnimation(std::string animFile) { //variables diff --git a/Animation.h b/Animation.h index 666a2cf..57b3e81 100644 --- a/Animation.h +++ b/Animation.h @@ -12,11 +12,7 @@ struct SpriteFrame{ class Animation { public: - Animation() {} - Animation(std::string animFile) - { - loadAnimation(animFile); - } + Animation(std::string animFile); int loadAnimation(std::string animFile); SpriteFrame *mAnim; int mBuilt, mNumFrames, mW, mH; diff --git a/Level.cpp b/Level.cpp index fc31120..5e2af20 100644 --- a/Level.cpp +++ b/Level.cpp @@ -3,9 +3,29 @@ Level::Level(SDL_Surface* screen) : mBackground(0), - mScreen(screen) + mScreen(screen), + mVikingAnimation("viking.anim"), + mSunAnimation("sun.anim") { + // load background mBackground = LoadImage("Backgrounds/bg.bmp"); + + // load sprites + Sprite vikings1(screen, "viking1", &mVikingAnimation); + vikings1.setPosition(10,30); + vikings1.setSpeed(1); + + Sprite vikings2(screen, "viking2", &mVikingAnimation); + vikings2.setPosition(350,300); + vikings2.setSpeed(1.5); + + Sprite sun(screen, "sun", &mSunAnimation); + sun.setPosition(480,50); + sun.setSpeed(1); + + mSprites.push_back(vikings1); + mSprites.push_back(vikings2); + mSprites.push_back(sun); } void Level::DrawIMG(SDL_Surface *img, int x, int y) diff --git a/Level.h b/Level.h index adc748c..8f2d750 100644 --- a/Level.h +++ b/Level.h @@ -12,18 +12,18 @@ public: ~Level(); void drawScene(); void LoadBG(string name); - virtual void postEvent(SDL_Event event); private: SDL_Surface *mBackground; SDL_Surface *mScreen; - vector mSprites; void DrawBG(); void DrawIMG(); void DrawIMG(SDL_Surface *img, int x, int y); void DrawIMG(SDL_Surface *img, int x, int y, int w, int h, int x2, int y2); void DrawSprites(); + + Animation mVikingAnimation, mSunAnimation; }; #endif diff --git a/main.cpp b/main.cpp index 2d18d73..c5b187e 100644 --- a/main.cpp +++ b/main.cpp @@ -24,8 +24,6 @@ SDL_Surface *back = NULL; SDL_Surface *screen = NULL; SDL_Surface *image = NULL; -Animation vikingAnimation; -Animation sunAnimation; //Sprite vikings1; //Sprite vikings2; //Sprite sun;