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.

DarkBASIC Professional Discussion / Timer Based Movement, Basic Use Help

Author
Message
Madscientist
16
Years of Service
User Offline
Joined: 23rd Aug 2009
Location: Between a rock and a hard place
Posted: 23rd Dec 2010 16:48
Well I'm starting a new game and it will be the first time using timer based movement. So I looked online to get a basic understanding of it. I came up with this simple code for it but can someone tell me if I've done it properly?
Here, timer damping is the amount to multiply the sprite movements by. Do I have to call up GetTimerDamping every time I position a sprite or just once at the top of my loop?


My computer surpasses all the technologies of the day. What computer do I have?

Indicium
18
Years of Service
User Offline
Joined: 26th May 2008
Location:
Posted: 23rd Dec 2010 17:06
The way I do it is like this:



Where t and factor# must be global, I then multiply my movement code by factor.



will move the object at 10unit/sec

Your method looks similar, I can't see why it wouldn't work, just remember to make tmr global

Madscientist
16
Years of Service
User Offline
Joined: 23rd Aug 2009
Location: Between a rock and a hard place
Posted: 23rd Dec 2010 17:16
Ok good, just checking, and Tmr is global.
Your's is pretty much the same except t is updated right after the factor# is taken. Does that make a difference? When am I actually supposed to update Tmr.LastF, before the sync, after it, or at the beginning of my loop?

My computer surpasses all the technologies of the day. What computer do I have?

Indicium
18
Years of Service
User Offline
Joined: 26th May 2008
Location:
Posted: 23rd Dec 2010 18:19
Nah it won't matter at all, neither does the point at which you update it, although I think it would be best if you update the timer based movement, make all your movements, then sync the screen.

Hope this helps

Madscientist
16
Years of Service
User Offline
Joined: 23rd Aug 2009
Location: Between a rock and a hard place
Posted: 23rd Dec 2010 18:37
Okay, I got it working but how would I get the screen to a constant sync rate of 60? I have it calculating FPS already.

My computer surpasses all the technologies of the day. What computer do I have?

Login to post a reply

Server time is: 2026-07-21 20:35:23
Your offset time is: 2026-07-21 20:35:23