Bah! Timers

Started by
2 comments, last by Shadwdrak 24 years, 1 month ago
Well this is becomming much more of a chore that I first imagined. I have a 2d tile engine, it runs untimed at a frame rate between 53-63. To make everything animate and play smooth I wanted to use a timer. I have tried adding the timer to the blitting portion of the code, the entire main loop, and I tried updating the distance moved by the character based on the ammount of time passed. All of these game me basically the same result CHOPPY PLAY!! I figured if I could run untimed at 53-63 fps, I should run great timed to 30fps, but this is not the case. It seems the lower the targeted frame rate the more chop I get. If anyone has any ideas please feel free to post. -Shadwdrak
Advertisement
from what i know, a timer is simply a bit a code that pauses the game loop a few milliseconds between each loop. i would think that not pausing the loop at all would improve frame rate. am i wrong? i dont use timers too heavily. otherwise, it seems to me you have a lot of provesses going on that could be optimized (i.e using look-up tables for trig functions, etc.), or your CPU can''t handle it. what are your specs?
From your original post it seems that you're unclear on the concept of frames per second (fps) and timers

By using a timer to lower you fps from 50 down to 30 that is supposed to make it more choppy! Raising frame rates higher than 50 would create smoother graphics.

Timers are simply used to allow consistent motion at any fps. You check your timer and find out how much to move your sprites according to the time gone past(speed variables), you dont use a timer to check to see how much to slow down your fps (although you can, and people do, but dont use it to slow it down that much)

Edited by - Atavist on 3/16/00 10:57:36 PM
Just because the church was wrong doesn't mean Galileo wasn't a heretic.It just means he was a heretic who was right.
int movefar = (timeGetTime() - timeCount) / 5;
timeCount = timeGetTime();

if(KEY_DOWN(VK_RIGHT))
{
PLAYER_X -= movefar; // current x pos on screen
if(PLAYER_X <= -16)
{
PLAYER_X = 0 + (PLAYER_X % movefar);
GLOBAL_X++; // globalx is the the x value of the TL element in the map matrix
if(GLOBAL_X + 41 > MAPWIDTH)
{
GLOBAL_X = MAPWIDTH - 41;
PLAYER_X = -16;
}}}

Does the above code look anywhere close to reasonable? Am I using the timer in an appropriate way?

-Shadwdrak

This topic is closed to new replies.

Advertisement