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.

Code Snippets / [DBP] Timerbased Movement-System

Author
Message
Mr Kohlenstoff
18
Years of Service
User Offline
Joined: 7th Jun 2006
Location: Germany
Posted: 7th Jul 2007 02:14
Hey again...

I was bored the last 30 minutes, so I created a small system for timerbased movement. I was so frustrated, that it was finished with just 15 lines, that I created two additional, nearly senseless functions and a much bigger example.

I think the system is working and used in many games in a similar way (correct me if I am wrong.. I just thought this kind of timerbased movement etc. would make most sense?). It's very easy to use...
Like always you should call the init-function at the beginning of your program (tm_init()), and in the mainloop the updatefunction (tm_update()). This updatefunction returns a factor, which should be used to change your timerbased variables like speed etc. as shown in the example.

Please don't mark this thread as spam, maybe it helps some people, who weren't aware that such a method of speedcontrolling is existing... Really, I just want to help!

Here the whole code with example:




And here just the functions.




If someone has ideas to improve the system (or knows that the system is completely useless because it has a general mistake I didn't notice so far.. who knows), just tell me, thanks.

Visit the DBPro - Speed up your game-Thread. http://forum.thegamecreators.com/?m=forum_view&t=88661&b=1
Sixty Squares
18
Years of Service
User Offline
Joined: 7th Jun 2006
Location: Somewhere in the world
Posted: 12th Jul 2007 00:13 Edited at: 12th Jul 2007 00:23
Pretty cool system I never knew timer based movement was so easy. Just one question. How do you know how far to move the camera and stuff? For example, say I wanted to move an object 5 units per loop. How would I convert this to timer based movement?

EDIT: Nevermind. After a little analysis of your code I understand it. Thanks for this! Not only are these functions useful, but just learned something very important. Good job . But the way I see it, wouldn't it be kinda hard to impliment in a huge game where lots of movement and decreasing of variables takes place at once?

Mr Kohlenstoff
18
Years of Service
User Offline
Joined: 7th Jun 2006
Location: Germany
Posted: 13th Jul 2007 00:23
Quote: "But the way I see it, wouldn't it be kinda hard to impliment in a huge game where lots of movement and decreasing of variables takes place at once?"


Yes, I think that would be much complicated work and probably cause many bugs.. but it shoudln't be too hard to include in a just started project, or in projects you'll start in future, and I think such a system is much more professional and usefull than just locking the sync rate..

Visit the DBPro - Speed up your game-Thread. http://forum.thegamecreators.com/?m=forum_view&t=88661&b=1
Commander in Chief
18
Years of Service
User Offline
Joined: 15th Apr 2006
Location: Carbondale, PA, USA
Posted: 21st Sep 2007 20:40 Edited at: 21st Sep 2007 20:56
I tried this on my nVidia 8500, just to see how much it can take...

20,000 cubes, took around 5 minutes to finish loading. Then took about 2 minutes to shut down. It ran at 4 FPS, with a maximum of 21 when looking away and all hidden.

With 0 cubes, I got a maximum of about 434 FPS. The amazing thing is with the 0 cubes I had visible, I got 23 FPS, but when I made the 0 cubes I had hidden, I got 434 FPS... big difference.

Very nice system, I never knew timer-based movement was so easy to use.

[Edit] Forgot the picture...


(Click "View" for enlarged picture)

Hardware: nVidia GeForce 8500GT 256mb, 240gb HD Space, Pentium 4 CPU 2.80GHz, 512mb RAM, Realtek HD Audio
Software: 3Ds Max 9, Adobe Photoshop CS8

Attachments

Login to view attachments
Kohaku
20
Years of Service
User Offline
Joined: 3rd May 2004
Location: The not very United Kingdom
Posted: 22nd Sep 2007 01:30
I'm pretty sure I've said this before somewhere, but cubes have never looked so awesome!


You are not alone.
Sid Sinister
19
Years of Service
User Offline
Joined: 10th Jul 2005
Location:
Posted: 24th Sep 2007 04:24
How does this compare to Ravens method?

http://forum.thegamecreators.com/?m=forum_view&t=53311&b=6

Your signature has been erased by a mod

Login to post a reply

Server time is: 2024-11-22 18:32:52
Your offset time is: 2024-11-22 18:32:52