ajustant el jugador
This commit is contained in:
@@ -17,75 +17,75 @@
|
||||
* de 3 niveles de intensidad (0, 128, 255) para cada componente RGB.
|
||||
*/
|
||||
class Color {
|
||||
public:
|
||||
/**
|
||||
* @enum Cpc
|
||||
* @brief Índices de los colores de la paleta Amstrad CPC
|
||||
*
|
||||
* Los nombres corresponden a los colores oficiales documentados por Amstrad.
|
||||
* El índice 0 está reservado para transparencia.
|
||||
*/
|
||||
enum class Cpc : Uint8 {
|
||||
// Transparente (índice 0)
|
||||
CLEAR = 0, // Nota: No usar "TRANSPARENT" - colisiona con macro de Windows
|
||||
public:
|
||||
/**
|
||||
* @enum Cpc
|
||||
* @brief Índices de los colores de la paleta Amstrad CPC
|
||||
*
|
||||
* Los nombres corresponden a los colores oficiales documentados por Amstrad.
|
||||
* El índice 0 está reservado para transparencia.
|
||||
*/
|
||||
enum class Cpc : Uint8 {
|
||||
// Transparente (índice 0)
|
||||
CLEAR = 0, // Nota: No usar "TRANSPARENT" - colisiona con macro de Windows
|
||||
|
||||
// Negros y azules (R=0)
|
||||
BLACK = 1, // 0, 0, 0
|
||||
BLUE = 2, // 0, 0, 128
|
||||
BRIGHT_BLUE = 3, // 0, 0, 255
|
||||
// Negros y azules (R=0)
|
||||
BLACK = 1, // 0, 0, 0
|
||||
BLUE = 2, // 0, 0, 128
|
||||
BRIGHT_BLUE = 3, // 0, 0, 255
|
||||
|
||||
// Rojos y magentas (G=0)
|
||||
RED = 4, // 128, 0, 0
|
||||
MAGENTA = 5, // 128, 0, 128
|
||||
MAUVE = 6, // 128, 0, 255
|
||||
BRIGHT_RED = 7, // 255, 0, 0
|
||||
PURPLE = 8, // 255, 0, 128
|
||||
BRIGHT_MAGENTA = 9, // 255, 0, 255
|
||||
// Rojos y magentas (G=0)
|
||||
RED = 4, // 128, 0, 0
|
||||
MAGENTA = 5, // 128, 0, 128
|
||||
MAUVE = 6, // 128, 0, 255
|
||||
BRIGHT_RED = 7, // 255, 0, 0
|
||||
PURPLE = 8, // 255, 0, 128
|
||||
BRIGHT_MAGENTA = 9, // 255, 0, 255
|
||||
|
||||
// Verdes y cianes (R=0, G>0)
|
||||
GREEN = 10, // 0, 128, 0
|
||||
CYAN = 11, // 0, 128, 128
|
||||
SKY_BLUE = 12, // 0, 128, 255
|
||||
// Verdes y cianes (R=0, G>0)
|
||||
GREEN = 10, // 0, 128, 0
|
||||
CYAN = 11, // 0, 128, 128
|
||||
SKY_BLUE = 12, // 0, 128, 255
|
||||
|
||||
// Amarillos y blancos medios (G=128)
|
||||
YELLOW = 13, // 128, 128, 0
|
||||
WHITE = 14, // 128, 128, 128
|
||||
PASTEL_BLUE = 15, // 128, 128, 255
|
||||
// Amarillos y blancos medios (G=128)
|
||||
YELLOW = 13, // 128, 128, 0
|
||||
WHITE = 14, // 128, 128, 128
|
||||
PASTEL_BLUE = 15, // 128, 128, 255
|
||||
|
||||
// Naranjas y rosas (R=255, G=128)
|
||||
ORANGE = 16, // 255, 128, 0
|
||||
PINK = 17, // 255, 128, 128
|
||||
PASTEL_MAGENTA = 18, // 255, 128, 255
|
||||
// Naranjas y rosas (R=255, G=128)
|
||||
ORANGE = 16, // 255, 128, 0
|
||||
PINK = 17, // 255, 128, 128
|
||||
PASTEL_MAGENTA = 18, // 255, 128, 255
|
||||
|
||||
// Verdes brillantes (G=255)
|
||||
BRIGHT_GREEN = 19, // 0, 255, 0
|
||||
SEA_GREEN = 20, // 0, 255, 128
|
||||
BRIGHT_CYAN = 21, // 0, 255, 255
|
||||
// Verdes brillantes (G=255)
|
||||
BRIGHT_GREEN = 19, // 0, 255, 0
|
||||
SEA_GREEN = 20, // 0, 255, 128
|
||||
BRIGHT_CYAN = 21, // 0, 255, 255
|
||||
|
||||
// Limas y pasteles verdes (G=255)
|
||||
LIME = 22, // 128, 255, 0
|
||||
PASTEL_GREEN = 23, // 128, 255, 128
|
||||
PASTEL_CYAN = 24, // 128, 255, 255
|
||||
// Limas y pasteles verdes (G=255)
|
||||
LIME = 22, // 128, 255, 0
|
||||
PASTEL_GREEN = 23, // 128, 255, 128
|
||||
PASTEL_CYAN = 24, // 128, 255, 255
|
||||
|
||||
// Amarillos brillantes y blancos (R=255, G=255)
|
||||
BRIGHT_YELLOW = 25, // 255, 255, 0
|
||||
PASTEL_YELLOW = 26, // 255, 255, 128
|
||||
BRIGHT_WHITE = 27 // 255, 255, 255
|
||||
};
|
||||
// Amarillos brillantes y blancos (R=255, G=255)
|
||||
BRIGHT_YELLOW = 25, // 255, 255, 0
|
||||
PASTEL_YELLOW = 26, // 255, 255, 128
|
||||
BRIGHT_WHITE = 27 // 255, 255, 255
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief Obtiene el índice de paleta de un color CPC
|
||||
* @param color Color del enum Cpc
|
||||
* @return Índice de paleta (Uint8)
|
||||
*/
|
||||
static constexpr auto index(Cpc color) -> Uint8 {
|
||||
return static_cast<Uint8>(color);
|
||||
}
|
||||
/**
|
||||
* @brief Obtiene el índice de paleta de un color CPC
|
||||
* @param color Color del enum Cpc
|
||||
* @return Índice de paleta (Uint8)
|
||||
*/
|
||||
static constexpr auto index(Cpc color) -> Uint8 {
|
||||
return static_cast<Uint8>(color);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Convierte un nombre de color (string) a índice de paleta
|
||||
* @param name Nombre del color en minúsculas (ej: "cyan", "bright_blue")
|
||||
* @return Índice de paleta, o 1 (BLACK) si no se encuentra
|
||||
*/
|
||||
static auto fromString(const std::string& name) -> Uint8;
|
||||
/**
|
||||
* @brief Convierte un nombre de color (string) a índice de paleta
|
||||
* @param name Nombre del color en minúsculas (ej: "cyan", "bright_blue")
|
||||
* @return Índice de paleta, o 1 (BLACK) si no se encuentra
|
||||
*/
|
||||
static auto fromString(const std::string& name) -> Uint8;
|
||||
};
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
namespace Texts {
|
||||
constexpr const char* WINDOW_CAPTION = "© 2026 Projecte 2026 — JailDesigner";
|
||||
constexpr const char* COPYRIGHT = "@2026 JailDesigner";
|
||||
constexpr const char* VERSION = "1.13"; // Versión por defecto
|
||||
constexpr const char* VERSION = "0.1"; // Versión por defecto
|
||||
} // namespace Texts
|
||||
|
||||
// Tamaño de bloque
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
#include "utils/utils.hpp"
|
||||
|
||||
#include <algorithm> // Para find, transform
|
||||
#include <cctype> // Para tolower
|
||||
#include <algorithm> // Para find, transform, ranges::all_of
|
||||
#include <array> // Para array
|
||||
#include <cctype> // Para tolower, isdigit
|
||||
#include <cmath> // Para round, abs
|
||||
#include <cstdlib> // Para abs
|
||||
#include <exception> // Para exception
|
||||
@@ -366,10 +367,36 @@ auto stringToColor(const std::string& str) -> Uint8 {
|
||||
auto it = PALETTE_MAP.find(str);
|
||||
if (it != PALETTE_MAP.end()) {
|
||||
return it->second;
|
||||
} // Si no se encuentra el color, devolvemos negro por defecto
|
||||
}
|
||||
|
||||
// Fallback: si el string es numérico (p.ej. "4"), lo tratamos como índice de paleta
|
||||
if (!str.empty() && std::ranges::all_of(str, [](char c) { return std::isdigit(static_cast<unsigned char>(c)) != 0; })) {
|
||||
const int IDX = safeStoi(str, 0);
|
||||
if (IDX >= 0 && IDX <= 255) {
|
||||
return static_cast<Uint8>(IDX);
|
||||
}
|
||||
}
|
||||
|
||||
// Si no se encuentra el color, devolvemos negro por defecto
|
||||
return 0;
|
||||
}
|
||||
|
||||
// Inverso de stringToColor: devuelve el nombre canónico para un índice de paleta (o el propio número si no hay)
|
||||
auto colorToString(Uint8 index) -> std::string {
|
||||
static const std::array<const char*, 16> NAMES = {
|
||||
"black", "bright_black",
|
||||
"blue", "bright_blue",
|
||||
"red", "bright_red",
|
||||
"magenta", "bright_magenta",
|
||||
"green", "bright_green",
|
||||
"cyan", "bright_cyan",
|
||||
"yellow", "bright_yellow",
|
||||
"white", "bright_white"};
|
||||
if (index < NAMES.size()) { return NAMES[index]; }
|
||||
if (index == 255) { return "transparent"; }
|
||||
return std::to_string(index);
|
||||
}
|
||||
|
||||
// Convierte una cadena a un entero de forma segura
|
||||
auto safeStoi(const std::string& value, int default_value) -> int {
|
||||
try {
|
||||
|
||||
@@ -92,7 +92,8 @@ auto toSDLRect(const SDL_FRect& frect) -> SDL_Rect; // Convierte SDL_FRect
|
||||
auto toSDLPoint(const SDL_FPoint& fpoint) -> SDL_Point; // Convierte SDL_FPoint a SDL_Point
|
||||
|
||||
// CONVERSIONES DE STRING
|
||||
auto stringToColor(const std::string& str) -> Uint8; // String a índice de paleta
|
||||
auto stringToColor(const std::string& str) -> Uint8; // String a índice de paleta (acepta nombres o números)
|
||||
auto colorToString(Uint8 index) -> std::string; // Índice de paleta a nombre canónico
|
||||
auto safeStoi(const std::string& value, int default_value = 0) -> int; // String a int seguro (sin excepciones)
|
||||
auto stringToBool(const std::string& str) -> bool; // String a bool (true/1/yes/on)
|
||||
auto boolToString(bool value) -> std::string; // Bool a string (1/0)
|
||||
|
||||
Reference in New Issue
Block a user