feat: add map background color

This commit is contained in:
2021-12-12 16:13:05 +01:00
parent 43f21ffd44
commit 1a091baeaf
10 changed files with 32 additions and 4 deletions

View File

@@ -37,6 +37,7 @@ bool World::loadMap(const protocol::WorldBeginDataPacket* worldHeader) {
m_TowerPlacePalette = worldHeader->getTowerTilePalette();
m_WalkablePalette = worldHeader->getWalkableTileColor();
m_DecorationPalette = worldHeader->getDecorationPalette();
m_Background = worldHeader->getBackgroundColor();
getRedTeam().getSpawn() = worldHeader->getRedSpawn();
getBlueTeam().getSpawn() = worldHeader->getBlueSpawn();

View File

@@ -93,6 +93,7 @@ void ClientGame::HandlePacket(const protocol::UpdateMoneyPacket* packet) {
void ClientGame::HandlePacket(const protocol::DisconnectPacket* packet) {
m_GameState = game::GameState::Disconnected;
m_Renderer->setBackgroundColor({ 0, 0, 0 });
}
void ClientGame::HandlePacket(const protocol::WorldDataPacket* packet) {

View File

@@ -17,6 +17,11 @@ WorldClient::WorldClient(ClientGame* game) : game::World(game), protocol::Packet
void WorldClient::HandlePacket(const protocol::WorldBeginDataPacket* packet) {
loadMap(packet);
if (m_Game->getGameState() == game::GameState::Game) {
const game::Color& backgroundColor = getBackgroundColor();
m_Game->getRenderer()->setBackgroundColor({ static_cast<float>(backgroundColor.r / 255.0f), static_cast<float>(backgroundColor.g / 255.0f),
static_cast<float>(backgroundColor.b / 255.0f) });
}
}
void WorldClient::HandlePacket(const protocol::WorldDataPacket* packet) {