50 lines
649 B
C++
50 lines
649 B
C++
|
|
#ifndef SPECTRE_GAME_TIME_H
|
|
#define SPECTRE_GAME_TIME_H
|
|
|
|
#include <Spectre/Math/Time.h>
|
|
#include <Spectre/System/Stopwatch.h>
|
|
|
|
namespace sp {
|
|
|
|
class GameTime
|
|
{
|
|
public :
|
|
GameTime(unsigned long updates_per_sec = 60);
|
|
|
|
void setTimeStep(unsigned long updates_per_sec);
|
|
|
|
double getTimeStep() const;
|
|
|
|
Time getElapsed() const;
|
|
|
|
bool beginFrame();
|
|
|
|
bool shouldTick() const;
|
|
|
|
bool tick();
|
|
|
|
void reset();
|
|
|
|
protected :
|
|
|
|
void accumulateTime();
|
|
|
|
void updateTime();
|
|
|
|
protected :
|
|
|
|
// TODO: min,max framerates
|
|
|
|
Stopwatch m_watch;
|
|
|
|
Time m_acc;
|
|
Time m_max_acc;
|
|
|
|
// Timeslice.
|
|
Time m_slice;
|
|
};
|
|
|
|
} // namespace sp
|
|
|
|
#endif /* SPECTRE_GAME_TIME_H */
|