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 / Coding Standard for TBM

Author
Message
CumQuaT
AGK Master
16
Years of Service
User Offline
Joined: 28th Apr 2010
Location: Tasmania, Australia
Posted: 28th May 2013 03:09
Hi guys,

Lamentably, I'm only ever able to be a part of this community in short bursts between long stretches of work, and so I'll often fall out of "normal practice".

Trying to find a decent Timer Based Movement routine, and doing a search of the forum returns dozens and dozens of different options. Currently, my game is using the RabbitTBM system, which is proving to be unsatisfactory, so I thought I'd drop a line here and see if there is an "all purpose" system for it which everyone has agreed upon as being the most appropriate for 3D while I've been away.

Or am I better off just playing around with the dozens of various methods and finding something that way?

Thanks guys! (I miss you all, btw!)


Mage
Valued Member
19
Years of Service
User Offline
Joined: 3rd Feb 2007
Location:
Posted: 28th May 2013 06:59
I'll post something here later today to help set you up. Although it would be helpful to know why the other methods were 'unsatisfactory'. That way I can throw in some added advice if need be.

Mage
Valued Member
19
Years of Service
User Offline
Joined: 3rd Feb 2007
Location:
Posted: 28th May 2013 09:44 Edited at: 28th May 2013 09:52
Timer Based Movement - Correcting For Changing Frame Rate.



A Few Short Points About Timer Movement...
The general idea is that with higher frame rate movement happens more often, and with lower frame rate movement happens less often. Therefore you need to make each movement bigger or smaller to keep object moving at the same speed.

This is done by creating a 'multiplier' that you scale individual movement jumps with.

This also applies to ANYTHING else that is affected by frame rate. Animation speed is an example.

Random Triggered Events require division not multiplication. If you have a 1 in 1000 chance of a bomb exploding each game loop, it should become less likely with higher frame rate. So divide the multiplier instead, and protect against division by zero. Only on events triggers that are affected by frame rate, and not for example based on input.


Don't Forget Safety Limits.
If a player pauses the game for 4 straight days, you don't want him teleporting into Jupiter orbit when he unpauses the game. So if more than a second is passing in your game loop, set the multiplier to zero. Nothing will move on that loop, and on the next loop the timing will normalize.


Avoid Frame Rate Smoothing.
There are a number of fantastic and brilliant people on the forum that like to smooth timing calculations over 30 frames. Avoid doing this. This is a horrible bad habit. Professional studios don't do this. If you have jitters, lag spikes, choppiness then this is painting over the problem. This is creating an effect that slows/speeds the game to try to hide the lag, instead of addressing the source of the lag and being efficient. This usually looks good to people designing the game, who can cap the frame rate, and stay at the cap, and ignore what actual player experience will be like. If your frame rate is erratic, your TBM code literally spits out the wrong answers every time. If your game is networked, then player speed will be all weird since their games are running at different speeds with little consistency. So do the grunt work and fix the lag problems directly.

CumQuaT
AGK Master
16
Years of Service
User Offline
Joined: 28th Apr 2010
Location: Tasmania, Australia
Posted: 28th May 2013 17:39
Thanks Mage! I'll definitely give this a go. Some great notes there.

So, I imagine that an example of using this would be something like:



Would that be right?


Mobiius
Valued Member
23
Years of Service
User Offline
Joined: 27th Feb 2003
Location: The Cold North
Posted: 28th May 2013 21:20 Edited at: 28th May 2013 21:32
No. You'd use it like this.

To move an object 100px per second.


To rotate an object 90 degrees per second..


And so on...

This is my current project, check it out! [url]forum.thegamecreators.com/?m=forum_view&t=204576&b=8[/url]
This is my website, check it out! [url]http:\\www.TeamDefiant.co.uk[/url]
Mage
Valued Member
19
Years of Service
User Offline
Joined: 3rd Feb 2007
Location:
Posted: 28th May 2013 23:22 Edited at: 28th May 2013 23:25
Just be aware of the bullet time variable. It defaults to 1.0 which is 100% game speed. But you can put things into slow motion by setting it to 0.5 etc. if it is set to 0 or simply never set to 1.0 then you'll wonder why your game is frozen.

Le Verdier
14
Years of Service
User Offline
Joined: 10th Jan 2012
Location: In the mosh-pit
Posted: 29th May 2013 13:01 Edited at: 29th May 2013 13:02
Don't use Timer() for a TBM...
Timer() resolution is only about 16 milliseconds that is, imho, not suitable for a game
use PerfTimer() for hires timing. perfimer is double integer
also use preffreq() (in dbp7.7) or QueryPerformanceFrequency in Kernel32.dll to get the frequency..
example:http://forum.thegamecreators.com/?m=forum_view&t=199373&b=11&msg=2387228#m2387228

Note: This works for "update position" variables type(ie pos=pos+speed#*dTime#)
for "updating speed" (Acceleration) something like fixed interval update is more suited

Burning Feet Man
18
Years of Service
User Offline
Joined: 4th Jan 2008
Location: Sydney, Australia
Posted: 29th May 2013 14:55 Edited at: 29th May 2013 14:57
Here is some Mage Advice (heh, geddit?) that Mage hit me up with a few moons ago after I slightly derailed the thread into TBM discussion;

Pro Tip: Reduce Power Consumption...

Worth the read.

Help build an online DarkBASIC Professional help archive.
DarkBasic Help Wikia
CumQuaT
AGK Master
16
Years of Service
User Offline
Joined: 28th Apr 2010
Location: Tasmania, Australia
Posted: 29th May 2013 15:54
Thanks guys. Some handy tips there.


Login to post a reply

Server time is: 2026-07-07 20:23:52
Your offset time is: 2026-07-07 20:23:52