Trabajando en los frames iniciales aleatorios de los enemigos

This commit is contained in:
2022-09-20 22:33:40 +02:00
parent 03fedbe3b0
commit bfb2610f6f
24 changed files with 17 additions and 43 deletions

View File

@@ -29,13 +29,7 @@ AnimatedSprite::~AnimatedSprite()
int AnimatedSprite::getIndex(std::string name)
{
int index = -1;
/*for (int i = 0; i < (int)animation.size(); i++)
{
if (animation[i].name == name)
{
index = i;
}
}*/
for (auto a : animation)
{
index++;
@@ -46,7 +40,6 @@ int AnimatedSprite::getIndex(std::string name)
}
printf("** Warning: could not find \"%s\" animation\n", name.c_str());
index = 0;
return -1;
}
@@ -230,17 +223,23 @@ bool AnimatedSprite::load(std::string filePath)
{
frames_per_row = std::stoi(line.substr(pos + 1, line.length()));
}
else if (line.substr(0, pos) == "frame_width")
{
frame_width = std::stoi(line.substr(pos + 1, line.length()));
// Normaliza valores
if (frames_per_row == 0)
{
frames_per_row = texture->getWidth() / frame_width;
}
}
else if (line.substr(0, pos) == "frame_height")
{
frame_height = std::stoi(line.substr(pos + 1, line.length()));
}
else
{
printf("Warning: file %s, unknown parameter \"%s\"\n", filename.c_str(), line.substr(0, pos).c_str());
@@ -261,12 +260,6 @@ bool AnimatedSprite::load(std::string filePath)
success = false;
}
// Normaliza valores
if (frames_per_row == 0)
{
frames_per_row = texture->getWidth() / frame_width;
}
// Pone un valor por defecto
setPos({0, 0, frame_width, frame_height});