Creating Custom Path in a Grid Using an Array

Get help using Construct 2

Post » Wed Sep 20, 2017 6:44 pm

Helloooo.

I'm working on an interface where the player clicks/taps on a cell in a grid and that cell is labeled with a value of 1 through 5. First click/tap, 1; second click/tap, 2; etc. At any time, the player can deselect any of the highlighted cells. Thus, if 1 through 3 is selected and the player deselects the 2 cell, the 3 cell becomes the new 2.

The purpose of this is because my character will follow the customized path devised by the player - the order of the selected cells will determine that path.

I initially figured using an array and pushing the UID of that selected cell node onto the back of the array. No problem there. Adding the UID values into the array is good.

The problem is IDENTIFYING the correct index in the array that has the UID value of the cell node when DESELECTING it (and thus deleting that array element).

So far, I can't QUITE think of a succinct method to DESELECT cells and thereby update that order of selected cells.

Any suggestions? THANKS!
I'm seeking Narnia. Who wants to come with me! Aslan is on the move!
B
146
S
25
G
8
Posts: 798
Reputation: 15,438

Post » Wed Sep 20, 2017 7:02 pm

Hey @Rhindon!

When a player deselects a cell, run a Repeat x times loop, in which x is the array.Width. Inside the loop, check the value stored in the array and compare it to the uid of the deselected cell, if it matches, delete the index. The array will fix indexes by itself.

Hope this helps. Cheers!
Bruno

I like to eat, but I'm no cook. Why liking to play games would make you a game designer?
B
22
S
6
G
3
Posts: 717
Reputation: 3,996

Post » Wed Sep 20, 2017 10:21 pm

DUUUUUUUUDE!!!! So obvious, @brunoplaermo! But leave it to me to miss it. LOL I will get to work on that and see if it meets my needs...but I'm pretty sure it will. Thank you so much!
I'm seeking Narnia. Who wants to come with me! Aslan is on the move!
B
146
S
25
G
8
Posts: 798
Reputation: 15,438

Post » Thu Sep 21, 2017 12:11 am

[Please pardon my exuberant emotional outburst of joy. ... Given my struggles at game design and learning C2, I feel I've earned it. LOL] IT WOOOOORKED!!!!! Absolutely PERFECTLY!!! Exactly as I planning. Thank you again!
I'm seeking Narnia. Who wants to come with me! Aslan is on the move!
B
146
S
25
G
8
Posts: 798
Reputation: 15,438


Return to How do I....?

Who is online

Users browsing this forum: Yahoo [Bot] and 26 guests