Sorry your browser is not supported!

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.

Newcomers DBPro Corner / Character jitters when Timer Based Movement is applied.

Author
Message
cyangamer
16
Years of Service
User Offline
Joined: 2nd Jun 2008
Location: Houston, TX, USA
Posted: 3rd Jan 2009 17:28
After fixing my other problem, timer-based movement began to make a lot more sense, so I used Dark Coder's little spiel (just because it looks flashy). Well, the "real" FPS (not screen fps()) goes all over the place, between 1 and 70 (the Sync Rate and frame rate is set to 60). So as a result, I have my character jittering because the factor that determines his speed of travel is constantly varying widely, being 5 one millisecond and 65 the next.

Here are the functions, completely untouched:


and here's the movement code:

followed by a section of code from the main loop that updates the timer.


Is there a way to stop the jittering and make the movement smooth?

Currently working on - Enemy AI and Action Battle System

the sig limit needs to be raised...
cyangamer
16
Years of Service
User Offline
Joined: 2nd Jun 2008
Location: Houston, TX, USA
Posted: 4th Jan 2009 23:22 Edited at: 4th Jan 2009 23:55
Alright I figured out what the problem is, but I still don't know how to fix it. For some reason, TBM_IsPerf is set to 0 (even though it's set to 1 in the demo that I have). Because of that, instead of getting Elapsed and OldTime from Perftimer() (which apparently smooths this out), it just uses the Timer():


This is what it should be doing:

Don't know exactly how the code works, so there are some parts I'm not able to pick out and analyze well. Why does it work in Dark Coder's demo but not in mine?

Currently working on - Enemy AI and Action Battle System

the sig limit needs to be raised...
IanM
Retired Moderator
22
Years of Service
User Offline
Joined: 11th Sep 2002
Location: In my moon base
Posted: 5th Jan 2009 18:16
Is TBM_IsPerf declared as a global in your code?

The Wilderbeast
19
Years of Service
User Offline
Joined: 14th Nov 2005
Location: UK
Posted: 5th Jan 2009 19:18
If you haven't declared it global and try to use it in a function then the value resets ever loop.

Login to post a reply

Server time is: 2024-11-25 12:51:21
Your offset time is: 2024-11-25 12:51:21