eliminat codi del JDD
This commit is contained in:
@@ -182,8 +182,6 @@ auto Director::checkProgramArguments(std::vector<std::string> const& args) -> st
|
|||||||
Options::cheats.infinite_lives = Options::Cheat::State::ENABLED;
|
Options::cheats.infinite_lives = Options::Cheat::State::ENABLED;
|
||||||
} else if (argument == "--invincible") {
|
} else if (argument == "--invincible") {
|
||||||
Options::cheats.invincible = Options::Cheat::State::ENABLED;
|
Options::cheats.invincible = Options::Cheat::State::ENABLED;
|
||||||
} else if (argument == "--jailEnabled") {
|
|
||||||
Options::cheats.jail_is_open = Options::Cheat::State::ENABLED;
|
|
||||||
} else if (argument == "--altSkin") {
|
} else if (argument == "--altSkin") {
|
||||||
Options::cheats.alternate_skin = Options::Cheat::State::ENABLED;
|
Options::cheats.alternate_skin = Options::Cheat::State::ENABLED;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -73,7 +73,6 @@ constexpr const char* NOTIFY = "notify.wav"; // Sonido de notificación
|
|||||||
namespace Cheat {
|
namespace Cheat {
|
||||||
constexpr bool INFINITE_LIVES = false; // Vidas infinitas desactivadas por defecto
|
constexpr bool INFINITE_LIVES = false; // Vidas infinitas desactivadas por defecto
|
||||||
constexpr bool INVINCIBLE = false; // Invencibilidad desactivada por defecto
|
constexpr bool INVINCIBLE = false; // Invencibilidad desactivada por defecto
|
||||||
constexpr bool JAIL_IS_OPEN = false; // Jail abierta desactivada por defecto
|
|
||||||
constexpr bool ALTERNATE_SKIN = false; // Skin alternativa desactivada por defecto
|
constexpr bool ALTERNATE_SKIN = false; // Skin alternativa desactivada por defecto
|
||||||
} // namespace Cheat
|
} // namespace Cheat
|
||||||
|
|
||||||
|
|||||||
@@ -25,7 +25,6 @@ Room::Room(const std::string& room_path, std::shared_ptr<Scoreboard::Data> data)
|
|||||||
item_manager_ = std::make_unique<ItemManager>(room->name, data_);
|
item_manager_ = std::make_unique<ItemManager>(room->name, data_);
|
||||||
|
|
||||||
initializeRoom(*room);
|
initializeRoom(*room);
|
||||||
openTheJail(); // Abre la Jail si se da el caso
|
|
||||||
|
|
||||||
// Crea el mapa de colisiones (necesita collision_data_, conveyor_belt_direction_)
|
// Crea el mapa de colisiones (necesita collision_data_, conveyor_belt_direction_)
|
||||||
collision_map_ = std::make_unique<CollisionMap>(collision_data_, conveyor_belt_direction_);
|
collision_map_ = std::make_unique<CollisionMap>(collision_data_, conveyor_belt_direction_);
|
||||||
@@ -81,28 +80,6 @@ void Room::initializeRoom(const Data& room) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Abre la jail para poder entrar
|
|
||||||
void Room::openTheJail() {
|
|
||||||
if (data_->jail_is_open && name_ == "THE JAIL") {
|
|
||||||
// Elimina el último enemigo (Bry debe ser el último enemigo definido en el fichero)
|
|
||||||
if (!enemy_manager_->isEmpty()) {
|
|
||||||
enemy_manager_->removeLastEnemy();
|
|
||||||
}
|
|
||||||
|
|
||||||
// Abre las puertas (tanto en tilemap para renderizado como en collisionmap para colisiones)
|
|
||||||
constexpr int TILE_A = 16 + (13 * MAP_WIDTH);
|
|
||||||
constexpr int TILE_B = 16 + (14 * MAP_WIDTH);
|
|
||||||
if (TILE_A < tile_map_.size()) {
|
|
||||||
tile_map_[TILE_A] = -1; // Renderizado: vacío
|
|
||||||
collision_data_[TILE_A] = -1; // Colisiones: vacío
|
|
||||||
}
|
|
||||||
if (TILE_B < tile_map_.size()) {
|
|
||||||
tile_map_[TILE_B] = -1; // Renderizado: vacío
|
|
||||||
collision_data_[TILE_B] = -1; // Colisiones: vacío
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Dibuja el mapa en pantalla
|
// Dibuja el mapa en pantalla
|
||||||
void Room::renderMap() {
|
void Room::renderMap() {
|
||||||
tilemap_renderer_->render();
|
tilemap_renderer_->render();
|
||||||
|
|||||||
@@ -124,5 +124,4 @@ class Room {
|
|||||||
|
|
||||||
// --- Funciones ---
|
// --- Funciones ---
|
||||||
void initializeRoom(const Data& room); // Inicializa los valores
|
void initializeRoom(const Data& room); // Inicializa los valores
|
||||||
void openTheJail(); // Abre la jail para poder entrar
|
|
||||||
};
|
};
|
||||||
@@ -96,23 +96,8 @@ void Scoreboard::setPaused(bool value) {
|
|||||||
|
|
||||||
// Actualiza el color de la cantidad de items recogidos
|
// Actualiza el color de la cantidad de items recogidos
|
||||||
void Scoreboard::updateItemsColor(float delta_time) {
|
void Scoreboard::updateItemsColor(float delta_time) {
|
||||||
if (!data_->jail_is_open) {
|
// No hay animación de color de items en este juego
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
items_color_timer_ += delta_time;
|
|
||||||
|
|
||||||
// Resetear timer cada 2 ciclos (0.666s total)
|
|
||||||
if (items_color_timer_ >= ITEMS_COLOR_BLINK_DURATION * 2.0F) {
|
|
||||||
items_color_timer_ = 0.0F;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Alternar color cada ITEMS_COLOR_BLINK_DURATION
|
|
||||||
if (items_color_timer_ < ITEMS_COLOR_BLINK_DURATION) {
|
|
||||||
items_color_ = stringToColor("white");
|
items_color_ = stringToColor("white");
|
||||||
} else {
|
|
||||||
items_color_ = stringToColor("magenta");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Devuelve la cantidad de minutos de juego transcurridos
|
// Devuelve la cantidad de minutos de juego transcurridos
|
||||||
|
|||||||
@@ -19,7 +19,6 @@ class Scoreboard {
|
|||||||
bool music{true}; // Indica si ha de sonar la música durante el juego
|
bool music{true}; // Indica si ha de sonar la música durante el juego
|
||||||
Uint8 color{0}; // Color para escribir el texto del marcador
|
Uint8 color{0}; // Color para escribir el texto del marcador
|
||||||
Uint32 ini_clock{0}; // Tiempo inicial para calcular el tiempo transcurrido
|
Uint32 ini_clock{0}; // Tiempo inicial para calcular el tiempo transcurrido
|
||||||
bool jail_is_open{false}; // Indica si se puede entrar a la Jail
|
|
||||||
};
|
};
|
||||||
|
|
||||||
// Métodos públicos
|
// Métodos públicos
|
||||||
|
|||||||
@@ -38,12 +38,11 @@ struct Cheat {
|
|||||||
|
|
||||||
State infinite_lives{Defaults::Cheat::INFINITE_LIVES ? State::ENABLED : State::DISABLED}; // Indica si el jugador dispone de vidas infinitas
|
State infinite_lives{Defaults::Cheat::INFINITE_LIVES ? State::ENABLED : State::DISABLED}; // Indica si el jugador dispone de vidas infinitas
|
||||||
State invincible{Defaults::Cheat::INVINCIBLE ? State::ENABLED : State::DISABLED}; // Indica si el jugador puede morir
|
State invincible{Defaults::Cheat::INVINCIBLE ? State::ENABLED : State::DISABLED}; // Indica si el jugador puede morir
|
||||||
State jail_is_open{Defaults::Cheat::JAIL_IS_OPEN ? State::ENABLED : State::DISABLED}; // Indica si la Jail está abierta
|
|
||||||
State alternate_skin{Defaults::Cheat::ALTERNATE_SKIN ? State::ENABLED : State::DISABLED}; // Indica si se usa una skin diferente para el jugador
|
State alternate_skin{Defaults::Cheat::ALTERNATE_SKIN ? State::ENABLED : State::DISABLED}; // Indica si se usa una skin diferente para el jugador
|
||||||
|
|
||||||
// Método para comprobar si alguno de los tres primeros trucos está activo
|
// Método para comprobar si alguno de los trucos está activo
|
||||||
[[nodiscard]] auto enabled() const -> bool {
|
[[nodiscard]] auto enabled() const -> bool {
|
||||||
return infinite_lives == State::ENABLED || invincible == State::ENABLED || jail_is_open == State::ENABLED;
|
return infinite_lives == State::ENABLED || invincible == State::ENABLED;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -33,7 +33,7 @@
|
|||||||
|
|
||||||
// Constructor
|
// Constructor
|
||||||
Game::Game(Mode mode)
|
Game::Game(Mode mode)
|
||||||
: scoreboard_data_(std::make_shared<Scoreboard::Data>(0, 9, 0, true, 0, SDL_GetTicks(), Options::cheats.jail_is_open == Options::Cheat::State::ENABLED)),
|
: scoreboard_data_(std::make_shared<Scoreboard::Data>(0, 9, 0, true, 0, SDL_GetTicks())),
|
||||||
scoreboard_(std::make_shared<Scoreboard>(scoreboard_data_)),
|
scoreboard_(std::make_shared<Scoreboard>(scoreboard_data_)),
|
||||||
room_tracker_(std::make_shared<RoomTracker>()),
|
room_tracker_(std::make_shared<RoomTracker>()),
|
||||||
mode_(mode),
|
mode_(mode),
|
||||||
@@ -450,11 +450,6 @@ void Game::handleDebugEvents(const SDL_Event& event) {
|
|||||||
player_->setColor();
|
player_->setColor();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case SDLK_3:
|
|
||||||
Options::cheats.jail_is_open = Options::cheats.jail_is_open == Options::Cheat::State::ENABLED ? Options::Cheat::State::DISABLED : Options::Cheat::State::ENABLED;
|
|
||||||
Notifier::get()->show({std::string("JAIL IS OPEN ") + (Options::cheats.jail_is_open == Options::Cheat::State::ENABLED ? "ENABLED" : "DISABLED")}, Notifier::Style::DEFAULT, -1, true);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case SDLK_0:
|
case SDLK_0:
|
||||||
Screen::get()->toggleDebugInfo();
|
Screen::get()->toggleDebugInfo();
|
||||||
break;
|
break;
|
||||||
@@ -654,11 +649,9 @@ void Game::setScoreBoardColor() {
|
|||||||
// Comprueba si ha finalizado el juego
|
// Comprueba si ha finalizado el juego
|
||||||
auto Game::isGameCompleted() -> bool {
|
auto Game::isGameCompleted() -> bool {
|
||||||
const bool IS_ON_THE_ROOM = room_->getName() == "THE JAIL"; // Estar en la habitación que toca
|
const bool IS_ON_THE_ROOM = room_->getName() == "THE JAIL"; // Estar en la habitación que toca
|
||||||
const bool HAVE_THE_ITEMS = scoreboard_data_->items >= int(total_items_ * 0.9F) || Options::cheats.jail_is_open == Options::Cheat::State::ENABLED; // Con mas del 90% de los items recogidos
|
const bool HAVE_THE_ITEMS = scoreboard_data_->items >= int(total_items_ * 0.9F); // Con mas del 90% de los items recogidos
|
||||||
const bool IS_ON_THE_DOOR = player_->getRect().x <= 128; // Y en la ubicación que toca (En la puerta)
|
const bool IS_ON_THE_DOOR = player_->getRect().x <= 128; // Y en la ubicación que toca (En la puerta)
|
||||||
|
|
||||||
scoreboard_data_->jail_is_open = HAVE_THE_ITEMS;
|
|
||||||
|
|
||||||
if (HAVE_THE_ITEMS && IS_ON_THE_ROOM && IS_ON_THE_DOOR) {
|
if (HAVE_THE_ITEMS && IS_ON_THE_ROOM && IS_ON_THE_DOOR) {
|
||||||
// Iniciar transición de fade en vez de cambio inmediato de escena
|
// Iniciar transición de fade en vez de cambio inmediato de escena
|
||||||
transitionToState(State::FADE_TO_ENDING);
|
transitionToState(State::FADE_TO_ENDING);
|
||||||
@@ -728,7 +721,7 @@ void Game::fillRoomNameTexture() {
|
|||||||
|
|
||||||
// Inicializa al jugador
|
// Inicializa al jugador
|
||||||
void Game::initPlayer(const Player::SpawnData& spawn_point, std::shared_ptr<Room> room) {
|
void Game::initPlayer(const Player::SpawnData& spawn_point, std::shared_ptr<Room> room) {
|
||||||
const Player::Data PLAYER{.spawn_data = spawn_point, .animations_path = "player.yalm", .room = std::move(room)};
|
const Player::Data PLAYER{.spawn_data = spawn_point, .animations_path = "player.yaml", .room = std::move(room)};
|
||||||
player_ = std::make_shared<Player>(PLAYER);
|
player_ = std::make_shared<Player>(PLAYER);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user