updated naming
This commit is contained in:
+20
-29
@@ -2,63 +2,54 @@
|
||||
#define TIMER_HPP
|
||||
|
||||
#include <chrono>
|
||||
#include <cstddef>
|
||||
#include <functional>
|
||||
#include <memory>
|
||||
#include <ncurses.h>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
class timer;
|
||||
class Timer;
|
||||
|
||||
struct balkjes {
|
||||
int startx;
|
||||
int starty;
|
||||
int yhight;
|
||||
};
|
||||
|
||||
class timeraction {
|
||||
class TimerAction {
|
||||
public:
|
||||
virtual ~timeraction() = default;
|
||||
virtual void update(const timer &t) = 0;
|
||||
virtual ~TimerAction() = default;
|
||||
virtual void update(const Timer &t) = 0;
|
||||
};
|
||||
|
||||
class timer {
|
||||
class Timer {
|
||||
private:
|
||||
double accumulator = 0;
|
||||
int triggeramount = 0;
|
||||
int trigger_amount = 0;
|
||||
double time_interval = 1; // only display every 1 seconds
|
||||
|
||||
|
||||
|
||||
public:
|
||||
std::string name;
|
||||
int triggercounter = 0;
|
||||
int trigger_counter = 0;
|
||||
bool is_infinite = false;
|
||||
std::unique_ptr<timeraction> action;
|
||||
std::unique_ptr<TimerAction> action;
|
||||
bool is_expired = false;
|
||||
|
||||
|
||||
//infinite timer
|
||||
timer(std::string name_input, double interval_input,
|
||||
std::unique_ptr<timeraction> action_input
|
||||
Timer(std::string name_input, double interval_input,
|
||||
std::unique_ptr<TimerAction> action_input
|
||||
);
|
||||
|
||||
|
||||
//limited timer
|
||||
timer(std::string name, double interval_input, int triggeramount,
|
||||
std::unique_ptr<timeraction> action
|
||||
Timer(std::string name, double interval_input, int trigger_amount,
|
||||
std::unique_ptr<TimerAction> action
|
||||
);
|
||||
// callbackfunc once enough time has accumulated
|
||||
void updatetime(double DeltaTime);
|
||||
void updatetime(double delta_time);
|
||||
};
|
||||
|
||||
// manage collection of timers
|
||||
class timermanager {
|
||||
std::vector<std::unique_ptr<timer>> timers;
|
||||
std::chrono::steady_clock::time_point prevtime; // initial starttime
|
||||
class TimerManager {
|
||||
std::vector<std::unique_ptr<Timer>> timers;
|
||||
std::chrono::steady_clock::time_point prev_time; // initial starttime
|
||||
|
||||
public:
|
||||
timermanager();
|
||||
void addtimer(std::unique_ptr<timer> input_timer);
|
||||
TimerManager();
|
||||
void addtimer(std::unique_ptr<Timer> input_timer);
|
||||
void updatetimers();
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user