# How do I make a graph game

Get help using Construct 2

### » Sun Sep 14, 2014 4:35 pm

I want to make a game that uses a graph underneath, but not sure what is the best way to do it. Each cell should be able to examine the type of the neighbouring cells, but the neighbours aren't necessarily visually touching each other, they're logically connected

any suggestions on what is the best way to do it? (I'm an experienced programmer, but haven't used Construct 2 before)
B
14
S
2
Posts: 26
Reputation: 933

### » Sun Sep 14, 2014 4:43 pm

I guess you're looking for the array object, with it you could loop through all cells..
I told my dentist I had trouble with my teeth and asked her to fix it without looking in my mouth..
B
54
S
16
G
8
Posts: 6,160
Reputation: 19,775

### » Sun Sep 14, 2014 5:57 pm

problem with the array is that each cell has 4 or 8 neighbours and it forces a certain topology
B
14
S
2
Posts: 26
Reputation: 933

### » Sun Sep 14, 2014 6:01 pm

If you use the z direction as well, it has even more..

Maybe you could explain better what you are trying to do, for I'm sure a solution can be thought of..
I told my dentist I had trouble with my teeth and asked her to fix it without looking in my mouth..
B
54
S
16
G
8
Posts: 6,160
Reputation: 19,775

### » Sun Sep 14, 2014 7:02 pm

It's a turn-based chase game, where nodes can have say up to N links connecting them to other nodes and there are N-1 enemies chasing a player that moves over the links on the graph nodes. The nodes+links (graph) is the underlying data structure, the display can be some drawing where the links aren't necessarily direct lines (can show up like say paths in some forest from a top view)
B
14
S
2
Posts: 26
Reputation: 933

### » Sun Sep 14, 2014 7:13 pm

I guess I could use an array anyway, of (K,1,N) dimension - I could store a number 0-(K-1) in each cell to mark a one way link. For two way links would store two times, as two one-way links
B
14
S
2
Posts: 26
Reputation: 933

### » Sun Sep 14, 2014 7:15 pm

And in the (i,0,0) position I'd store some info on where the node is on the UI or some reference to a graphics object (are there such?). If I can only keep numbers in the array then I'd need (K,2,N) dimension so that at (I,0,0) I store X and at (I,1,0) I store Y coordinate of the node on the display
B
14
S
2
Posts: 26
Reputation: 933

### » Sun Sep 14, 2014 7:22 pm

you can keep complete strings in the array if needed and use TokenAt to get information from that string..
I told my dentist I had trouble with my teeth and asked her to fix it without looking in my mouth..
B
54
S
16
G
8
Posts: 6,160
Reputation: 19,775

### » Sun Sep 14, 2014 7:25 pm

Another thing is that I need to be able to go the other way too, from clicking something on the display to finding the correct cell in the datamodel (the array). Can I keep some Tag value on visual objects or use their Name or something to point back to the cell's number? (I mean x in (x,*,*))
B
14
S
2
Posts: 26
Reputation: 933

### » Sun Sep 14, 2014 7:27 pm

I guess using an instance variable would be the easiest way for that..
I told my dentist I had trouble with my teeth and asked her to fix it without looking in my mouth..
B
54
S
16
G
8
Posts: 6,160
Reputation: 19,775

Next