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 / DB Feature Request...

Author
Message
iaretony
23
Years of Service
User Offline
Joined: 6th Jun 2003
Location:
Posted: 31st Jul 2003 20:44
Framerate independant linear interpolation is very important for making you're games run at the same speed on machines with different HW.

Framrate independant eased interpolation is great because not only does it offer the benefit of making you're game run the same on different machines, but it also looks really cool... You're characters speed up at the beginning of their movement, and slow down as they reach their target...

I really think DB needs to add a couple commands that do these two things. I know they are simple to implement, but DB is all about making it easier to write games...

Anyhow, here is my frame rate independant eased interpolation function. You pass in the start time of the animation, the duration (how long the animation should last) and starting and ending values (usually you're start value is you're characters current position, and you're ending value is where you want him to move to)... I'm also including a test function that visually shows the output of the interpolator (it looks like a sine wave)... You'll need to put some setup code around this to make it work, but that should be trivial...

function ease_interp( start_time# as float, duration# as float, from# as float, to# as float )
`DarkBasic's trigonmetric functions take degrees, not radians
`as this formula assumes. So they must be converted.
`(1+cos(t*pi))/2
now# = timer()
time_delta# = now# - start_time#
value# = (1+cos(((time_delta# / duration#)*3.14159)*(180/3.14159))) / 2
if from#
iaretony
23
Years of Service
User Offline
Joined: 6th Jun 2003
Location:
Posted: 31st Jul 2003 20:45
Oops... That got screwed up... Let me try that again...

Rob K
Retired Moderator
23
Years of Service
User Offline
Joined: 10th Sep 2002
Location: Surrey, United Kingdom
Posted: 31st Jul 2003 21:03
Any feature requests need to be emailed to [email protected] if you want results

Login to post a reply

Server time is: 2026-07-21 21:13:37
Your offset time is: 2026-07-21 21:13:37