canvi de pc

This commit is contained in:
2025-03-02 08:09:15 +01:00
parent cd96be80f9
commit 193dac708f
3 changed files with 74 additions and 38 deletions

View File

@@ -442,9 +442,6 @@ Room::Room(const std::string &room_path, std::shared_ptr<ScoreboardData> data)
}
}
// Carga los sonidos
item_sound_ = Resource::get()->getSound("item.wav");
// Abre la jail para poder entrar
if (data_->jail_is_open)
{
@@ -484,10 +481,47 @@ Room::Room(const std::string &room_path, std::shared_ptr<ScoreboardData> data)
// Destructor
Room::~Room()
{
// Reclama la memoria utilizada por los objetos
SDL_DestroyTexture(map_texture_);
}
void Room::initializeRoom(const RoomData& room) {
// Asignar valores a las variables miembro
number_ = room.number;
name_ = room.name;
bg_color_ = room.bg_color;
border_color_ = room.border_color;
item_color1_ = room.item_color1.empty() ? "yellow" : room.item_color1;
item_color2_ = room.item_color2.empty() ? "magenta" : room.item_color2;
room_top_ = room.room_top;
room_bottom_ = room.room_bottom;
room_left_ = room.room_left;
room_right_ = room.room_right;
tile_set_file_ = room.tile_set_file;
tile_map_file_ = room.tile_map_file;
auto_surface_direction_ = room.auto_surface_direction;
tile_map_ = Resource::get()->getTileMap(room.tile_map_file);
texture_ = Resource::get()->getTexture(room.tile_set_file);
tile_set_width_ = texture_->getWidth() / TILE_SIZE_;
is_paused_ = false;
counter_ = 0;
// Crear los enemigos
for (auto &enemy_data : room.enemies) {
enemies_.emplace_back(std::make_shared<Enemy>(enemy_data));
}
// Crear los items
for (auto &item : room.items) {
const SDL_Point itemPos = {item.x, item.y};
if (!ItemTracker::get()->hasBeenPicked(room.name, itemPos)) {
item.color1 = stringToColor(options.video.palette, item_color1_);
item.color2 = stringToColor(options.video.palette, item_color2_);
items_.emplace_back(std::make_shared<Item>(item));
}
}
}
// Devuelve el nombre de la habitación
std::string Room::getName()
{
@@ -797,7 +831,7 @@ bool Room::itemCollision(SDL_Rect &rect)
{
ItemTracker::get()->addItem(name_, items_[i]->getPos());
items_.erase(items_.begin() + i);
JA_PlaySound(item_sound_);
JA_PlaySound(Resource::get()->getSound("item.wav"));
data_->items++;
options.stats.items = data_->items;
return true;
@@ -1218,7 +1252,7 @@ void Room::setAnimatedTiles()
const int xc = (tile_map_[i] % tile_set_width_) * TILE_SIZE_;
const int yc = (tile_map_[i] / tile_set_width_) * TILE_SIZE_;
aTile_t at;
AnimatedTile at;
at.sprite = std::make_shared<Sprite>(texture_, x, y, 8, 8);
at.sprite->setClip(xc, yc, 8, 8);
at.x_orig = xc;