llevat soport per a colors amb nom

This commit is contained in:
2026-04-06 09:14:36 +02:00
parent c4a26ffa0f
commit cdf0665458
121 changed files with 676 additions and 5754 deletions

View File

@@ -6,12 +6,11 @@
#include "core/rendering/sprite/animated_sprite.hpp" // Para SAnimatedSprite
#include "core/resources/resource_cache.hpp" // Para Resource
#include "utils/utils.hpp" // Para stringToColor
#include "utils/utils.hpp"
// Constructor
Enemy::Enemy(const Data& enemy)
: sprite_(std::make_shared<AnimatedSprite>(Resource::Cache::get()->getAnimationData(enemy.animation_path))),
color_string_(enemy.color),
x1_(enemy.x1),
x2_(enemy.x2),
y1_(enemy.y1),
@@ -30,7 +29,7 @@ Enemy::Enemy(const Data& enemy)
collider_ = getRect();
color_ = stringToColor(color_string_);
color_ = enemy.color;
// Coloca un frame al azar o el designado
sprite_->setCurrentAnimationFrame((enemy.frame == -1) ? (rand() % sprite_->getCurrentAnimationSize()) : enemy.frame);

View File

@@ -21,7 +21,7 @@ class Enemy {
bool flip{false}; // Indica si el enemigo hace flip al terminar su ruta
bool mirror{false}; // Indica si el enemigo está volteado verticalmente
int frame{0}; // Frame inicial para la animación del enemigo
std::string color; // Color del enemigo
Uint8 color{14}; // Color del enemigo (default: white=14)
};
explicit Enemy(const Data& enemy); // Constructor
@@ -44,7 +44,6 @@ class Enemy {
// Variables
Uint8 color_{0}; // Color del enemigo
std::string color_string_; // Color del enemigo en formato texto
int x1_{0}; // Limite izquierdo de la ruta en el eje X
int x2_{0}; // Limite derecho de la ruta en el eje X
int y1_{0}; // Limite superior de la ruta en el eje Y

View File

@@ -35,8 +35,8 @@ void Player::render() {
sprite_->render(1, color_);
#ifdef _DEBUG
if (Debug::get()->isEnabled()) {
Screen::get()->getRendererSurface()->putPixel(under_right_foot_.x, under_right_foot_.y, static_cast<Uint8>(PaletteColor::GREEN));
Screen::get()->getRendererSurface()->putPixel(under_left_foot_.x, under_left_foot_.y, static_cast<Uint8>(PaletteColor::GREEN));
Screen::get()->getRendererSurface()->putPixel(under_right_foot_.x, under_right_foot_.y, 8);
Screen::get()->getRendererSurface()->putPixel(under_left_foot_.x, under_left_foot_.y, 8);
}
#endif
}
@@ -566,14 +566,14 @@ void Player::setColor(Uint8 color) {
if (Options::game.player_color >= 0) {
color_ = static_cast<Uint8>(Options::game.player_color);
} else {
color_ = static_cast<Uint8>(PaletteColor::WHITE);
color_ = 14;
}
// Si el color coincide con el fondo de la habitación, usar fallback
if (room_ != nullptr && color_ == room_->getBGColor()) {
color_ = (room_->getBGColor() != static_cast<Uint8>(PaletteColor::WHITE))
? static_cast<Uint8>(PaletteColor::WHITE)
: static_cast<Uint8>(PaletteColor::BRIGHT_BLACK);
color_ = (room_->getBGColor() != 14)
? 14
: 1;
}
}