Hello
I have a basic node system that stores points as well as the points they are connected to in my JavaScript like this:
var path = [];
path[0] = {'x':1,'y':3,'linksTo':[1],'id':0};
path[1] = {'x':1,'y':4,'linksTo':[0],'id':1};
path[2] = {'x':1,'y':1,'linksTo':[3] ,'id':2};
path[3] = {'x':1,'y':0,'linksTo':[2] ,'id':3};
Now the end result looks something along the lines of this in my game:
The yellow dots represent the nodes stored in my path data. Now the question is how do i simplify this for when a user is building a road on the map so it automatically corrects the data.
Essentially if a user builds an intersection the nodes will update accordingly to keep the data clean and simple here is an example with the nodes in the place they should be:
The logic to do this seems quite complex and am hoping for some guidance on the best way to do this, i don't really know where to begin with adding the functionality to do this. The paths can go in 8 compass directions, N,S,E,W,NE,SE,SW and NW.