ClawMachineCosplay/Time.h

22 lines
405 B
C
Raw Normal View History

2024-06-01 02:22:57 +02:00
class Time {
private:
unsigned long lastTime;
float m_deltaTime;
public:
Time() {
lastTime = millis();
m_deltaTime = 0.0f;
}
void update() {
unsigned long currentTime = millis();
m_deltaTime = (currentTime - lastTime) / 1000.0f; // Convert to seconds
lastTime = currentTime;
}
float deltaTime() {
return m_deltaTime;
}
};