1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60
|
#include "Resource_Manager.h"
Resource_Manager::Resource_Manager()
{
ok = true;
}
void Resource_Manager :: init()
{
p1 = IMG_Load("robo_walking-x95-y120.bmp");
SDL_SetColorKey(p1, SDL_SRCCOLORKEY, SDL_MapRGB(p1->format, 255, 0, 255));
npc = IMG_Load("enemy.bmp");
SDL_SetColorKey(npc, SDL_SRCCOLORKEY, SDL_MapRGB(npc->format, 255, 0, 255));
bullet = IMG_Load("bullet_right.png");
SDL_SetAlpha(bullet, SDL_SRCALPHA, 0);
if (p1==NULL)
{
std::cout << "Can't find p1's image" << std::endl;
ok = false;
}
if (npc==NULL)
{
std::cout << "Can't find npc's image" << std::endl;
ok = false;
}
if (bullet==NULL)
{
std::cout << "Can't find bullet's image" << std::endl;
ok = false;
}
};
SDL_Surface* Resource_Manager :: get_p1()
{
SDL_Surface* temp = SDL_ConvertSurface(p1, p1->format, p1->flags);
return temp;
};
SDL_Surface* Resource_Manager :: get_npc()
{
SDL_Surface* temp = SDL_ConvertSurface(npc, npc->format,npc->flags);
return temp;
};
SDL_Surface* Resource_Manager :: get_bullet()
{
SDL_Surface* temp = SDL_ConvertSurface(bullet, bullet->format, bullet->flags);
return bullet;
};
Resource_Manager::~Resource_Manager()
{
SDL_FreeSurface(p1);
SDL_FreeSurface(npc);
SDL_FreeSurface(bullet);
}
|