made tons of stuff lol
This commit is contained in:
parent
36f0dae96b
commit
54c3acf092
16 changed files with 450 additions and 94 deletions
|
|
@ -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;
|
||||
}
|
||||
};}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue