Vector help please

Monkey Forums/Monkey Programming/Vector help please

slenkar(Posted 2011) [#1]
I am drawing a line from where the player is, to where he clicks.
Im trying to set the length of the line to 50 and draw it then.

Local startv:Vector=New Vector(p.x_map_pos,p.y_map_pos)
Local endv:Vector=New Vector(p.destination_x,p.destination_y)
Local wholev:Vector=New Vector(0.0,0.0)
wholev.MakeBetween(startv,endv)

If wholev.Length()>50
wholev.ReduceLength(wholev.Length()-50)
Endif

p.destination_x=p.x_map_pos+wholev.X
p.destination_y=p.y_map_pos+wholev.Y


but the new line I draw always looks like its a few degrees off.
(sometimes 4 sometimes 20)
Am I doing something wrong?

here is the code for makebetween:
	Method MakeBetween:Vector( PositionFrom:Vector , PositionToo:Vector)
		If PositionFrom = Null Or PositionToo = Null Then Return Self
		X = ( PositionToo.X - PositionFrom.X ) 	
		Y = ( PositionToo.Y - PositionFrom.Y )
		Return Self		
	End



muddy_shoes(Posted 2011) [#2]
What does "ReduceLength" do? It would be easier if you just posted the Vector class.


slenkar(Posted 2011) [#3]
Thanks

I messed up, it was really working

I was just drawing the line from the wrong place :)