| left and right mouse to switch between targets, so the issue is that when right clicking( do it a few times) you will notice something fishy with the direction of travel, the angles it's getting are off, but working as intended when going to the left. 
 
 
Import mojo
Class Test Extends App
		
	Field velx:Float
	Field vely:Float
	Field x:Float
	Field y:Float
	Field angle:Float
	Field speed:Float
	Field moving:Bool
	Field target:Int
	
	Method OnCreate()
		SetUpdateRate 60
		Self.moving=False
		
	End
	
	
	
	Method OnUpdate()
		If MouseDown(0)
			Self.x=320
			Self.y=220
			Self.angle=Rnd(-180,180)
			Self.SetVelocities()
			Self.speed=5
			Self.moving=True
			Self.target=1
		Endif
		
		If MouseDown(1)
			Self.x=320
			Self.y=220
			Self.angle=Rnd(-180,180)
			Self.SetVelocities()
			Self.speed=5
			Self.moving=True
			Self.target=2
		Endif		
		
		If Self.moving
			Self.x+=Self.velx*Self.speed
			Self.y+=Self.vely*Self.speed
			Select Self.target
				Case 1
					Self.TurnTo(20,220,5)
				Case 2
					Self.TurnTo(620,220,5)
			End Select
		Endif
	End
	Method OnRender()
		SetColor(0,255,0)
		DrawOval (320,220,10,10)
		
		SetColor (0,0,255)
		DrawOval(Self.x,Self.y,10,10)
		
		SetColor(255,0,0)
		DrawOval (620,220,10,10)
		DrawOval (20,220,10,10)
	End
	Method TurnTo:Void(_x:Float, _y:Float, _step:Float)
		Local min:Float = -180;
		Local max:Float = 180;
		Local half:Float = 0
		Local retval:Float = 0.0;
		Local _start:Float = Self.angle
		Local _End:Float = ATan2(Self.x - _x, Self.y - _y)
		'Print "end = " + _End
		_End -= 180
		'Print "end = " + _End
		
	 	If (_End - _start) < -half And (_End - _start)>min And (_End - _start)<max Then
				retval = (_start-_step)
				
			ElseIf(_End - _start) >= half And (_End - _start) > min And (_End - _start) < max Then
				retval = (_start+_step)	
						
			ElseIf(_End - _start) < min Then
				
				retval = (_start+_step)
				Repeat
					If retval<-180 Then retval+=360
					If retval>180 Then retval -=360
				Until retval>=-180 And retval<=180
				
			ElseIf(_End - _start) >= max Then
	
				retval = (_start-_step)
				Repeat
					If retval<-180 Then retval+=360
					If retval>180 Then retval -=360
				Until retval>=-180 And retval<=180
							
			Else
				retval = _start
		Endif
	
	   	Self.angle = retval
		Self.SetVelocities()
	End	
	Method SetVelocities:Void()
		Self.velx = Sin(Self.angle)
		Self.vely = Cos(Self.angle)
	End Method	
End
Function Main()
	New Test
End
 
 thanks in advance, just not seeing the problem at the moment and its starting to really annoy me.
 
 
 |