View Single Post
# 12 09-10-2002 , 09:47 PM
kbrown's Avatar
Moderator
Join Date: Sep 2002
Location: London, UK
Posts: 3,198
Hehe...this wasn't as easy as it first sounded but here's one solution:

Code:
if (time == 0)
{
	//initialize
	Coin.rotateY = 0;
}
else if (time < 3)
{
	// accelerate to 3 secs of time
	Coin.rotateY = Coin.rotateY + time * 10;
}
else if (time < 6)
{
	// maintain constant speed while time is less than 6 secs
	Coin.rotateY = Coin.rotateY + 30;
}
else if (time >= 6 && time < 9)
{
	// decelerate back to zero speed between 6 and 9 secs
	Coin.rotateY = Coin.rotateY + 30 - 10 * (time - 6);
}

//this is just to prevent overflows
while (Coin.rotateY > 360)
	Coin.rotateY = Coin.rotateY - 360;
the deceleration equation might seem like a quick hack but it has a purpose if you think it over. I'll leave it to you to figure it out user added image Feel free to ask, if you don't understand...


Kari
- My Website
- My IMDB

Do a lot, Fail a lot and Learn a lot!

Last edited by kbrown; 09-10-2002 at 09:59 PM.