mirror of
https://github.com/ddnet/ddnet.git
synced 2024-11-19 14:38:18 +00:00
added start countdown when game starts without a timer
This commit is contained in:
parent
35ba490183
commit
b374a24c06
|
@ -3,7 +3,7 @@ from datatypes import *
|
|||
Emotes = ["NORMAL", "PAIN", "HAPPY", "SURPRISE", "ANGRY", "BLINK"]
|
||||
PlayerFlags = ["PLAYING", "IN_MENU", "CHATTING", "SCOREBOARD", "READY"]
|
||||
GameFlags = ["TEAMS", "FLAGS"]
|
||||
GameStateFlags = ["WARMUP", "SUDDENDEATH", "GAMEOVER", "PAUSED"]
|
||||
GameStateFlags = ["WARMUP", "SUDDENDEATH", "GAMEOVER", "PAUSED", "STARTCOUNTDOWN"]
|
||||
|
||||
Emoticons = ["OOP", "EXCLAMATION", "HEARTS", "DROP", "DOTDOT", "MUSIC", "SORRY", "GHOST", "SUSHI", "SPLATTEE", "DEVILTEE", "ZOMG", "ZZZ", "WTF", "EYES", "QUESTION"]
|
||||
|
||||
|
|
|
@ -63,7 +63,7 @@ void CHud::RenderGameTimer()
|
|||
|
||||
void CHud::RenderPauseTimer()
|
||||
{
|
||||
if(m_pClient->m_Snap.m_pGameInfoObj->m_GameStateFlags&GAMESTATEFLAG_PAUSED)
|
||||
if((m_pClient->m_Snap.m_pGameInfoObj->m_GameStateFlags&(GAMESTATEFLAG_STARTCOUNTDOWN|GAMESTATEFLAG_PAUSED)) == GAMESTATEFLAG_PAUSED)
|
||||
{
|
||||
char aBuf[256];
|
||||
const char *pText = Localize("Game paused");
|
||||
|
@ -101,6 +101,27 @@ void CHud::RenderPauseTimer()
|
|||
}
|
||||
}
|
||||
|
||||
void CHud::RenderStartCountdown()
|
||||
{
|
||||
if(m_pClient->m_Snap.m_pGameInfoObj->m_GameStateFlags&GAMESTATEFLAG_STARTCOUNTDOWN)
|
||||
{
|
||||
char aBuf[256];
|
||||
const char *pText = Localize("Game starts in");
|
||||
float FontSize = 20.0f;
|
||||
float w = TextRender()->TextWidth(0, FontSize, pText, -1);
|
||||
TextRender()->Text(0, 150*Graphics()->ScreenAspect()+-w/2, 50, FontSize, pText, -1);
|
||||
|
||||
if(m_pClient->m_Snap.m_pGameInfoObj->m_GameStateTimer == -1)
|
||||
return;
|
||||
|
||||
FontSize = 16.0f;
|
||||
int Seconds = (m_pClient->m_Snap.m_pGameInfoObj->m_GameStateTimer+SERVER_TICK_SPEED-1)/SERVER_TICK_SPEED;
|
||||
str_format(aBuf, sizeof(aBuf), "%d", Seconds);
|
||||
w = TextRender()->TextWidth(0, FontSize, aBuf, -1);
|
||||
TextRender()->Text(0, 150*Graphics()->ScreenAspect()+-w/2, 75, FontSize, aBuf, -1);
|
||||
}
|
||||
}
|
||||
|
||||
void CHud::RenderSuddenDeath()
|
||||
{
|
||||
if(m_pClient->m_Snap.m_pGameInfoObj->m_GameStateFlags&GAMESTATEFLAG_SUDDENDEATH)
|
||||
|
@ -513,6 +534,7 @@ void CHud::OnRender()
|
|||
|
||||
RenderGameTimer();
|
||||
RenderPauseTimer();
|
||||
RenderStartCountdown();
|
||||
RenderSuddenDeath();
|
||||
RenderScoreHud();
|
||||
RenderWarmupTimer();
|
||||
|
|
|
@ -18,6 +18,7 @@ class CHud : public CComponent
|
|||
void RenderHealthAndAmmo(const CNetObj_Character *pCharacter);
|
||||
void RenderGameTimer();
|
||||
void RenderPauseTimer();
|
||||
void RenderStartCountdown();
|
||||
void RenderSuddenDeath();
|
||||
void RenderScoreHud();
|
||||
void RenderSpectatorHud();
|
||||
|
|
|
@ -24,7 +24,10 @@ IGameController::IGameController(CGameContext *pGameServer)
|
|||
m_GameStateTimer = TIMER_INFINITE;
|
||||
m_RoundStartTick = Server()->Tick();
|
||||
m_SuddenDeath = 0;
|
||||
SetGameState(GS_WARMUP, g_Config.m_SvWarmup);
|
||||
if(g_Config.m_SvWarmup)
|
||||
SetGameState(GS_WARMUP, g_Config.m_SvWarmup);
|
||||
else
|
||||
SetGameState(GS_STARTCOUNTDOWN, TIMER_STARTCOUNTDOWN);
|
||||
|
||||
// info
|
||||
m_GameFlags = 0;
|
||||
|
@ -421,12 +424,23 @@ void IGameController::SetGameState(int GameState, int Seconds)
|
|||
else
|
||||
SetGameState(GS_GAME);
|
||||
}
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case GS_STARTCOUNTDOWN:
|
||||
{
|
||||
if(m_GameState == GS_GAME || m_GameState == GS_STARTCOUNTDOWN)
|
||||
{
|
||||
m_GameState = GS_STARTCOUNTDOWN;
|
||||
m_GameStateTimer = Seconds*Server()->TickSpeed();
|
||||
GameServer()->m_World.m_Paused = true;
|
||||
}
|
||||
}
|
||||
break;
|
||||
case GS_GAME:
|
||||
{
|
||||
m_GameState = GS_GAME;
|
||||
m_GameStateTimer = TIMER_INFINITE;
|
||||
m_StartCountdownReset = true;
|
||||
SetPlayersReadyState(true);
|
||||
GameServer()->m_World.m_Paused = false;
|
||||
}
|
||||
|
@ -449,7 +463,15 @@ void IGameController::SetGameState(int GameState, int Seconds)
|
|||
GameServer()->m_World.m_Paused = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
bool NeedStartCountdown = m_GameStateTimer != 0;
|
||||
SetGameState(GS_GAME);
|
||||
if(NeedStartCountdown)
|
||||
{
|
||||
SetGameState(GS_STARTCOUNTDOWN, TIMER_STARTCOUNTDOWN);
|
||||
m_StartCountdownReset = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
@ -501,6 +523,10 @@ void IGameController::Snap(int SnappingClient)
|
|||
pGameInfoObj->m_GameStateFlags |= GAMESTATEFLAG_WARMUP;
|
||||
pGameInfoObj->m_GameStateTimer = m_GameStateTimer;
|
||||
break;
|
||||
case GS_STARTCOUNTDOWN:
|
||||
pGameInfoObj->m_GameStateFlags |= GAMESTATEFLAG_STARTCOUNTDOWN|GAMESTATEFLAG_PAUSED;
|
||||
pGameInfoObj->m_GameStateTimer = m_GameStateTimer;
|
||||
break;
|
||||
case GS_PAUSED:
|
||||
pGameInfoObj->m_GameStateFlags |= GAMESTATEFLAG_PAUSED;
|
||||
pGameInfoObj->m_GameStateTimer = m_GameStateTimer;
|
||||
|
@ -533,7 +559,23 @@ void IGameController::Tick()
|
|||
{
|
||||
case GS_WARMUP:
|
||||
if(m_GameStateTimer == 0 || (m_GameStateTimer == TIMER_INFINITE && (!g_Config.m_SvPlayerReadyMode || GetPlayersReadyState())))
|
||||
StartRound();
|
||||
{
|
||||
if(m_GameStateTimer == 0)
|
||||
StartRound();
|
||||
else
|
||||
SetGameState(GS_STARTCOUNTDOWN, TIMER_STARTCOUNTDOWN);
|
||||
}
|
||||
break;
|
||||
case GS_STARTCOUNTDOWN:
|
||||
if(m_GameStateTimer == 0)
|
||||
{
|
||||
if(m_StartCountdownReset)
|
||||
StartRound();
|
||||
else
|
||||
SetGameState(GS_GAME);
|
||||
}
|
||||
else
|
||||
++m_RoundStartTick;
|
||||
break;
|
||||
case GS_PAUSED:
|
||||
if(m_GameStateTimer == 0 || (m_GameStateTimer == TIMER_INFINITE && g_Config.m_SvPlayerReadyMode && GetPlayersReadyState()))
|
||||
|
|
|
@ -37,6 +37,7 @@ class IGameController
|
|||
// game
|
||||
int m_GameState;
|
||||
int m_GameStateTimer;
|
||||
bool m_StartCountdownReset;
|
||||
|
||||
virtual void DoWincheck();
|
||||
void SetGameState(int GameState, int Seconds=0);
|
||||
|
@ -136,15 +137,17 @@ public:
|
|||
enum
|
||||
{
|
||||
GS_WARMUP,
|
||||
GS_STARTCOUNTDOWN,
|
||||
GS_GAME,
|
||||
GS_PAUSED,
|
||||
GS_GAMEOVER,
|
||||
|
||||
TIMER_INFINITE = -1,
|
||||
TIMER_STARTCOUNTDOWN = 3,
|
||||
};
|
||||
|
||||
void DoPause(int Seconds) { SetGameState(GS_PAUSED, Seconds); }
|
||||
void DoRestart() { StartRound(); }
|
||||
void DoRestart() { SetGameState(GS_STARTCOUNTDOWN, TIMER_STARTCOUNTDOWN); }
|
||||
void DoWarmup(int Seconds) { SetGameState(GS_WARMUP, Seconds); }
|
||||
|
||||
// general
|
||||
|
|
|
@ -174,7 +174,8 @@ void CGameWorld::Tick()
|
|||
pEnt = m_pNextTraverseEntity;
|
||||
}
|
||||
}
|
||||
else if(GameServer()->m_pController->GetGameState() == IGameController::GS_PAUSED)
|
||||
else if(GameServer()->m_pController->GetGameState() == IGameController::GS_PAUSED ||
|
||||
GameServer()->m_pController->GetGameState() == IGameController::GS_STARTCOUNTDOWN)
|
||||
{
|
||||
// update all objects
|
||||
for(int i = 0; i < NUM_ENTTYPES; i++)
|
||||
|
|
|
@ -68,7 +68,7 @@ void CPlayer::Tick()
|
|||
m_pCharacter = 0;
|
||||
}
|
||||
|
||||
if(GameServer()->m_pController->GetGameState() != IGameController::GS_PAUSED)
|
||||
if(GameServer()->m_pController->GetGameState() != IGameController::GS_PAUSED && GameServer()->m_pController->GetGameState() != IGameController::GS_STARTCOUNTDOWN)
|
||||
{
|
||||
if(!m_pCharacter && m_Team == TEAM_SPECTATORS && m_SpectatorID == SPEC_FREEVIEW)
|
||||
m_ViewPos -= vec2(clamp(m_ViewPos.x-m_LatestActivity.m_TargetX, -500.0f, 500.0f), clamp(m_ViewPos.y-m_LatestActivity.m_TargetY, -400.0f, 400.0f));
|
||||
|
|
Loading…
Reference in a new issue