[DOC:29/10/2025] la surface ara se pillarà del .ANI

Tots els arxius .ani i .room retocats per a adequarse als canvis.
This commit is contained in:
2025-10-29 14:22:36 +01:00
parent 95dd6b4f70
commit 70d6cbfaf8
134 changed files with 133 additions and 620 deletions

View File

@@ -10,7 +10,8 @@
// Constructor
Enemy::Enemy(const Data& enemy)
: sprite_(std::make_shared<SurfaceAnimatedSprite>(Resource::get()->getSurface(enemy.surface_path), Resource::get()->getAnimations(enemy.animation_path))),
// [DOC:29/10/2025] la surface ara se pillarà del .ANI
: sprite_(std::make_shared<SurfaceAnimatedSprite>(/*Resource::get()->getSurface(enemy.surface_path), */Resource::get()->getAnimations(enemy.animation_path))),
color_string_(enemy.color),
x1_(enemy.x1),
x2_(enemy.x2),

View File

@@ -10,7 +10,9 @@ class Enemy {
public:
// --- Estructuras ---
struct Data {
/* [DOC:29/10/2025] la surface ara se pillarà del .ANI
std::string surface_path{}; // Ruta al fichero con la textura
[/DOC] */
std::string animation_path{}; // Ruta al fichero con la animación
/* [DOC:29/10/2025] w i h ja no fan falta, se pilla del .ANI
int w = 0; // Anchura del enemigo

View File

@@ -18,7 +18,7 @@
Player::Player(const Data& player)
: room_(player.room) {
// Inicializa algunas variables
initSprite(player.texture_path, player.animations_path);
initSprite(/*player.texture_path, */player.animations_path);
setColor();
applySpawnValues(player.spawn_data);
placeSprite();
@@ -641,11 +641,11 @@ void Player::applySpawnValues(const SpawnData& spawn) {
}
// Inicializa el sprite del jugador
void Player::initSprite(const std::string& surface_path, const std::string& animations_path) {
auto surface = Resource::get()->getSurface(surface_path);
void Player::initSprite(/*const std::string& surface_path, */const std::string& animations_path) {
//auto surface = Resource::get()->getSurface(surface_path);
auto animations = Resource::get()->getAnimations(animations_path);
sprite_ = std::make_shared<SurfaceAnimatedSprite>(surface, animations);
sprite_ = std::make_shared<SurfaceAnimatedSprite>(/*surface, */animations);
sprite_->setWidth(WIDTH);
sprite_->setHeight(HEIGHT);
sprite_->setCurrentAnimation("walk");

View File

@@ -47,7 +47,7 @@ class Player {
struct Data {
SpawnData spawn_data{};
std::string texture_path{};
//std::string texture_path{};
std::string animations_path{};
std::shared_ptr<Room> room = nullptr;
@@ -57,7 +57,7 @@ class Player {
// Constructor con parámetros
Data(SpawnData spawn_data, std::string texture_path, std::string animations_path, std::shared_ptr<Room> room)
: spawn_data(std::move(spawn_data)),
texture_path(std::move(texture_path)),
//texture_path(std::move(texture_path)),
animations_path(std::move(animations_path)),
room(std::move(room)) {}
};
@@ -147,7 +147,7 @@ class Player {
void initSounds(); // Inicializa los sonidos de salto y caida
void placeSprite() { sprite_->setPos(x_, y_); } // Coloca el sprite en la posición del jugador
void applySpawnValues(const SpawnData& spawn); // Aplica los valores de spawn al jugador
void initSprite(const std::string& surface_path, const std::string& animations_path); // Inicializa el sprite del jugador
void initSprite(/*const std::string& surface_path, */const std::string& animations_path); // Inicializa el sprite del jugador
#ifdef _DEBUG
// --- Variables ---

View File

@@ -861,9 +861,9 @@ auto Room::setEnemy(Enemy::Data* enemy, const std::string& key, const std::strin
bool success = true;
try {
if (key == "tileSetFile") {
/*if (key == "tileSetFile") {
enemy->surface_path = value;
} else if (key == "animation") {
} else */if (key == "animation") {
enemy->animation_path = value;
/* [DOC:29/10/2025] w i h ja no fan falta, se pilla del .ANI
} else if (key == "width") {

View File

@@ -21,9 +21,9 @@ Scoreboard::Scoreboard(std::shared_ptr<ScoreboardData> data)
constexpr float SURFACE_HEIGHT = 6.0F * TILE_SIZE;
// Reserva memoria para los objetos
auto player_texture = Resource::get()->getSurface(Options::cheats.alternate_skin == Options::Cheat::State::ENABLED ? "player2.gif" : "player.gif");
//auto player_texture = Resource::get()->getSurface(Options::cheats.alternate_skin == Options::Cheat::State::ENABLED ? "player2.gif" : "player.gif");
auto player_animations = Resource::get()->getAnimations(Options::cheats.alternate_skin == Options::Cheat::State::ENABLED ? "player2.ani" : "player.ani");
player_sprite_ = std::make_shared<SurfaceAnimatedSprite>(player_texture, player_animations);
player_sprite_ = std::make_shared<SurfaceAnimatedSprite>(player_animations);
player_sprite_->setCurrentAnimation("walk_menu");
surface_ = std::make_shared<Surface>(SURFACE_WIDTH, SURFACE_HEIGHT);

View File

@@ -18,7 +18,7 @@
// Constructor
Credits::Credits()
: shining_sprite_(std::make_shared<SurfaceAnimatedSprite>(Resource::get()->getSurface("shine.gif"), Resource::get()->getAnimations("shine.ani"))) {
: shining_sprite_(std::make_shared<SurfaceAnimatedSprite>(Resource::get()->getAnimations("shine.ani"))) {
// Inicializa variables
SceneManager::current = SceneManager::Scene::CREDITS;
SceneManager::options = SceneManager::Options::NONE;

View File

@@ -275,7 +275,7 @@ void Ending2::loadSprites() {
// Carga los sprites
for (const auto& file : sprite_list_) {
sprites_.emplace_back(std::make_shared<SurfaceAnimatedSprite>(Resource::get()->getSurface(file + ".gif"), Resource::get()->getAnimations(file + ".ani")));
sprites_.emplace_back(std::make_shared<SurfaceAnimatedSprite>(Resource::get()->getAnimations(file + ".ani")));
sprite_max_width_ = std::max(sprites_.back()->getWidth(), sprite_max_width_);
sprite_max_height_ = std::max(sprites_.back()->getHeight(), sprite_max_height_);
}

View File

@@ -20,8 +20,8 @@
// Constructor
GameOver::GameOver()
: player_sprite_(std::make_shared<SurfaceAnimatedSprite>(Resource::get()->getSurface("player_game_over.gif"), Resource::get()->getAnimations("player_game_over.ani"))),
tv_sprite_(std::make_shared<SurfaceAnimatedSprite>(Resource::get()->getSurface("tv.gif"), Resource::get()->getAnimations("tv.ani"))),
: player_sprite_(std::make_shared<SurfaceAnimatedSprite>(Resource::get()->getAnimations("player_game_over.ani"))),
tv_sprite_(std::make_shared<SurfaceAnimatedSprite>(Resource::get()->getAnimations("tv.ani"))),
delta_timer_(std::make_shared<DeltaTimer>()) {
SceneManager::current = SceneManager::Scene::GAME_OVER;
SceneManager::options = SceneManager::Options::NONE;