Completadas las superficies automáticas

This commit is contained in:
2022-09-25 14:34:40 +02:00
parent dea16e0004
commit b88df7c9e6
5 changed files with 40 additions and 23 deletions

View File

@@ -13,6 +13,7 @@ Room::Room(std::string file, SDL_Renderer *renderer, Screen *screen, Asset *asse
paused = false;
itemColor1 = stringToColor("magenta");
itemColor2 = stringToColor("yellow");
autoSurfaceDirection = 1;
counter = 0;
// Copia los punteros a objetos
@@ -339,14 +340,15 @@ bool Room::setVars(std::string var, std::string value)
roomRight = value;
}
else if (var == "tilemap")
else if (var == "autoSurface")
{
// Se introducen los valores separados por comas en un vector
std::stringstream ss(value);
std::string tmp;
while (getline(ss, tmp, ','))
if (value == "right")
{
tilemap.push_back(std::stoi(tmp));
autoSurfaceDirection = 1;
}
else
{
autoSurfaceDirection = -1;
}
}
@@ -1181,7 +1183,16 @@ void Room::setAnimatedTiles()
void Room::updateAnimatedTiles()
{
const int numFrames = 4;
const int offset = ((counter / 3) % numFrames * tileSize);
int offset = 0;
if (autoSurfaceDirection == -1)
{
offset = ((counter / 3) % numFrames * tileSize);
}
else
{
offset = ((numFrames - 1 - ((counter / 3) % numFrames)) * tileSize);
}
for (auto &a : aTile)
{
SDL_Rect rect = a.sprite->getSpriteClip();
@@ -1365,4 +1376,10 @@ void Room::pause()
void Room::resume()
{
paused = false;
}
// Obten la direccion de las superficies automaticas
int Room::getAutoSurfaceDirection()
{
return autoSurfaceDirection;
}