made tons of stuff lol

This commit is contained in:
kin fuyuki 2025-12-21 03:01:29 -03:00
commit 54c3acf092
No known key found for this signature in database
GPG key ID: 0E4E8E519FB71401
16 changed files with 450 additions and 94 deletions

View file

@ -1,8 +1,17 @@
#pragma once
#define CFG this->CONF()
#include <immintrin.h>
#include <time.h>
namespace enginend{
extern const long long CPUCLOCK;
inline const char* COMMONCONFIG();
class program {
unsigned long long currenttick = __rdtsc();
unsigned long long currentframe = __rdtsc();
public:
int tickrate;
int framerate;
program():client(false){}
program(bool isclient):client(isclient){}
virtual const char* CONF()=0;
@ -11,4 +20,23 @@ public:
virtual void tick()=0;
virtual void draw()=0;
virtual void exit()=0;
};
bool shouldtick() {
unsigned long long now = __rdtsc();
unsigned long long interval = CPUCLOCK / tickrate;
if (now - currenttick >= interval) {
currenttick = now;
return true;
}
return false;
}
bool shoulddraw() {
unsigned long long now = __rdtsc();
unsigned long long interval = CPUCLOCK / framerate;
if (now - currentframe >= interval) {
currentframe = now;
return true;
}
return false;
}
};}