Moving along a line

BlitzMax Forums/BlitzMax Beginners Area/Moving along a line

		Function TweenLinear#(X1#, X2#, Tween#)
		
			Value# = X1# + (Tween# * (X2# - X1#))
			Return Value#
			
		End Function


Start tween at 0, and increase to 1 and the return value will go from X1 to X2.

(X2# - X1#) is the length of the line. Multiplying that by Tween# gives us how far to travel along the line from point 1. Adding that to X1# gives us the final position.

If you want to move in 2D, you just call that function once to calculate the X and once to calculate the Y.