Compare commits

3 Commits

Author SHA1 Message Date
f438e8946b style: canviar border_ a enum class 2025-03-20 14:06:58 +01:00
68c97610fb style: canvis en Game 2025-03-20 13:46:31 +01:00
7746b679b4 style: canvis en Player 2025-03-20 13:44:37 +01:00
7 changed files with 96 additions and 93 deletions

View File

@@ -34,11 +34,6 @@ constexpr int PLAY_AREA_CENTER_Y = PLAY_AREA_TOP + (PLAY_AREA_HEIGHT / 2);
constexpr int PLAY_AREA_FIRST_QUARTER_Y = PLAY_AREA_HEIGHT / 4; constexpr int PLAY_AREA_FIRST_QUARTER_Y = PLAY_AREA_HEIGHT / 4;
constexpr int PLAY_AREA_THIRD_QUARTER_Y = (PLAY_AREA_HEIGHT / 4) * 3; constexpr int PLAY_AREA_THIRD_QUARTER_Y = (PLAY_AREA_HEIGHT / 4) * 3;
constexpr int BORDER_TOP = 0;
constexpr int BORDER_RIGHT = 1;
constexpr int BORDER_BOTTOM = 2;
constexpr int BORDER_LEFT = 3;
// Anclajes de pantalla // Anclajes de pantalla
constexpr int GAMECANVAS_CENTER_X = GAMECANVAS_WIDTH / 2; constexpr int GAMECANVAS_CENTER_X = GAMECANVAS_WIDTH / 2;
constexpr int GAMECANVAS_FIRST_QUARTER_X = GAMECANVAS_WIDTH / 4; constexpr int GAMECANVAS_FIRST_QUARTER_X = GAMECANVAS_WIDTH / 4;

View File

@@ -6,7 +6,7 @@
#include "asset.h" // Para Asset #include "asset.h" // Para Asset
#include "cheevos.h" // Para Cheevos #include "cheevos.h" // Para Cheevos
#include "debug.h" // Para Debug #include "debug.h" // Para Debug
#include "defines.h" // Para BLOCK, PLAY_AREA_HEIGHT, BORDER_BOTTOM #include "defines.h" // Para BLOCK, PLAY_AREA_HEIGHT, RoomBorder::BOTTOM
#include "global_events.h" // Para check #include "global_events.h" // Para check
#include "global_inputs.h" // Para check #include "global_inputs.h" // Para check
#include "input.h" // Para Input, InputAction, INPUT_DO_NOT_ALLOW_REPEAT #include "input.h" // Para Input, InputAction, INPUT_DO_NOT_ALLOW_REPEAT
@@ -141,7 +141,7 @@ void Game::update()
if (mode_ == GameMode::GAME) if (mode_ == GameMode::GAME)
{ {
player_->update(); player_->update();
checkPlayerOnBorder(); checkPlayerIsOnBorder();
checkPlayerAndItems(); checkPlayerAndItems();
checkPlayerAndEnemies(); checkPlayerAndEnemies();
checkIfPlayerIsAlive(); checkIfPlayerIsAlive();
@@ -249,19 +249,19 @@ void Game::checkDebugEvents(const SDL_Event &event)
break; break;
case SDL_SCANCODE_W: case SDL_SCANCODE_W:
changeRoom(room_->getRoom(BORDER_TOP)); changeRoom(room_->getRoom(RoomBorder::TOP));
break; break;
case SDL_SCANCODE_A: case SDL_SCANCODE_A:
changeRoom(room_->getRoom(BORDER_LEFT)); changeRoom(room_->getRoom(RoomBorder::LEFT));
break; break;
case SDL_SCANCODE_S: case SDL_SCANCODE_S:
changeRoom(room_->getRoom(BORDER_BOTTOM)); changeRoom(room_->getRoom(RoomBorder::BOTTOM));
break; break;
case SDL_SCANCODE_D: case SDL_SCANCODE_D:
changeRoom(room_->getRoom(BORDER_RIGHT)); changeRoom(room_->getRoom(RoomBorder::RIGHT));
break; break;
case SDL_SCANCODE_7: case SDL_SCANCODE_7:
@@ -326,7 +326,7 @@ bool Game::changeRoom(const std::string &room_path)
} }
// Comprueba si el jugador esta en el borde de la pantalla // Comprueba si el jugador esta en el borde de la pantalla
void Game::checkPlayerOnBorder() void Game::checkPlayerIsOnBorder()
{ {
if (player_->getOnBorder()) if (player_->getOnBorder())
{ {
@@ -661,6 +661,18 @@ void Game::createRoomNameTexture()
room_name_rect_ = {0, PLAY_AREA_HEIGHT, options.game.width, text->getCharacterSize() * 2}; room_name_rect_ = {0, PLAY_AREA_HEIGHT, options.game.width, text->getCharacterSize() * 2};
} }
// Hace sonar la música
void Game::keepMusicPlaying()
{
const std::string music_path = mode_ == GameMode::GAME ? "game.ogg" : "title.ogg";
// Si la música no está sonando
if (JA_GetMusicState() == JA_MUSIC_INVALID || JA_GetMusicState() == JA_MUSIC_STOPPED)
{
JA_PlayMusic(Resource::get()->getMusic(music_path));
}
}
// DEMO MODE: Inicializa las variables para el modo demo // DEMO MODE: Inicializa las variables para el modo demo
void Game::DEMO_init() void Game::DEMO_init()
{ {
@@ -692,16 +704,4 @@ void Game::DEMO_checkRoomChange()
} }
} }
} }
}
// Hace sonar la música
void Game::keepMusicPlaying()
{
const std::string music_path = mode_ == GameMode::GAME ? "game.ogg" : "title.ogg";
// Si la música no está sonando
if (JA_GetMusicState() == JA_MUSIC_INVALID || JA_GetMusicState() == JA_MUSIC_STOPPED)
{
JA_PlayMusic(Resource::get()->getMusic(music_path));
}
} }

View File

@@ -92,7 +92,7 @@ private:
void checkInput(); void checkInput();
// Comprueba si el jugador esta en el borde de la pantalla y actua // Comprueba si el jugador esta en el borde de la pantalla y actua
void checkPlayerOnBorder(); void checkPlayerIsOnBorder();
// Comprueba las colisiones del jugador con los enemigos // Comprueba las colisiones del jugador con los enemigos
bool checkPlayerAndEnemies(); bool checkPlayerAndEnemies();
@@ -151,15 +151,15 @@ private:
// Crea la textura para poner el nombre de la habitación // Crea la textura para poner el nombre de la habitación
void createRoomNameTexture(); void createRoomNameTexture();
// Hace sonar la música
void keepMusicPlaying();
// DEMO MODE: Inicializa las variables para el modo demo // DEMO MODE: Inicializa las variables para el modo demo
void DEMO_init(); void DEMO_init();
// DEMO MODE: Comprueba si se ha de cambiar de habitación // DEMO MODE: Comprueba si se ha de cambiar de habitación
void DEMO_checkRoomChange(); void DEMO_checkRoomChange();
// Hace sonar la música
void keepMusicPlaying();
public: public:
// Constructor // Constructor
explicit Game(GameMode mode); explicit Game(GameMode mode);

View File

@@ -3,7 +3,7 @@
#include <algorithm> // Para max, min #include <algorithm> // Para max, min
#include <cmath> // Para ceil, abs #include <cmath> // Para ceil, abs
#include "debug.h" // Para Debug #include "debug.h" // Para Debug
#include "defines.h" // Para BORDER_BOTTOM, BORDER_LEFT, BORDER_RIGHT #include "defines.h" // Para RoomBorder::BOTTOM, RoomBorder::LEFT, RoomBorder::RIGHT
#include "input.h" // Para Input, InputAction #include "input.h" // Para Input, InputAction
#include "jail_audio.h" // Para JA_PlaySound #include "jail_audio.h" // Para JA_PlaySound
#include "options.h" // Para Cheat, Options, options #include "options.h" // Para Cheat, Options, options
@@ -132,25 +132,25 @@ void Player::checkBorders()
{ {
if (x_ < PLAY_AREA_LEFT) if (x_ < PLAY_AREA_LEFT)
{ {
border_ = BORDER_LEFT; border_ = RoomBorder::LEFT;
is_on_border_ = true; is_on_border_ = true;
} }
else if (x_ + WIDTH_ > PLAY_AREA_RIGHT) else if (x_ + WIDTH_ > PLAY_AREA_RIGHT)
{ {
border_ = BORDER_RIGHT; border_ = RoomBorder::RIGHT;
is_on_border_ = true; is_on_border_ = true;
} }
else if (y_ < PLAY_AREA_TOP) else if (y_ < PLAY_AREA_TOP)
{ {
border_ = BORDER_TOP; border_ = RoomBorder::TOP;
is_on_border_ = true; is_on_border_ = true;
} }
else if (y_ + HEIGHT_ > PLAY_AREA_BOTTOM) else if (y_ + HEIGHT_ > PLAY_AREA_BOTTOM)
{ {
border_ = BORDER_BOTTOM; border_ = RoomBorder::BOTTOM;
is_on_border_ = true; is_on_border_ = true;
} }
@@ -204,26 +204,25 @@ void Player::switchBorders()
{ {
switch (border_) switch (border_)
{ {
case BORDER_TOP: case RoomBorder::TOP:
y_ = PLAY_AREA_BOTTOM - HEIGHT_ - BLOCK; y_ = PLAY_AREA_BOTTOM - HEIGHT_ - BLOCK;
setState(PlayerState::STANDING); setState(PlayerState::STANDING);
break; break;
case BORDER_BOTTOM: case RoomBorder::BOTTOM:
y_ = PLAY_AREA_TOP; y_ = PLAY_AREA_TOP;
setState(PlayerState::STANDING); setState(PlayerState::STANDING);
break; break;
case BORDER_RIGHT: case RoomBorder::RIGHT:
x_ = PLAY_AREA_LEFT; x_ = PLAY_AREA_LEFT;
break; break;
case BORDER_LEFT: case RoomBorder::LEFT:
x_ = PLAY_AREA_RIGHT - WIDTH_; x_ = PLAY_AREA_RIGHT - WIDTH_;
break; break;
default: default:
// Manejo para casos no previstos (opcional)
break; break;
} }
@@ -235,13 +234,13 @@ void Player::switchBorders()
// Aplica gravedad al jugador // Aplica gravedad al jugador
void Player::applyGravity() void Player::applyGravity()
{ {
constexpr float GF = 0.035f; constexpr float GRAVITY_FORCE = 0.035f;
// La gravedad solo se aplica cuando el jugador esta saltando // La gravedad solo se aplica cuando el jugador esta saltando
// Nunca mientras cae o esta de pie // Nunca mientras cae o esta de pie
if (state_ == PlayerState::JUMPING) if (state_ == PlayerState::JUMPING)
{ {
vy_ += GF; vy_ += GRAVITY_FORCE;
if (vy_ > MAX_VY_) if (vy_ > MAX_VY_)
{ {
vy_ = MAX_VY_; vy_ = MAX_VY_;
@@ -275,10 +274,10 @@ void Player::move()
#endif #endif
// Comprueba la colisión con las superficies // Comprueba la colisión con las superficies
const int pos = room_->checkRightSurfaces(&proj); const int POS = room_->checkRightSurfaces(&proj);
// Calcula la nueva posición // Calcula la nueva posición
if (pos == -1) if (POS == -1)
{ {
// Si no hay colisión // Si no hay colisión
x_ += vx_; x_ += vx_;
@@ -286,14 +285,14 @@ void Player::move()
else else
{ {
// Si hay colisión lo mueve hasta donde no colisiona // Si hay colisión lo mueve hasta donde no colisiona
x_ = pos + 1; x_ = POS + 1;
} }
// Si ha tocado alguna rampa mientras camina (sin saltar), asciende // Si ha tocado alguna rampa mientras camina (sin saltar), asciende
if (state_ != PlayerState::JUMPING) if (state_ != PlayerState::JUMPING)
{ {
LineVertical leftSide = {static_cast<int>(x_), static_cast<int>(y_) + HEIGHT_ - 2, static_cast<int>(y_) + HEIGHT_ - 1}; // Comprueba solo los dos pixels de abajo const LineVertical LEFT_SIDE = {static_cast<int>(x_), static_cast<int>(y_) + HEIGHT_ - 2, static_cast<int>(y_) + HEIGHT_ - 1}; // Comprueba solo los dos pixels de abajo
const int ly = room_->checkLeftSlopes(&leftSide); const int ly = room_->checkLeftSlopes(&LEFT_SIDE);
if (ly > -1) if (ly > -1)
{ {
y_ = ly - HEIGHT_; y_ = ly - HEIGHT_;
@@ -322,10 +321,10 @@ void Player::move()
#endif #endif
// Comprueba la colisión // Comprueba la colisión
const int pos = room_->checkLeftSurfaces(&proj); const int POS = room_->checkLeftSurfaces(&proj);
// Calcula la nueva posición // Calcula la nueva posición
if (pos == -1) if (POS == -1)
{ {
// Si no hay colisión // Si no hay colisión
x_ += vx_; x_ += vx_;
@@ -333,17 +332,17 @@ void Player::move()
else else
{ {
// Si hay colisión lo mueve hasta donde no colisiona // Si hay colisión lo mueve hasta donde no colisiona
x_ = pos - WIDTH_; x_ = POS - WIDTH_;
} }
// Si ha tocado alguna rampa mientras camina (sin saltar), asciende // Si ha tocado alguna rampa mientras camina (sin saltar), asciende
if (state_ != PlayerState::JUMPING) if (state_ != PlayerState::JUMPING)
{ {
LineVertical rightSide = {static_cast<int>(x_) + WIDTH_ - 1, static_cast<int>(y_) + HEIGHT_ - 2, static_cast<int>(y_) + HEIGHT_ - 1}; // Comprueba solo los dos pixels de abajo const LineVertical RIGHT_SIDE = {static_cast<int>(x_) + WIDTH_ - 1, static_cast<int>(y_) + HEIGHT_ - 2, static_cast<int>(y_) + HEIGHT_ - 1}; // Comprueba solo los dos pixels de abajo
const int ry = room_->checkRightSlopes(&rightSide); const int RY = room_->checkRightSlopes(&RIGHT_SIDE);
if (ry > -1) if (RY > -1)
{ {
y_ = ry - HEIGHT_; y_ = RY - HEIGHT_;
} }
} }
@@ -385,10 +384,10 @@ void Player::move()
#endif #endif
// Comprueba la colisión // Comprueba la colisión
const int pos = room_->checkBottomSurfaces(&proj); const int POS = room_->checkBottomSurfaces(&proj);
// Calcula la nueva posición // Calcula la nueva posición
if (pos == -1) if (POS == -1)
{ {
// Si no hay colisión // Si no hay colisión
y_ += vy_; y_ += vy_;
@@ -396,7 +395,7 @@ void Player::move()
else else
{ {
// Si hay colisión lo mueve hasta donde no colisiona y entra en caída // Si hay colisión lo mueve hasta donde no colisiona y entra en caída
y_ = pos + 1; y_ = POS + 1;
setState(PlayerState::FALLING); setState(PlayerState::FALLING);
} }
} }
@@ -416,11 +415,11 @@ void Player::move()
#endif #endif
// Comprueba la colisión con las superficies normales y las automáticas // Comprueba la colisión con las superficies normales y las automáticas
const int pos = std::max(room_->checkTopSurfaces(&proj), room_->checkAutoSurfaces(&proj)); const int POS = std::max(room_->checkTopSurfaces(&proj), room_->checkAutoSurfaces(&proj));
if (pos > -1) if (POS > -1)
{ {
// Si hay colisión lo mueve hasta donde no colisiona y pasa a estar sobre la superficie // Si hay colisión lo mueve hasta donde no colisiona y pasa a estar sobre la superficie
y_ = pos - HEIGHT_; y_ = POS - HEIGHT_;
setState(PlayerState::STANDING); setState(PlayerState::STANDING);
// Deja de estar enganchado a la superficie automatica // Deja de estar enganchado a la superficie automatica
@@ -431,18 +430,18 @@ void Player::move()
// Si no hay colisión con los muros, comprueba la colisión con las rampas // Si no hay colisión con los muros, comprueba la colisión con las rampas
if (state_ != PlayerState::JUMPING) if (state_ != PlayerState::JUMPING)
{ // Las rampas no se miran si se está saltando { // Las rampas no se miran si se está saltando
LineVertical leftSide = {proj.x, proj.y, proj.y + proj.h - 1}; const LineVertical LEFT_SIDE = {proj.x, proj.y, proj.y + proj.h - 1};
LineVertical rightSide = {proj.x + proj.w - 1, proj.y, proj.y + proj.h - 1}; const LineVertical RIGHT_SIDE = {proj.x + proj.w - 1, proj.y, proj.y + proj.h - 1};
const int p = std::max(room_->checkRightSlopes(&rightSide), room_->checkLeftSlopes(&leftSide)); const int POINT = std::max(room_->checkRightSlopes(&RIGHT_SIDE), room_->checkLeftSlopes(&LEFT_SIDE));
if (p > -1) if (POINT > -1)
{ {
// No está saltando y hay colisión con una rampa // No está saltando y hay colisión con una rampa
// Calcula la nueva posición // Calcula la nueva posición
y_ = p - HEIGHT_; y_ = POINT - HEIGHT_;
setState(PlayerState::STANDING); setState(PlayerState::STANDING);
#ifdef DEBUG #ifdef DEBUG
debug_color_ = {255, 255, 0}; debug_color_ = {255, 255, 0};
debug_point_ = {(int)x_ + (WIDTH_ / 2), p}; debug_point_ = {(int)x_ + (WIDTH_ / 2), POINT};
#endif #endif
} }
else else
@@ -529,70 +528,70 @@ void Player::playFallSound()
// Comprueba si el jugador tiene suelo debajo de los pies // Comprueba si el jugador tiene suelo debajo de los pies
bool Player::isOnFloor() bool Player::isOnFloor()
{ {
bool onFloor = false; bool on_floor = false;
bool onSlopeL = false; bool on_slope_l = false;
bool onSlopeR = false; bool on_slope_r = false;
updateFeet(); updateFeet();
// Comprueba las superficies // Comprueba las superficies
for (auto f : under_feet_) for (auto f : under_feet_)
{ {
onFloor |= room_->checkTopSurfaces(&f); on_floor |= room_->checkTopSurfaces(&f);
onFloor |= room_->checkAutoSurfaces(&f); on_floor |= room_->checkAutoSurfaces(&f);
} }
// Comprueba las rampas // Comprueba las rampas
onSlopeL = room_->checkLeftSlopes(&under_feet_[0]); on_slope_l = room_->checkLeftSlopes(&under_feet_[0]);
onSlopeR = room_->checkRightSlopes(&under_feet_[1]); on_slope_r = room_->checkRightSlopes(&under_feet_[1]);
#ifdef DEBUG #ifdef DEBUG
if (onFloor) if (on_floor)
{ {
Debug::get()->add("ON_FLOOR"); Debug::get()->add("ON_FLOOR");
} }
if (onSlopeL) if (on_slope_l)
{ {
Debug::get()->add("ON_SLOPE_L: " + std::to_string(under_feet_[0].x) + "," + std::to_string(under_feet_[0].y)); Debug::get()->add("ON_SLOPE_L: " + std::to_string(under_feet_[0].x) + "," + std::to_string(under_feet_[0].y));
} }
if (onSlopeR) if (on_slope_r)
{ {
Debug::get()->add("ON_SLOPE_R: " + std::to_string(under_feet_[1].x) + "," + std::to_string(under_feet_[1].y)); Debug::get()->add("ON_SLOPE_R: " + std::to_string(under_feet_[1].x) + "," + std::to_string(under_feet_[1].y));
} }
#endif #endif
return onFloor || onSlopeL || onSlopeR; return on_floor || on_slope_l || on_slope_r;
} }
// Comprueba si el jugador esta sobre una superficie automática // Comprueba si el jugador esta sobre una superficie automática
bool Player::isOnAutoSurface() bool Player::isOnAutoSurface()
{ {
bool onAutoSurface = false; bool on_auto_surface = false;
updateFeet(); updateFeet();
// Comprueba las superficies // Comprueba las superficies
for (auto f : under_feet_) for (auto f : under_feet_)
{ {
onAutoSurface |= room_->checkAutoSurfaces(&f); on_auto_surface |= room_->checkAutoSurfaces(&f);
} }
#ifdef DEBUG #ifdef DEBUG
if (onAutoSurface) if (on_auto_surface)
{ {
Debug::get()->add("ON_AUTO_SURFACE"); Debug::get()->add("ON_AUTO_SURFACE");
} }
#endif #endif
return onAutoSurface; return on_auto_surface;
} }
// Comprueba si el jugador está sobre una rampa hacia abajo // Comprueba si el jugador está sobre una rampa hacia abajo
bool Player::isOnDownSlope() bool Player::isOnDownSlope()
{ {
bool onSlope = false; bool on_slope = false;
updateFeet(); updateFeet();
@@ -602,17 +601,17 @@ bool Player::isOnDownSlope()
under_feet_[1].y += 1; under_feet_[1].y += 1;
// Comprueba las rampas // Comprueba las rampas
onSlope |= room_->checkLeftSlopes(&under_feet_[0]); on_slope |= room_->checkLeftSlopes(&under_feet_[0]);
onSlope |= room_->checkRightSlopes(&under_feet_[1]); on_slope |= room_->checkRightSlopes(&under_feet_[1]);
#ifdef DEBUG #ifdef DEBUG
if (onSlope) if (on_slope)
{ {
Debug::get()->add("ON_DOWN_SLOPE"); Debug::get()->add("ON_DOWN_SLOPE");
} }
#endif #endif
return onSlope; return on_slope;
} }
// Comprueba que el jugador no toque ningun tile de los que matan // Comprueba que el jugador no toque ningun tile de los que matan

View File

@@ -9,7 +9,7 @@
#include "defines.h" // Para BORDER_TOP, BLOCK #include "defines.h" // Para BORDER_TOP, BLOCK
#include "s_animated_sprite.h" // Para SAnimatedSprite #include "s_animated_sprite.h" // Para SAnimatedSprite
#include "utils.h" // Para Color #include "utils.h" // Para Color
class Room; // lines 12-12 #include "room.h"
struct JA_Sound_t; // lines 13-13 struct JA_Sound_t; // lines 13-13
enum class PlayerState enum class PlayerState
@@ -78,7 +78,7 @@ public:
bool is_alive_ = true; // Indica si el jugador esta vivo o no bool is_alive_ = true; // Indica si el jugador esta vivo o no
bool is_paused_ = false; // Indica si el jugador esta en modo pausa bool is_paused_ = false; // Indica si el jugador esta en modo pausa
bool auto_movement_ = false; // Indica si esta siendo arrastrado por una superficie automatica bool auto_movement_ = false; // Indica si esta siendo arrastrado por una superficie automatica
int border_ = BORDER_TOP; // Indica en cual de los cuatro bordes se encuentra RoomBorder border_ = RoomBorder::TOP; // Indica en cual de los cuatro bordes se encuentra
SDL_Rect last_position_; // Contiene la ultima posición del jugador, por si hay que deshacer algun movimiento SDL_Rect last_position_; // Contiene la ultima posición del jugador, por si hay que deshacer algun movimiento
int jump_init_pos_; // Valor del eje Y en el que se inicia el salto int jump_init_pos_; // Valor del eje Y en el que se inicia el salto
std::vector<JA_Sound_t *> jumping_sound_; // Vecor con todos los sonidos del salto std::vector<JA_Sound_t *> jumping_sound_; // Vecor con todos los sonidos del salto
@@ -175,7 +175,7 @@ public:
bool getOnBorder() { return is_on_border_; } bool getOnBorder() { return is_on_border_; }
// Indica en cual de los cuatro bordes se encuentra // Indica en cual de los cuatro bordes se encuentra
int getBorder() { return border_; } RoomBorder getBorder() { return border_; }
// Cambia al jugador de un borde al opuesto. Util para el cambio de pantalla // Cambia al jugador de un borde al opuesto. Util para el cambio de pantalla
void switchBorders(); void switchBorders();

View File

@@ -645,23 +645,23 @@ void Room::update()
} }
// Devuelve la cadena del fichero de la habitación contigua segun el borde // Devuelve la cadena del fichero de la habitación contigua segun el borde
std::string Room::getRoom(int border) std::string Room::getRoom(RoomBorder border)
{ {
switch (border) switch (border)
{ {
case BORDER_TOP: case RoomBorder::TOP:
return upper_room_; return upper_room_;
break; break;
case BORDER_BOTTOM: case RoomBorder::BOTTOM:
return lower_room_; return lower_room_;
break; break;
case BORDER_RIGHT: case RoomBorder::RIGHT:
return right_room_; return right_room_;
break; break;
case BORDER_LEFT: case RoomBorder::LEFT:
return left_room_; return left_room_;
break; break;

View File

@@ -23,6 +23,15 @@ enum class TileType
ANIMATED ANIMATED
}; };
enum class RoomBorder : int
{
TOP = 0,
RIGHT = 1,
BOTTOM = 2,
LEFT = 3
};
struct AnimatedTile struct AnimatedTile
{ {
std::shared_ptr<SSprite> sprite; // SSprite para dibujar el tile std::shared_ptr<SSprite> sprite; // SSprite para dibujar el tile
@@ -179,7 +188,7 @@ public:
void update(); void update();
// Devuelve la cadena del fichero de la habitación contigua segun el borde // Devuelve la cadena del fichero de la habitación contigua segun el borde
std::string getRoom(int border); std::string getRoom(RoomBorder border);
// Devuelve el tipo de tile que hay en ese pixel // Devuelve el tipo de tile que hay en ese pixel
TileType getTile(SDL_Point point); TileType getTile(SDL_Point point);