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 / Constant animation speed under different PC hardware specs ?

Author
Message
Juggernaut
14
Years of Service
User Offline
Joined: 12th Mar 2012
Location:
Posted: 12th Aug 2012 17:17
Hello,

How can I make sure that the animation speed of the characters work at the same speed under different PC hardware ?
DVader
22
Years of Service
User Offline
Joined: 28th Jan 2004
Location:
Posted: 12th Aug 2012 18:10
Search for timer examples. Control your sync timing, using a timer so it only updates at the FPS of your choice.

Pincho Paxton
23
Years of Service
User Offline
Joined: 8th Dec 2002
Location:
Posted: 12th Aug 2012 19:02
If t <= timer()
Update animation frame
t = timer() + 60(whatever)
Endif

Juggernaut
14
Years of Service
User Offline
Joined: 12th Mar 2012
Location:
Posted: 13th Aug 2012 01:55
Thank you Paxton for the code snippet. It will definitely help me.

And DVader, thank you too for your advice. I will search for such examples.
WLGfx
18
Years of Service
User Offline
Joined: 1st Nov 2007
Location: NW United Kingdom
Posted: 13th Aug 2012 02:14
If you google more information about Delta-Timing this will help you. Also, some things only have to be calculated once with the delta multiplier, while others will have to be divided individually to stop things from flying straight through walls and such. So you still have to be careful with your coding technique.

Mental arithmetic? Me? (That's for computers) I can't subtract a fart from a plate of beans!
Warning! May contain Nuts!
Zwarteziel
15
Years of Service
User Offline
Joined: 22nd Jan 2011
Location: Netherlands
Posted: 13th Aug 2012 08:00
I've read about the Enhanced Animation plugin, that - besides a bunch of other useful stuff - also has timer-based functions. I'm contemplating buying it... Is it recommended by fellow DBPro-users?
WLGfx
18
Years of Service
User Offline
Joined: 1st Nov 2007
Location: NW United Kingdom
Posted: 13th Aug 2012 13:28 Edited at: 13th Aug 2012 13:33
Okay, so it's the wrong language and not DBP but the actual piece for the timer based movement is in there:



By using the number of milli-seconds since the last frame update, you can multiply the movement for all animations.

EDIT: That should be easier to read...

Mental arithmetic? Me? (That's for computers) I can't subtract a fart from a plate of beans!
Warning! May contain Nuts!
Dar13
18
Years of Service
User Offline
Joined: 12th May 2008
Location: Microsoft VisualStudio 2010 Professional
Posted: 13th Aug 2012 16:55
Quote: "I've read about the Enhanced Animation plugin, that - besides a bunch of other useful stuff - also has timer-based functions. I'm contemplating buying it... Is it recommended by fellow DBPro-users?"

Enhanced animation is a great plugin for combining and transitioning between animations. I wish there was an equivalent for the graphics API that I'm using currently.

TheComet
18
Years of Service
User Offline
Joined: 18th Oct 2007
Location: I`m under ur bridge eating ur goatz.
Posted: 14th Aug 2012 00:54 Edited at: 14th Aug 2012 00:56
I wrote some animation code a while ago, you're free to use it. You might have to remove the debugging code from it though (DebugOutput() and AddTextToConsole() can be removed).



There is a variable in there called TBM.delta#. That is your timer based movement variable everyone is talking about above. You will have to code that part as well, just use UDTs to define it:



The code has the following functions:

InitAnimation() - Must be called before using any other functions.
ControlAnimation() - Must be called once every loop.
PlayObject( ObjID , StartFrame# , EndFrame# , Speed# ) - Will play an object's animation.
LoopObject( ObjID , StartFrame# , EndFrame# , Speed# ) - Will loop an object' animation.
StopObject( ObjID ) - Will stop a playing object.
return value = ObjectFrame( ObjID ) - Returns the current animation frame.
return value = ObjectPlaying( ObjID ) - Returns 1 if playing, 0 if not playing.

You MUST ALWAYS call StopObject() BEFORE playing a new animation!!! Otherwise the code will try to play two different animations using the same object, and a rubber bunny with a knife will jump out of your screen and stab you to death

An example:



TheComet

Your mod has been erased by a signature, please reduce him [overall] to no larger than 120 kg please.
Juggernaut
14
Years of Service
User Offline
Joined: 12th Mar 2012
Location:
Posted: 14th Aug 2012 01:39
WLGfx, TheComet - thank you for all the whole hearted help.

Login to post a reply

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