forked from jaildesigner-jailgames/jaildoctors_dilemma
Completadas las superficies automáticas
This commit is contained in:
@@ -183,8 +183,16 @@ void Player::checkInput()
|
||||
}
|
||||
else
|
||||
{ // El movimiento lo proporciona la superficie
|
||||
vx = 0.6f;
|
||||
sprite->setFlip(SDL_FLIP_NONE);
|
||||
vx = 0.6f * room->getAutoSurfaceDirection();
|
||||
|
||||
if (vx > 0.0f)
|
||||
{
|
||||
sprite->setFlip(SDL_FLIP_NONE);
|
||||
}
|
||||
else
|
||||
{
|
||||
sprite->setFlip(SDL_FLIP_HORIZONTAL);
|
||||
}
|
||||
}
|
||||
|
||||
if (input->checkInput(INPUT_UP, REPEAT_TRUE))
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
@@ -17,19 +17,6 @@
|
||||
#ifndef ROOM_H
|
||||
#define ROOM_H
|
||||
|
||||
/*
|
||||
Cada habitación se crea y destruye cada vez que se entra o sale de la misma
|
||||
Cada habitacion tiene lo siguiente:
|
||||
- NOMBRE (texto)
|
||||
- COLOR DE FONDO (texto)
|
||||
- COLOR DEL BORDE (texto)
|
||||
- SET DE TILES (texto, hace referencia a un png de la colección)
|
||||
- LIMITE SUPERIOR (ID de la habitación superior), INFERIOR, IZQUIERDO y DERECHO
|
||||
- MAPA DE TILES (array con los indices de los tiles a utilizar) <-- hay que decidir si cada tile del set ya
|
||||
tierne propiedades o se ponen en un mapa aparte
|
||||
- LISTADO DE ENEMIGOS (tipo, posicion, dx, dy)
|
||||
- LISTADO DE ITEMS (tipo, posicion)
|
||||
*/
|
||||
enum tile_e
|
||||
{
|
||||
t_empty,
|
||||
@@ -84,6 +71,7 @@ private:
|
||||
int counter; // Contador para lo que haga falta
|
||||
std::vector<aTile_t> aTile; // Vector con los indices de tiles animados
|
||||
std::vector<h_line_t> autoSurfaces; // Lista con las superficies automaticas de la habitación
|
||||
int autoSurfaceDirection; // Sentido en el que arrastran las superficies automáticas de la habitación
|
||||
|
||||
int tileSize; // Ancho del tile en pixels
|
||||
int mapWidth; // Ancho del mapa en tiles
|
||||
@@ -228,6 +216,9 @@ public:
|
||||
|
||||
// Quita el modo pausa del mapa
|
||||
void resume();
|
||||
|
||||
// Obten la direccion de las superficies automaticas
|
||||
int getAutoSurfaceDirection();
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user