- [FIX] ficava el color incorrecte de background

- [NEW] el fondo no usat ara pinta el color de borde
This commit is contained in:
2025-11-18 17:50:53 +01:00
parent 03baa43543
commit f72311bb17
3 changed files with 18 additions and 4 deletions

View File

@@ -40,7 +40,7 @@ void loadRoom(std::string room_file)
}
tilemap::set(tiles);
tilemap::setBackground(aux::getColorByName(room["room"]["bgColor"].get_value<std::string>()));
tilemap::setBorder(aux::getColorByName(room["room"]["border"].get_value<std::string>()));
//fkyaml::node name_node = room["room"]["name"];
//printf("%s\n", name_node.get_value<std::string>().c_str());
}

View File

@@ -6,6 +6,7 @@ namespace tilemap
{
uint16_t tiles[16*32];
uint32_t back_color = 0xff000000;
uint32_t border_color = 0xff000000;
SDL_Texture *tileset;
SDL_Texture *map;
uint32_t paleta[16] = {
@@ -23,7 +24,7 @@ namespace tilemap
void start()
{
draw::setClip(200,48,draw::getWindowSize().x-400, draw::getWindowSize().y-48);
draw::setColor(0xff000000);
draw::setColor(border_color);
draw::fillrect(200,48,draw::getWindowSize().x-400, draw::getWindowSize().y-48);
}
@@ -42,9 +43,8 @@ namespace tilemap
draw::resetClip();
}
void set(uint16_t *tiles)
void rebuild()
{
memcpy(tilemap::tiles, tiles, 32*16*2);
draw::setDestination(map);
draw::setSource(tileset);
draw::cls(back_color);
@@ -58,9 +58,22 @@ namespace tilemap
draw::setDestination(nullptr);
}
void set(uint16_t *tiles)
{
memcpy(tilemap::tiles, tiles, 32*16*2);
rebuild();
}
void setBackground(int color)
{
back_color = paleta[color];
rebuild();
}
void setBorder(int color)
{
border_color = paleta[color];
rebuild();
}
}

View File

@@ -11,4 +11,5 @@ namespace tilemap
void set(uint16_t *tiles);
void setBackground(int color);
void setBorder(int color);
}