PATH EDITOR

BlitzPlus Forums/BlitzPlus Programming/PATH EDITOR

This is what i have tried so far but somethings wrong, i can't quite think what it might be :(


.start
Global new_id=1			; stores a new id
Global current_id=1		; holds the current target id




	Type path

		Field x
		Field y
		Field id
	
	End Type



	
 



	Function create_point()			; create a path point

		p.path	=	New path
	
		p\x=Int(MouseX())			; store x position
		p\y=Int(MouseY())			; store y position
		p\id=new_id
		new_id=new_id+1
	
	End Function







	Function update_path(x,y)			; use objects co-ordinates to calculate the path

		For p.path	=	Each path			; cycle through each point

			If p\id=current_id 				; until id matches current id
			
				If x<p\x Then x=x+1
				If x>p\x Then x=x-1
				If y<p\y Then y=y+1
				If y>p\y Then y=y-1			
		
				If x=p\x And y=p\y Then current_id=current_id+1
			
			
			EndIf
		
			Plot p\x,p\y
			
		Next
	
	End Function