time keeping / deltatime now handled by timermanager instead of main

This commit is contained in:
2026-07-16 18:49:11 +02:00
parent 523dac1f4d
commit db8fc15560
3 changed files with 65 additions and 46 deletions
+20 -3
View File
@@ -1,6 +1,7 @@
#ifndef TIMER_HPP
#define TIMER_HPP
#include <chrono>
#include <cstddef>
#include <functional>
#include <memory>
@@ -10,6 +11,12 @@
class timer;
struct balkjes {
int startx;
int starty;
int yhight;
};
class timeraction {
public:
virtual ~timeraction() = default;
@@ -47,11 +54,12 @@ public:
// manage collection of timers
class timermanager {
std::vector<std::unique_ptr<timer>> timers;
std::chrono::steady_clock::time_point prevtime; // initial starttime
public:
void addtimer(std::unique_ptr<timer> input_timer);
void updatetimers(double dtime);
timermanager();
void addtimer(std::unique_ptr<timer> input_timer);
void updatetimers();
};
class swapaction : public timeraction {
@@ -63,6 +71,15 @@ public:
void update(const timer &t);
};
class printaction : public timeraction {
public:
size_t it_i = 0;
bool iscomplete = false;
std::vector<balkjes> &input_vector;
printaction(std::vector<balkjes> &input_vector);
void update(const timer &t);
};
#endif