Original Post
I searched a lot with google, but I didn't find anything useful, except perhaps tweening, but I dont think it will solve my problem, since that is only for fast speeds.
Short:
The particle jumps forth instead of moving at a constant speed.
The problem is totaly eliminated when I turn vsync on (steady 60fps) and have a constant time step of 1. I tried setting the same speed with the normal update mode, but it jumps again - I'M PRETTY SURE THE PROBLEM LIES IN MY UPDATING
Additional:
it is a simple 2d sprite particle that moves a bit per ms.
This function is called in my loop before render phase, given the time step calculated based on last update
Time = timeGetTime();
checkSystemMessageQue = parses every message on the message queue if there are any
Long:
The problem is that the sprite jumps forth every so often by an uneven amount, as if the step isnt called for a lot of time. This is not the case, because I have a steady fps of 1400, and it even occurs when I have vsync turned on. I used to do an update every frame, but than realised that that way the amount time elapsed between two updates can be really small and the update will get called with timesteps of 0. I than implemented a second version which you can see above. Didnt help much.
I tried rendering the particle only in screen pixels (minimal location change was 1pixel etc) but no improvements; I render an antialiased circle so slow speeds arent a problem, but I am suspecting this is only because the step is so small a skipped update isnt noticeable.
Thanks!
[Edited by - eagerone on June 27, 2010 2:07:01 AM]
Short:
The particle jumps forth instead of moving at a constant speed.
The problem is totaly eliminated when I turn vsync on (steady 60fps) and have a constant time step of 1. I tried setting the same speed with the normal update mode, but it jumps again - I'M PRETTY SURE THE PROBLEM LIES IN MY UPDATING
Additional:
it is a simple 2d sprite particle that moves a bit per ms.
particle.position.x += particle.speed.x*time_step;particle.position.y += particle.speed.y*time_step;This function is called in my loop before render phase, given the time step calculated based on last update
last_update = Time();while(checkSystemMessageQue()!=QUIT){ elapsed = Time()-last_update; if(elapsed>0){ particle.doStep(elapsed); last_update = Time(); } particle.doRender();}Time = timeGetTime();
checkSystemMessageQue = parses every message on the message queue if there are any
Long:
The problem is that the sprite jumps forth every so often by an uneven amount, as if the step isnt called for a lot of time. This is not the case, because I have a steady fps of 1400, and it even occurs when I have vsync turned on. I used to do an update every frame, but than realised that that way the amount time elapsed between two updates can be really small and the update will get called with timesteps of 0. I than implemented a second version which you can see above. Didnt help much.
I tried rendering the particle only in screen pixels (minimal location change was 1pixel etc) but no improvements; I render an antialiased circle so slow speeds arent a problem, but I am suspecting this is only because the step is so small a skipped update isnt noticeable.
Thanks!
[Edited by - eagerone on June 27, 2010 2:07:01 AM]