Optimising Challenge

BlitzMax Forums/BlitzMax Programming/Optimising Challenge

The forum is locked. These are the original blitzbasic.com forums, kept so they can still be read. No new topics, replies or edits can be made here. To join in, head over to the Blitz3D+ forums.

Basically I want to use Floyds routine to make one item look at another item but with tweening.

Here is the new code. How can I make it work with atan2 to make something point at something else? I tried but get negative spinning again.


Angle = Atan2( y2 - y1 , x2-x1 ) + 90
If Angle<360 Angle:+360
if Angle>360 Angle:-360

'NOTE: I assume something is wrong with how I generate Angle... it somehow breaks floyd's code below despite being in the range.

' Assumes p1 and p2 are in the range [0,360) and t is in [0,1].
Function TweenAngle#( p1# , p2# , t# )
	
	Local angle# = p1 + t * (p2 - p1)
	
	If p1 <= p2 Then Return angle
	
	angle :+ t * 360.0
	
	If angle < 360.0
		Return angle
	Else
		Return angle - 360.0
	End If
	
End Function