Chris Peterson 24a08e6017 Squashed commit of Chris's networking code
commit 052d5a2ee82d14752ba7a2a89b375de0f4b3214d
Author: Chris Peterson <xethm55@yahoo.com>
Date:   Fri Sep 14 20:49:49 2012 -0400

    Damn! - Forgot to add the Types.h file

commit 8bb6f6d56279289dd0c1f118dffb390dc6538a7c
Author: Chris Peterson <xethm55@yahoo.com>
Date:   Fri Sep 14 20:41:46 2012 -0400

    Fixed a lot of the lag issues.  There are still some tweaks needed, but that is going to happen with the input system changes

commit 0b5fe2dd64b561d965229a8dff25575eaf5c9264
Author: Chris Peterson <xethm55@yahoo.com>
Date:   Fri Sep 14 20:21:31 2012 -0400

    Client server stuff working.  A lot of lag in the system though

commit 07fac2c86d3b379fd1ac287bf3f60b778ca59508
Merge: 5cfd5b2 ac79196
Author: Chris Peterson <xethm55@yahoo.com>
Date:   Fri Sep 14 17:49:18 2012 -0400

    Merging in changes from Holtrop

commit 5cfd5b28d5e384803ef7b807849ac570e6c84e0f
Author: Chris Peterson <xethm55@yahoo.com>
Date:   Sun Sep 9 12:23:12 2012 -0400

    Building on linux now

commit 470d486cdebd95099020911dee7f9290c78ee274
Merge: 842040d f072eec
Author: Chris Peterson <xethm55@yahoo.com>
Date:   Sun Sep 9 11:58:39 2012 -0400

    Merged in master with tank model

commit 842040d0fee481f726b2ae5aec60787371af3923
Merge: 6866c58 9b993f2
Author: Chris Peterson <xethm55@yahoo.com>
Date:   Thu Aug 30 23:25:19 2012 -0400

    Merged in changes from upstream (holtrop/master)

commit 6866c58200cc50d3ccc886266303c1b654c89527
Author: Chris Peterson <xethm55@yahoo.com>
Date:   Sat Aug 18 17:07:50 2012 -0400

    added server code and a simple echo server.
2012-09-15 09:49:12 -04:00

61 lines
1.2 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);
//stepTime = ((((sf::Window*)screen)->GetFrameTime() / 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));
}