You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.
Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.
float delta = 60.0f / dbScreenFPS();
// move player
player.pos += speed * delta;
float start = time.wMilliseconds;
//do player movement, et cedera, here.
//if W is being pressed, speed the player up.
//else slow them down.
if(dbKeyState(17) == 1) playerVelocityX += 0.1 * fpsDelayFix;
else playerVelocityX *= pow(0.85, fpsDelayFix);
//player velocity is to 85% to the power of fpsDelayFix.
//everything that has movement needs to be affected by 'fpsDelayFix'.
//even animation speeds will need to be adjusted in order to keep up
//when FPS gets low.
dbSync(); // refresh screen
//the 'total' variable will tell us how the this entire frame took to process
//since the wMilliseconds only tells us the ms in the current second, and not
// the ms since last called, we have to do this...
if(time.wMilliseconds > start) total = time.wMilliseconds - start;
else total = 1000 - start + time.wMilliseconds;
fpsDelayFix = 60 / (1000 / total);
// if the fps is 60, this variable will be set to 1, if it is 30 it will
//be set to 2. Meaning that the game will need to go twice as fast in order
//to run at normal speed. If the FPS is 2, the game will need to go 30 times
//as fast to make up for the lack of processing occurring each second.
Login to post a reply