put classes in own file implemented basic wchar printing using timer

This commit is contained in:
2026-07-10 19:49:09 +02:00
parent 3834d764c1
commit f3b7de0489
3 changed files with 111 additions and 70 deletions
+50
View File
@@ -0,0 +1,50 @@
#ifndef TIMER_HPP
#define TIMER_HPP
#include <cstddef>
#include <functional>
#include <memory>
#include <ncurses.h>
#include <string>
#include <vector>
class timer {
private:
double accumulator = 0;
int triggeramount = 0;
double time_interval = 1; // only display every 1 seconds
public:
std::string name;
int triggercounter = 0;
bool is_infinite = false;
std::function<void(const timer&)> callbackfunc;
bool is_expired = false;
//infinite timer
timer(std::string name_input, size_t interval_input,
std::function<void(const timer &)> callback_input);
//limited timer
timer(std::string name, size_t interval_input, int triggeramount,
std::function<void(const timer &)> callback);
// callbackfunc once enough time has accumulated
void updatetime(double DeltaTime);
};
// manage collection of timers
class timermanager {
std::vector<std::unique_ptr<timer>> timers;
public:
void addtimer(std::unique_ptr<timer> input_timer);
void updatetimers(double dtime);
};
#endif