Simulant  21.12-194
A portable game engine for Windows, OSX, Linux, Dreamcast, and PSP
throttle.h
1 #pragma once
2 
3 namespace smlt {
4 
5 class Throttle {
6 public:
7  Throttle(uint16_t fps):
8  wait_time_(1.0f / fps) {}
9 
10  /* Returns true if it's time for another update */
11  bool update_and_test(float dt) {
12  passed_ += dt;
13  if(passed_ >= wait_time_) {
14  passed_ -= wait_time_;
15  return true;
16  }
17  return false;
18  }
19 
20 private:
21  float passed_ = 0.0f;
22  float wait_time_ = 0.0f;
23 };
24 
25 }
smlt
Definition: animation.cpp:25
smlt::Throttle
Definition: throttle.h:5