Files
Blitz/include/blitz/misc/TickCounter.h
Persson-dev c2c6f1f033
All checks were successful
Linux arm64 / Build (push) Successful in 4m59s
C'est important la doc (#43)
C'est très long

Co-authored-by: Morph01 <thibaut6969delastreet@gmail.com>
Reviewed-on: #43
Co-authored-by: Persson-dev <sim16.prib@gmail.com>
Co-committed-by: Persson-dev <sim16.prib@gmail.com>
2024-04-11 17:17:40 +02:00

68 lines
1.1 KiB
C++

#pragma once
/**
* \file TickCounter.h
* \brief File containing the blitz::utils::TickCounter class
*/
#include <cstdint>
namespace blitz {
namespace utils {
/**
* \class TickCounter
* \brief Class used to count ticks
*/
class TickCounter {
private:
float m_TPS;
float m_MSPT;
std::uint64_t m_LastTPSTime;
std::uint8_t m_TickCount;
int m_TargetTPS;
public:
/**
* \brief Constructor
* \param tps The target ticks per second
*/
TickCounter(int tps) : m_TargetTPS(tps) {}
/**
* \brief Reset the tick counter
*/
void Reset();
/**
* \brief Update the tick counter
* \return True if the tick counter has been updated
*/
bool Update();
/**
* \brief Get the ticks per second
* \return The ticks per second
*/
float GetTPS() const {
return m_TPS;
}
/**
* \brief Get the milliseconds per tick
* \return The milliseconds per tick
*/
float GetMSPT() const {
return m_MSPT;
}
/**
* \brief Set the ticks per second
* \param mspt The ticks per second
*/
void SetMSPT(float mspt) {
m_MSPT = mspt;
}
};
} // namespace utils
} // namespace blitz