forked from jaildesigner-jailgames/jaildoctors_dilemma
Arreglado un bug a la hora de buscar por nombre los recursos
This commit is contained in:
@@ -26,7 +26,10 @@ std::string Asset::get(std::string text)
|
||||
{
|
||||
for (auto f : fileList)
|
||||
{
|
||||
if (f.file.find(text) != std::string::npos)
|
||||
const size_t lastIndex = f.file.find_last_of("/")+1;
|
||||
const std:: string file = f.file.substr(lastIndex, std::string::npos);
|
||||
|
||||
if (file == text)
|
||||
{
|
||||
return f.file;
|
||||
}
|
||||
|
||||
@@ -14,6 +14,9 @@ void Resource::loadTextures(std::vector<std::string> list)
|
||||
{
|
||||
for (auto l : list)
|
||||
{
|
||||
std::cout << "\nLOAD TEXTURE: " << l << std::endl;
|
||||
std::cout << "png: " << asset->get(l) << std::endl;
|
||||
|
||||
res_texture_t t;
|
||||
t.name = l;
|
||||
t.texture = new Texture(renderer, asset->get(l));
|
||||
@@ -30,6 +33,10 @@ void Resource::loadAnimations(std::vector<std::string> list)
|
||||
const size_t lastIndex = l.find_last_of(".");
|
||||
const std::string pngFile = l.substr(0, lastIndex) + ".png";
|
||||
|
||||
std::cout << "\nLOAD ANIMATION: " << l << std::endl;
|
||||
std::cout << "png: " << asset->get(pngFile) << std::endl;
|
||||
std::cout << "ani: " << asset->get(l) << std::endl;
|
||||
|
||||
res_animation_t as;
|
||||
as.name = l;
|
||||
as.animation = new animatedSprite_t(loadAnimationFromFile(getTexture(pngFile), asset->get(l)));
|
||||
@@ -158,8 +165,12 @@ Texture *Resource::getTexture(std::string name)
|
||||
{
|
||||
for (auto texture : textures)
|
||||
{
|
||||
if (texture.name.find(name) != std::string::npos)
|
||||
// if (texture.name.find(name) != std::string::npos)
|
||||
if (texture.name == name)
|
||||
{
|
||||
// std::cout << "\nTEXTURE REQUESTED: " << name << std::endl;
|
||||
// std::cout << "served: " << texture.name << std::endl;
|
||||
|
||||
return texture.texture;
|
||||
}
|
||||
}
|
||||
@@ -173,8 +184,11 @@ animatedSprite_t *Resource::getAnimation(std::string name)
|
||||
{
|
||||
for (auto animation : animations)
|
||||
{
|
||||
if (animation.name.find(name) != std::string::npos)
|
||||
// if (animation.name.find(name) != std::string::npos)
|
||||
if (animation.name == name)
|
||||
{
|
||||
// std::cout << "\nANIMATION REQUESTED: " << name << std::endl;
|
||||
// std::cout << "served: " << animation.name << std::endl;
|
||||
return animation.animation;
|
||||
}
|
||||
}
|
||||
@@ -188,7 +202,8 @@ textFile_t *Resource::getOffset(std::string name)
|
||||
{
|
||||
for (auto offset : offsets)
|
||||
{
|
||||
if (offset.name.find(name) != std::string::npos)
|
||||
// if (offset.name.find(name) != std::string::npos)
|
||||
if (offset.name == name)
|
||||
{
|
||||
return offset.textFile;
|
||||
}
|
||||
@@ -203,7 +218,8 @@ std::vector<int> *Resource::getTileMap(std::string name)
|
||||
{
|
||||
for (auto tileMap : tileMaps)
|
||||
{
|
||||
if (tileMap.name.find(name) != std::string::npos)
|
||||
// if (tileMap.name.find(name) != std::string::npos)
|
||||
if (tileMap.name == name)
|
||||
{
|
||||
return tileMap.tileMap;
|
||||
}
|
||||
@@ -218,7 +234,8 @@ room_t *Resource::getRoom(std::string name)
|
||||
{
|
||||
for (auto room : rooms)
|
||||
{
|
||||
if (room.name.find(name) != std::string::npos)
|
||||
// if (room.name.find(name) != std::string::npos)
|
||||
if (room.name == name)
|
||||
{
|
||||
return room.room;
|
||||
}
|
||||
|
||||
@@ -311,7 +311,7 @@ void Director::loadResources(section_t section)
|
||||
std::vector<std::string> animationList;
|
||||
|
||||
// Jugador
|
||||
animationList.push_back("player");
|
||||
animationList.push_back("player.ani");
|
||||
|
||||
// Enemigos
|
||||
animationList.push_back("abad.ani");
|
||||
|
||||
@@ -20,8 +20,8 @@ Game::Game(SDL_Renderer *renderer, Screen *screen, Resource *resource, Asset *as
|
||||
|
||||
// ****
|
||||
// this->debug->setEnabled(true);
|
||||
currentRoom = "06.room";
|
||||
const int x = 30;
|
||||
currentRoom = "25.room";
|
||||
const int x = 28;
|
||||
const int y = 13;
|
||||
spawnPoint = {x * 8, y * 8, 0, 0, 0, s_standing, SDL_FLIP_HORIZONTAL};
|
||||
// ****
|
||||
|
||||
Reference in New Issue
Block a user