Added Time
This commit is contained in:
38
TSE_Core/src/utils/Time.cpp
Normal file
38
TSE_Core/src/utils/Time.cpp
Normal file
@@ -0,0 +1,38 @@
|
||||
#include "Time.hpp"
|
||||
|
||||
TSE::ITimeInterface* TSE::Time::timeInterface = nullptr;
|
||||
float TSE::Time::DeltaTime = 0;
|
||||
float TSE::Time::LastFrameTime = 0;
|
||||
float TSE::Time::CurrentTime = 0;
|
||||
|
||||
void TSE::Time::Init(ITimeInterface *time)
|
||||
{
|
||||
Time::timeInterface = time;
|
||||
}
|
||||
|
||||
void TSE::Time::Destroy()
|
||||
{
|
||||
delete(timeInterface);
|
||||
}
|
||||
|
||||
float TSE::Time::deltaTime()
|
||||
{
|
||||
return DeltaTime;
|
||||
}
|
||||
|
||||
float TSE::Time::currentTime()
|
||||
{
|
||||
return CurrentTime;
|
||||
}
|
||||
|
||||
float TSE::Time::lastFrameTime()
|
||||
{
|
||||
return LastFrameTime;
|
||||
}
|
||||
|
||||
void TSE::Time::Update()
|
||||
{
|
||||
LastFrameTime = CurrentTime;
|
||||
CurrentTime = timeInterface->GetTotalEllapsedTime();
|
||||
DeltaTime = CurrentTime - LastFrameTime;
|
||||
}
|
||||
23
TSE_Core/src/utils/Time.hpp
Normal file
23
TSE_Core/src/utils/Time.hpp
Normal file
@@ -0,0 +1,23 @@
|
||||
#pragma once
|
||||
|
||||
#include "interfaces/ITimeInterface.hpp"
|
||||
|
||||
namespace TSE
|
||||
{
|
||||
class Time
|
||||
{
|
||||
private:
|
||||
static ITimeInterface* timeInterface;
|
||||
static float LastFrameTime;
|
||||
static float DeltaTime;
|
||||
static float CurrentTime;
|
||||
|
||||
public:
|
||||
static void Init(ITimeInterface* time);
|
||||
static void Destroy();
|
||||
static float deltaTime();
|
||||
static float currentTime();
|
||||
static float lastFrameTime();
|
||||
static void Update();
|
||||
};
|
||||
} // namespace TSE
|
||||
Reference in New Issue
Block a user