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 problems - delta time

Author
Message
greenlig
22
Years of Service
User Offline
Joined: 30th Aug 2003
Location: Melbourne
Posted: 13th Apr 2010 08:51
Hi people,

I have a fairly simple problem confronting me. I want to implement delta-time into my very simple program. Basically, I want to gauge the time it takes in seconds for one frame to be processed, and multiply the movement speed of my circle by that number each frame.

The code I have is very simple too. I flogged some of it from a post I searched earlier. The problem I seem to be coming up against is that the time.move variable seems to reset to 0 occasionally, stuffing up the circle moving across screen. Also, it doesn't exactly seem to be frame-rate independent.

I understand the basic principle of delta-time, and how to use it, but for the life of me I cannot implement it, or find an example with enough documentation to help my fairly limited coding mind.

The end result I am using this for is a timer. Basically, I want to say "If dude hits this thing, increment this number in seconds till it reaches this ceiling, then reset it". I imagine that would be fairly simple to do, I just need delta-time to work!

So, without further ado, here is my amazingly manly code. Also, if you are willing to help, please explain what you are doing, because I would love to be able to help others when my turn comes to do so!



Thanks in advance for your help guys!

Regards,
Greenlig

Your signature has been erased by a mod as it is far too big.
dark coder
23
Years of Service
User Offline
Joined: 6th Oct 2002
Location: Japan
Posted: 13th Apr 2010 09:05 Edited at: 13th Apr 2010 09:06
Something like this makes more sense:



I don't know why you'd want to position an object by the time delta, that would just make the inaccuracies very obvious as shown in your example.

greenlig
22
Years of Service
User Offline
Joined: 30th Aug 2003
Location: Melbourne
Posted: 13th Apr 2010 11:14
Thanks heaps for the help Dark Coder. I have been making stuff in Unity and with all movement, you multiply it by delta time to get timer-based movement.

Once again, thank-you for the help!

Greenlig

Your signature has been erased by a mod as it is far too big.
bjadams
AGK Backer
18
Years of Service
User Offline
Joined: 29th Mar 2008
Location:
Posted: 13th Apr 2010 21:33
there's a timer based movement plugin
greenlig
22
Years of Service
User Offline
Joined: 30th Aug 2003
Location: Melbourne
Posted: 14th Apr 2010 02:28
@ BJadams - Not sure what you are referring to...Where is this plugin of which you speak?

Greenlig

Your signature has been erased by a mod as it is far too big.
bjadams
AGK Backer
18
Years of Service
User Offline
Joined: 29th Mar 2008
Location:
Posted: 14th Apr 2010 09:40 Edited at: 14th Apr 2010 09:40
Timer Plugin by ShaunRW

It was on the Newsletter too

http://forum.thegamecreators.com/?m=forum_view&t=163865&b=5&p=0
Deego
18
Years of Service
User Offline
Joined: 21st May 2008
Location:
Posted: 16th Apr 2010 01:29 Edited at: 16th Apr 2010 01:32
http://forum.thegamecreators.com/?m=forum_view&t=130673&b=1

Mage has the solution to your problem right there. It works perfect for me; I've used it for every project I've done. No plug ins or anything, just the raw power of DBPro code.

Quote: "
What this does is make all movement appear as if it were going at 60 frames per second. If you have a low frame rate, the objects move at larger intervals, if you have a higher frame rate they move at smaller intervals. This can be applied to anything that is affected by differences in framerate not just movement.
"

Login to post a reply

Server time is: 2026-07-26 12:34:11
Your offset time is: 2026-07-26 12:34:11