Grid/Board Movement problem

  • 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

    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 <img src="{SMILIES_PATH}/icon_e_biggrin.gif" alt=":D" title="Very Happy">

  • 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:

  • 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:

    Trying a different solution right now. I'd love to see your solution in a capx though

  • Hi MPPlantOfficial

    Grate explanation, however, There are some possibilities that are still missing 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

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • Trying a different solution right now. I'd love to see your solution in a capx though <img src="{SMILIES_PATH}/icon_e_wink.gif" alt=";)" title="Wink">

    Here you go:

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

    I think it works pretty well.

    EDIT:

    Except for this situation:

    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.

  • 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.

  • [quote:24ci50dw]If indicator overlaps with a block that's DISABLE = 1, it would get reassigned to block.FALLBACK

    What if that block is also disabled?

  • [quote:3lk42j0s]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

  • 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.

  • 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

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)