#include "fns.h"
using namespace std;
+Animation::Animation(std::string animFile)
+{
+ loadAnimation(animFile);
+}
+
int Animation::loadAnimation(std::string animFile)
{
//variables
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;
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)
~Level();
void drawScene();
void LoadBG(string name);
-
virtual void postEvent(SDL_Event event);
private:
SDL_Surface *mBackground;
SDL_Surface *mScreen;
-
vector<Sprite> 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
SDL_Surface *screen = NULL;\r
SDL_Surface *image = NULL;\r
\r
-Animation vikingAnimation;\r
-Animation sunAnimation;\r
//Sprite vikings1;\r
//Sprite vikings2;\r
//Sprite sun;\r