From de7ee5ef022a8ccaece0ea5f5402adedeafe36b4 Mon Sep 17 00:00:00 2001 From: Star Rauchenberger Date: Sat, 12 Mar 2022 09:05:21 -0500 Subject: added back bump sound (and assets for fuller music) --- src/timer.h | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 src/timer.h (limited to 'src/timer.h') diff --git a/src/timer.h b/src/timer.h new file mode 100644 index 0000000..ec34f3e --- /dev/null +++ b/src/timer.h @@ -0,0 +1,32 @@ +#ifndef TIMER_H_45E2F1F9 +#define TIMER_H_45E2F1F9 + +class Timer { +public: + + Timer(int dt) : dt_(dt) {} + + void accumulate(int t) { + acc_ += t; + } + + bool step() { + if (acc_ > dt_) { + acc_ -= dt_; + return true; + } else { + return false; + } + } + + void reset() { + acc_ = 0; + } + +private: + + int dt_; + int acc_ = 0; +}; + +#endif /* end of include guard: TIMER_H_45E2F1F9 */ -- cgit 1.4.1