Solventat bug amb el punter a ScoreboardData

This commit is contained in:
2025-02-27 14:17:00 +01:00
parent c6474cb2da
commit 0cec9f8556
20 changed files with 246 additions and 223 deletions

View File

@@ -27,7 +27,8 @@ Demo::Demo()
debug_(Debug::get())
{
// Inicia algunas variables
board_.ini_clock = SDL_GetTicks();
board_ = std::make_shared<ScoreboardData>();
board_->ini_clock = SDL_GetTicks();
rooms_.push_back("04.room");
rooms_.push_back("54.room");
rooms_.push_back("20.room");
@@ -42,19 +43,19 @@ Demo::Demo()
// Crea los objetos
ItemTracker::init();
scoreboard_ = std::make_shared<Scoreboard>(&board_);
room_ = std::make_shared<Room>(resource_->getRoom(current_room_), &board_.items, false);
scoreboard_ = std::make_shared<Scoreboard>(board_);
room_ = std::make_shared<Room>(resource_->getRoom(current_room_), board_);
text_ = resource_->getText("smb2");
// Inicializa el resto de variables
counter_ = 0;
room_time_ = 400;
ticks_ = 0;
board_.lives = 9;
board_.items = 0;
board_.rooms = 1;
board_.jail_is_open = false;
board_.music = true;
board_->lives = 9;
board_->items = 0;
board_->rooms = 1;
board_->jail_is_open = false;
board_->music = true;
setScoreBoardColor();
options.section.section = Section::DEMO;
@@ -188,7 +189,7 @@ bool Demo::changeRoom(std::string file)
if (asset_->get(file) != "")
{
// Crea un objeto habitación a partir del fichero
room_ = std::make_shared<Room>(resource_->getRoom(file), &board_.items, false);
room_ = std::make_shared<Room>(resource_->getRoom(file), board_);
// Pone el color del marcador en función del color del borde de la habitación
setScoreBoardColor();
@@ -228,9 +229,9 @@ void Demo::setScoreBoardColor()
// Si el color es negro lo cambia a blanco
const Color black_color = stringToColor(options.video.palette, "black");
board_.color = colorAreEqual(color, black_color) ? stringToColor(options.video.palette, "white") : color;
board_->color = colorAreEqual(color, black_color) ? stringToColor(options.video.palette, "white") : color;
// Si el color es negro brillante lo cambia a blanco
const Color bright_blac_color = stringToColor(options.video.palette, "bright_black");
board_.color = colorAreEqual(color, bright_blac_color) ? stringToColor(options.video.palette, "white") : color;
board_->color = colorAreEqual(color, bright_blac_color) ? stringToColor(options.video.palette, "white") : color;
}