Here's 'Sprite.h':
Code: Select all
#include "Content.h"
using namespace std;
#ifndef SPRITE
#define SPRITE
class Sprite{
public:
Sprite();
Sprite(string file2,int x2,int y2,bool visible2);
void show();
void hide();
string file;
int x;
int y;
bool visible;
private:
SDL_Surface *bmp;
SDL_Rect offset;
};
Sprite::Sprite(){
file="null.bmp";
bmp=SDL_DisplayFormat(SDL_LoadBMP(file.c_str()));
x=0;
y=0;
offset.x=x;
offset.y=y;
visible=false;
}
Sprite::Sprite(string file2,int x2,int y2,bool visible2){
file=file2;
bmp=SDL_DisplayFormat(SDL_LoadBMP(file.c_str()));
x=x2;
y=y2;
offset.x=x;
offset.y=y;
visible=visible2;
}
void Sprite::show(){
SDL_BlitSurface(bmp,NULL,screen,&offset);
}
void Sprite::hide(){
SDL_FreeSurface(bmp);
delete this;
}
#endif
Code: Select all
#ifndef CONTENT
#define CONTENT
#include <iostream>
#include "SDL\SDL.h"
#include "windows.h"
#include "Environment.h"
#include "Sprite.h"
#include "Tile.h"
#include "Map.h"
#include "World.h"
#include "Object.h"
#include "Creature.h"
#include "Npc.h"
#include "Player.h"
using namespace std;
int mapIndex=0;
SDL_Surface *screen=NULL; //SDL's screen
Sprite *sprite=new Sprite("dude.bmp",10,10,true); //test sprite
Player *player=new Player(); //Main Player
World *world=new World(); //the world
#endif