How do I connect a set of nodes?

Get help using Construct 2

Post » Tue Jun 20, 2017 11:08 pm

I am currently able to generate a random set of nodes in my project.

The problem that I have is I don't know any efficient way to connect nodes and store their connection data. For example:

Image

The selected node would be #1 and the selected path is in blue. I would use the arrow keys to toggle between the paths and the selected path/connection would change. I would also want the player to be able to select paths behind them to move back (using the same method to toggle between different paths). The nodes have a varying number of connections so I feel that using instance variables for each node would not work well in this case.

Another problem I have is with the random generation not mixing well with the paths/connections. The paths should be evenly distributed so that there aren't nodes with too many connections and there also shouldn't be nodes with no connections. Right now I just have nodes being connected to whatever is closest.

Image

The FTL sector map is how I envision the final result for this project just to give an idea as to what the map is for. Thanks in advance for any help that someone is willing to give.
B
16
S
4
G
4
Posts: 59
Reputation: 3,091

Post » Wed Jun 21, 2017 9:54 am

One approach, since you are drawing/showing the connections anyway, is to store the end point nodes of a connection in two variables in the connection object (A and B in the example I added). When you arrive at a new node (via FTL jump, portal or whatever) you store all the connection where your current location is one of the end points in an array (A = node or B = node). Then all you need to do is cycle through the array's indexes based on input.

Capx example using arrows, the random generation is a bit crude (in the way that the paths cross unlike in FTL). But you are more interested in how to store connection information and how to cycle the chosen paths from what I understand.

https://www.dropbox.com/s/be1lanyiv7fe6 ... .capx?dl=1
B
15
S
6
Posts: 85
Reputation: 1,195

Post » Wed Jun 21, 2017 6:40 pm

Pulstar wrote:One approach, since you are drawing/showing the connections anyway, is to store the end point nodes of a connection in two variables in the connection object (A and B in the example I added). When you arrive at a new node (via FTL jump, portal or whatever) you store all the connection where your current location is one of the end points in an array (A = node or B = node). Then all you need to do is cycle through the array's indexes based on input.

Capx example using arrows, the random generation is a bit crude (in the way that the paths cross unlike in FTL). But you are more interested in how to store connection information and how to cycle the chosen paths from what I understand.

https://www.dropbox.com/s/be1lanyiv7fe6 ... .capx?dl=1


Wow, thank you so much for helping me with this. The example is easy to understand and does exactly what I was looking for. I will try and improve upon the generation and upload a capx for anyone who might want to see the finished product. :)
B
16
S
4
G
4
Posts: 59
Reputation: 3,091

Post » Wed Jun 21, 2017 10:08 pm

Here's another implementation that matches the ftl generation best I can tell. The idea used is very similar idea to Pulstar's, it's just another way to go about it.

https://www.dropbox.com/s/yyqwtx8pwnw8t ... .capx?dl=1
B
92
S
32
G
107
Posts: 5,274
Reputation: 69,959


Return to How do I....?

Who is online

Users browsing this forum: Apollo14, ChoosyZerk and 57 guests