Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- struct RealTimeEngine
- {
- i32 m_lastTicks;
- i32 m_coreSpeed;
- bool m_running = true;
- RealTimeEngine(const i32 &coreSpeed = 120) : m_coreSpeed(coreSpeed), m_lastTicks(0){}
- void Start() { m_lastTicks = clock(); m_running = true; }
- void Stop() { m_running = false; }
- i32 Steps()
- {
- if (m_running)
- {
- i32 tickDiff = clock() - m_lastTicks;
- i32 stepDiff = tickDiff * m_coreSpeed / 1000;
- m_lastTicks += stepDiff * 1000 / m_coreSpeed;
- return stepDiff;
- }
- return 0;
- }
- };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement