Grid/Board Movement problem

Get help using Construct 2

Post » Tue Oct 10, 2017 10:08 pm

Hi guys. I'm having a problem with some seemingly basic grid problem. I have built a capx before enabling the pink square to be move from square to square with ease using a single instance variable for my indicator sprite but right now I'm faced with a different challenge.

My capx: https://www.dropbox.com/s/p04xd82wc1n3m ... .capx?dl=0

Image
First of all, I want the black squares in the image above to be totally different sprites thus my existing capx won't be applicable in this situation. In the image, only the green squares are selectable.
So the movement I want would be say I'm at A2, pressing right = A3
B2 pressing RIGHT = B4
A2 pressing DOWN = B2
A3 pressing DOWN = B4
B4 / B2 pressing DOWN = C1
E5 pressing UP = D1
B4 pressing UP = A3

And so on. How would I go about this? This seems like it should be simple but somehow I'm at a plateau :D
"The intent is to provide subscribers with a sense of pride and accomplishment for unlocking different features...."
B
42
S
18
G
32
Posts: 832
Reputation: 20,807

Post » Tue Oct 10, 2017 11:41 pm

Just a though - maybe you could do this without the array, using Pick Nearest event.

If Right key pressed:

First try to Pick Nearest green sprite, which is on the same row (sprite.y=current.y), and which is to the right from the current (sprite.x>current.x)

Else (If none picked):
Pick Nearest green sprite, which is to the right from the current (sprite.x>current.x). Nearest from any other row will be picked.


EDIT: When using "Pick nearest" with other conditions, "Pick nearest" needs to be the last in the list:
Image
Image

Did I help to fix a problem in your game? You can buy me a cup of coffee :) If you'd like to hire me, please see this post
B
19
S
9
G
158
Posts: 2,393
Reputation: 84,413

Post » Wed Oct 11, 2017 6:18 pm

dop2000 wrote:Just a though - maybe you could do this without the array, using Pick Nearest event.

If Right key pressed:

First try to Pick Nearest green sprite, which is on the same row (sprite.y=current.y), and which is to the right from the current (sprite.x>current.x)

Else (If none picked):
Pick Nearest green sprite, which is to the right from the current (sprite.x>current.x). Nearest from any other row will be picked.


EDIT: When using "Pick nearest" with other conditions, "Pick nearest" needs to be the last in the list:
Image


Trying a different solution right now. I'd love to see your solution in a capx though ;)
"The intent is to provide subscribers with a sense of pride and accomplishment for unlocking different features...."
B
42
S
18
G
32
Posts: 832
Reputation: 20,807

Post » Wed Oct 11, 2017 10:14 pm

Hi @MPPlantOfficial

Grate explanation, however, There are some possibilities that are still missing :D is important for the logic that's why I'm asking to take it into account example:

C3 pressing UP = Wich one will you chose, what are you preference Righ or Left, I see that when you going down you preference is Right like on the example you added (A3 pressing DOWN = B4)

Another Thing: is there any possibilities that in any horizontal line from A, B, C etc... you will find all squares black? because other ways will have to jump to the next Horizontal line that has at list one green square
B
54
S
33
G
95
Posts: 435
Reputation: 53,546

Post » Thu Oct 12, 2017 3:09 am

MPPlantOfficial wrote:Trying a different solution right now. I'd love to see your solution in a capx though ;)



Here you go:
https://www.dropbox.com/s/q0na54oyhiq8r ... .capx?dl=0

I think it works pretty well.

EDIT:
Except for this situation:
Image

It's impossible to select the two blocks in the middle.
I think you should have the same problem if you are doing it the way you described in the first comment.

You need to add diagonal movement - check if DOWN+RIGHT pressed simultaneously, as this would be the first thing players will try to do to reach those blocks in the middle.
Image

Did I help to fix a problem in your game? You can buy me a cup of coffee :) If you'd like to hire me, please see this post
B
19
S
9
G
158
Posts: 2,393
Reputation: 84,413

Post » Thu Oct 12, 2017 8:18 am

dop2000 wrote:Here you go:
https://www.dropbox.com/s/q0na54oyhiq8r ... .capx?dl=0
I think it works pretty well.

Cool. Thanks. By the way another solution I made was simply to assign 2 instavars on each block.

The instance vars are:

DISABLE = 0/1
FALLBACK = varies.

If indicator overlaps with a block that's DISABLE = 1, it would get reassigned to block.FALLBACK
However with this example the fallback block is 1-way so it might be ideal to create 4 fallbacks for each direction just like in your example. Thanks again.
"The intent is to provide subscribers with a sense of pride and accomplishment for unlocking different features...."
B
42
S
18
G
32
Posts: 832
Reputation: 20,807

Post » Thu Oct 12, 2017 8:25 am

If indicator overlaps with a block that's DISABLE = 1, it would get reassigned to block.FALLBACK


What if that block is also disabled?
Image

Did I help to fix a problem in your game? You can buy me a cup of coffee :) If you'd like to hire me, please see this post
B
19
S
9
G
158
Posts: 2,393
Reputation: 84,413

Post » Thu Oct 12, 2017 9:17 am

dop2000 wrote:
If indicator overlaps with a block that's DISABLE = 1, it would get reassigned to block.FALLBACK


What if that block is also disabled?

Manual instavar assignment per block. All Fallback blocks are activated. Or at least they should be. I haven't worked on the CAPX yet
"The intent is to provide subscribers with a sense of pride and accomplishment for unlocking different features...."
B
42
S
18
G
32
Posts: 832
Reputation: 20,807

Post » Thu Oct 12, 2017 9:22 am

Oh, so you manually set up the grid in editor and it's not changed during the gameplay?
I thought your grid is randomly generated.
Image

Did I help to fix a problem in your game? You can buy me a cup of coffee :) If you'd like to hire me, please see this post
B
19
S
9
G
158
Posts: 2,393
Reputation: 84,413

Post » Thu Oct 12, 2017 9:24 am

Well since it was ready since yesterday and I was just waiting before posting for that missing info just in case I had to modify it

I will post it anyway for some else if need it

https://www.dropbox.com/s/jkfvcw2pie7goo9/GridTileSelect.capx?dl=0
B
54
S
33
G
95
Posts: 435
Reputation: 53,546


Return to How do I....?

Who is online

Users browsing this forum: No registered users and 1 guest