View Single Post
Old 18th March 2005, 11:28   #224
Major Dude
Mr_Nudge's Avatar
Join Date: Apr 2004
Location: melbourne, australia
Posts: 655
cos and sin functions , as most people know, clamp variables between 1 and -1, but the thing is, cos/sin doesn't just flip when in reaches -1 or 1, it slows down, so when it reaches 1 or -1 it is actually at a dead stop and then goes so slow it goes backwards. sin/cos is fine for movement, but not for counters or any other types of timers, because the rate of change will increase as it gets closer to 0 and then start slowing down. Here's a nifty piece of code that keeps the rate of change constant and still clamps between 1 and -1:



there you go. a lot longer, but keeps a constant speed.

Life's a game, break the rules
Click here
Mr_Nudge is offline   Reply With Quote