   trouble with sprites and timers
  I've been wrestling with this all afternoon and can't wrap my mind around it.Here's the objective: to move a sprite (non-animated) from one end of the screen to the other (a known distance) over time T (a known constant time), and have it do so smoothly.So far I am unable to do this.What I've tried is to use my two knowns (distance and time) to craft a velocity (in pixels) which I use to move my sprite. (Keeping it simple, assume I am only moving it horizontally, only changing the x value.) I am using all floats for these values right up until I draw them. (I'm using a traditional round, i.e. if it's less than 0.5 it's floor, otherwise it's ceiling.) I've tried to implement a "fixed frame rate" (which I am convinced is broken) which only draws everything every time segment, where a time segment is how much of a second I'd expect to lapse between frames to impose a fixed FPS.In my initial attempts, movement *always* seemed unreasonably slow (that is, it should take four seconds to move but takes a great deal longer) and stutters (very clear, more-than-one pixel jerks with each "step").My first thought was that if velocity's ever greater than or equal to two that it may cause the stutters I'm seeing, and perhaps dividing velocity by itself and the frame length by velocity will fix this (that is, always move one pixel). I don't like this because its' 1. two more divisions and 2. not addressing the root of the problem, which is how slow everything seems.The worst part is that removing my current timing code actually slows things down further. I know I'm doing it wrong, but so far I'm not sure how or why. I've read a few timing articles and threads this afternoon, and I'm embarrassed to say I can't make heads or tails of them. I'd very much appreciate a clear and for-idiots explanation of this timing stuff, which is why I've posted here.How do you implement a fixed frame rate for your sprite-based (or any) games?Thank you in advance.   
  After more digging (and a break to play MineCraft) I found this tutorial (ironically on this site) via Google.http://www.gamedev.net/reference/articles/article1604.aspThis thread has gotten a healthy number of hits and no responses, which leads me to believe people are interested in this, but no one who knows the deal has seen it yet. So here's something for us to look at. I'm mulching through it now.EDIT:Much clearer than anything I've seen today; if I understand it correctly, I essentially want to derive seconds_per_frame, and use it to divide any sprite's desired movement/second by in order to smooth out movement. I believe this is a "variable frame rate"? Whatever the term, I hope it works.   ;  There's an even better solution: Fix Your Timestep!;  Thank you very much, gg; I'll have a look.   ;  That was a good read; I'm not (yet) incorporating a physics engine, but I suspect my updates in general might go well within the timing loop? Here follows the code from that site with a very small modification:    float t = 0.0f;    const float dt = 0.01f;    float currentTime = time();    float accumulator = 0.0f;    while (!quit)    {    float newTime = time();    float deltaTime = newTime - currentTime;    currentTime = newTime;    accumulator += deltaTime;    while (accumulator>=dt)    {    // CALL ALL UPDATE FUNCS HERE    t += dt;    accumulator -= dt;    }    render(state);    }I'm not 100% where to poll for events in this basic loop; not sure if I should poll when I'm running updates, at fixed intervals (this is what the author seems to suggest - not in the article but in one of his commends on it), or poll every pass?Polling at regular intervals seems easy to do: he suggests doing it every 100hz. I'm confused though, as he set this loop up to keep things regular; I wonder why the input polling would be removed from it in this way?   ;  heres some food for thought.delta is your time and it is in seconds so 1 = 1 second.distance is how far you want to travel in one second.movement = distance * delta.you want to move 300 pixels in 6 seconds, that's 300 / 6 * delta.float delta = framesTime;speed = 200; // 200 pixels per secondfloat direction = 45; // direction the object is facing in degrees./** convert degrees to radians */float radians = (direction * 3.151492) / 180;/** get length based on speed to move along the x and or y axis */float xMovement = cos(radians) * (speed * delta);float yMovement = sin(radians) * (speed * delta);