fix: lobby timer

This commit is contained in:
2021-09-02 19:12:01 +02:00
parent fc9c07f041
commit c3edb96a1c
3 changed files with 3 additions and 2 deletions

View File

@@ -27,7 +27,7 @@ ClientGame::~ClientGame(){
void ClientGame::tick(std::uint64_t delta){ void ClientGame::tick(std::uint64_t delta){
game::Game::tick(delta); game::Game::tick(delta);
m_WorldRenderer.update(); m_WorldRenderer.update();
if (m_GameState == game::GameState::Lobby && m_Players.size() >= 2){ if (m_GameState == game::GameState::Lobby && m_LobbyTime > 0){
m_LobbyTime -= delta; m_LobbyTime -= delta;
} }
} }

View File

@@ -54,6 +54,7 @@ void Lobby::OnPlayerJoin(std::uint8_t playerID){
if (m_Players.size() == 2){ // start timer if a second player join the match if (m_Players.size() == 2){ // start timer if a second player join the match
m_StartTimerTime = utils::getTime(); m_StartTimerTime = utils::getTime();
m_Timer.reset(); m_Timer.reset();
sendTimeRemaining();
} }
} }

View File

@@ -205,7 +205,7 @@ void showTeamSelection(){
void showLobbyProgress(){ void showLobbyProgress(){
const int timePassed = LOBBY_WAITING_TIME - client->getGame().getLobbyTime(); const int timePassed = LOBBY_WAITING_TIME - client->getGame().getLobbyTime();
const float progress = (float)timePassed / (float)(LOBBY_WAITING_TIME); const float progress = (float)timePassed / (float)(LOBBY_WAITING_TIME);
if (progress > 0 && progress < 1 && client->getGame().getPlayers().size() >= 2){ if (progress > 0 && progress < 1){
ImGui::ProgressBar(progress, ImVec2(0.0f, 0.0f), std::string(std::to_string(client->getGame().getLobbyTime() / 1000) + "s").c_str()); ImGui::ProgressBar(progress, ImVec2(0.0f, 0.0f), std::string(std::to_string(client->getGame().getLobbyTime() / 1000) + "s").c_str());
ImGui::SameLine(0.0f, ImGui::GetStyle().ItemInnerSpacing.x); ImGui::SameLine(0.0f, ImGui::GetStyle().ItemInnerSpacing.x);
ImGui::Text("Time Remaining"); ImGui::Text("Time Remaining");