draw border around overlay map Changed from refptr<map<U8, Player> > to map<U8, refptr<player> > minor bugfix - using more memory on sky than needed Fixed some bugs with multiplayer CCFS: print error when unable to find file by default simplify GLProgram creation with stdarg
60 lines
1.1 KiB
C++
60 lines
1.1 KiB
C++
#include "Timer.h"
|
|
|
|
// The number of time steps per second
|
|
const float STEPS_PER_SECOND = 60.0f;
|
|
|
|
double Timer::totalElapsedTime;
|
|
float Timer::stepTime;
|
|
sf::Uint32 Timer::curTimeStep;
|
|
|
|
void Timer::Init(void)
|
|
{
|
|
// Reset the clock
|
|
myClock.restart();
|
|
|
|
// Set the time keepers to zero
|
|
myTotalElapsedTime = 0;
|
|
|
|
// Reset the game speed
|
|
gameSpeed = 1.0f;
|
|
}
|
|
|
|
void Timer::Update(void)
|
|
{
|
|
// Record the time step
|
|
stepTime = ((myClock.getElapsedTime().asSeconds() / 1000.0f) * gameSpeed);
|
|
myClock.restart();
|
|
|
|
// Add the time to the total time
|
|
myTotalElapsedTime += stepTime;
|
|
totalElapsedTime = myTotalElapsedTime;
|
|
|
|
// Calculate the game step
|
|
curTimeStep = (sf::Uint32)(totalElapsedTime * STEPS_PER_SECOND);
|
|
}
|
|
|
|
sf::Uint32 Timer::GetTime(void)
|
|
{
|
|
return curTimeStep;
|
|
}
|
|
|
|
float Timer::GetStepTime(void)
|
|
{
|
|
return stepTime;
|
|
}
|
|
|
|
sf::Uint32 Timer::GetTotalTime(void)
|
|
{
|
|
return (sf::Uint32)(totalElapsedTime * 1000.0f);
|
|
}
|
|
|
|
double Timer::GetTimeDouble(void)
|
|
{
|
|
return totalElapsedTime;
|
|
}
|
|
|
|
float Timer::GetElapsedTime(sf::Uint32 baseTime)
|
|
{
|
|
return (totalElapsedTime - ((double)baseTime / STEPS_PER_SECOND));
|
|
}
|