forked from jaildesigner-jailgames/jaildoctors_dilemma
Ja pinta cosetes per pantalla
This commit is contained in:
@@ -18,9 +18,15 @@ Surface::Surface(std::shared_ptr<SurfaceData> surface_dest, int w, int h)
|
||||
|
||||
Surface::Surface(std::shared_ptr<SurfaceData> surface_dest, const std::string &file_path)
|
||||
: surface_data_dest_(surface_dest),
|
||||
surface_data_(std::make_shared<SurfaceData>(loadSurface(Asset::get()->get(file_path)))),
|
||||
original_surface_data_(surface_data_),
|
||||
transparent_color_(0) {}
|
||||
transparent_color_(0)
|
||||
{
|
||||
// Carga la SurfaceData
|
||||
SurfaceData loadedData = loadSurface(file_path);
|
||||
surface_data_ = std::make_shared<SurfaceData>(std::move(loadedData));
|
||||
|
||||
// Inicializa el puntero original
|
||||
original_surface_data_ = surface_data_;
|
||||
}
|
||||
|
||||
Surface::~Surface() {}
|
||||
|
||||
@@ -54,6 +60,7 @@ SurfaceData Surface::loadSurface(const std::string &file_path)
|
||||
}
|
||||
|
||||
// Crear y devolver directamente el objeto SurfaceData
|
||||
printWithDots("Surface : ", file_path.substr(file_path.find_last_of("\\/") + 1), "[ LOADED ]");
|
||||
return SurfaceData(w, h, pixels);
|
||||
}
|
||||
|
||||
@@ -85,13 +92,8 @@ void Surface::loadPalette(const std::string &file_path)
|
||||
}
|
||||
|
||||
// Copiar los datos de la paleta al std::array
|
||||
printWithDots("Palette : ", file_path.substr(file_path.find_last_of("\\/") + 1), "[ LOADED ]");
|
||||
std::copy(pal.get(), pal.get() + palette_.size(), palette_.begin());
|
||||
|
||||
for (auto p : palette_)
|
||||
{
|
||||
std::cout << std::hex << p << " ";
|
||||
}
|
||||
std::cout << std::endl;
|
||||
}
|
||||
|
||||
// Establece un color en la paleta
|
||||
@@ -128,7 +130,8 @@ Uint8 Surface::getPixel(int x, int y)
|
||||
// Dibuja un rectangulo
|
||||
void Surface::fillRect(std::shared_ptr<SurfaceData> surface_data, SDL_Rect *rect, Uint8 color)
|
||||
{
|
||||
if (!rect) return; // Verificar si el rectángulo es válido
|
||||
if (!rect)
|
||||
return; // Verificar si el rectángulo es válido
|
||||
|
||||
// Limitar los valores del rectángulo al tamaño de la superficie
|
||||
int x_start = std::max(0, rect->x);
|
||||
|
||||
Reference in New Issue
Block a user