I originally coded this in Java, but i recoded it in C++ to use on gellin's base to recreate the font without causing lag.
So basically what this code does is it cause's the execution of certain code to be delayed, like the Sleep() function, but it doesn't cause the whole thread to pause, therefore there is no lag. It just takes the current system times, waits the ammount specified, and then lets execution of the method continue.
This code IS c/p friendly.
If your using this more generally (like not in gellin's base) then use this example.
EXAMPLE 1
Wait.h
Code:
#include <time.h>
class cWait{
public:
void wait(int waittime);
void startWait();
bool isWait();
};
extern class cWait Wait;
Wait.cpp
Code:
#include "Wait.h"
long waitin;
long t0, t1;
void cWait::wait(int waittime){
waitin = waittime;
}
void cWait::startWait(){
t0 = time(NULL) * 1000;
}
bool cWait::isWait(){
t1 = time(NULL) * 1000;
return (t1 - t0) < waitin;
}
If your using this class with gellin's base, then use this example.
EXAMPLE 2
Wait.h
Code:
#include <time.h>
class cWait{
public:
void startWait();
bool isWait();
};
extern class cWait Wait;
Wait.cpp
Code:
#include "Wait.h"
long waitin = 20000;
long t0, t1;
void cWait::startWait(){
t0 = time(NULL) * 1000;
}
bool cWait::isWait(){
t1 = time(NULL) * 1000;
return (t1 - t0) < waitin;
}
Then to add this to your RenderFrame.
Use (In Gellin's base)
Code:
if(!Wait.isWait()){
this->UpdateFont(pDevice);
Wait.startWait();
}
If you don't understand this code, or think it's worthless, let me know. Just trying to help lol.