canvi de pc

This commit is contained in:
2025-03-01 08:11:00 +01:00
parent 5ff04daf20
commit c7db6aeaa3
6 changed files with 49 additions and 9 deletions

View File

@@ -18,7 +18,9 @@ Surface::Surface(std::shared_ptr<SurfaceData> surface_dest, int w, int h)
Surface::Surface(std::shared_ptr<SurfaceData> surface_dest, std::string file_path)
: surface_dest_(surface_dest),
surface_(std::make_shared<SurfaceData>(loadSurface(Asset::get()->get(file_path)))),
transparent_color_(0) {}
transparent_color_(0) {
std::cout << "surface loaded: "<< surface_->width << "x" << surface_->height << std::endl;
}
Surface::~Surface() {}
@@ -84,6 +86,12 @@ void Surface::loadPalette(const std::string &file_path)
// Copiar los datos de la paleta al std::array
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
@@ -125,6 +133,11 @@ Uint8 Surface::getPixel(int x, int y)
// Copia una región de la superficie de origen a la de destino
void Surface::render(int dx, int dy, int sx, int sy, int w, int h)
{
if (!surface_ || !surface_dest_)
{
throw std::runtime_error("Surface source or destination is null.");
}
// Limitar la región para evitar accesos fuera de rango
w = std::min(w, surface_->width - sx);
h = std::min(h, surface_->height - sy);