[Plugin]Board, Layout2Board [Behavior] Grid Move

From the Asset Store
Snap to visible grid - perfect solution for any game genre
  • Yes, chess group will do the job.

  • Update:

    New plugin: rex_board_edge , to maintain edges on a board.

    User also need to update rex_board, rex_slg_movement plugin.

    xoros

    Done.

  • Grrreat, thank you!

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Update:

    rex_board plugin: add action: create chess above tile

    rex_board_edge plugin: add condition:On edge kicked

    I will add more actions/conditions to make the board system more easy to use.

  • rexrainbow, thanks so much for pointing me here! I still have to try to implement the board_edge plugin, but it looks very promising.

  • Hi again rexrainbow,

    I've been trying to implement the board_edge plugin, and so far, for a certain configuration, it works.

    However, when using squareTx's '8 direction' the edge only respects one direction. I've attached an image which demonstrates the behaviour: the player is behind a long wall, and if the target tile is behind the wall, it will try to move diagonally (because there is no edge between the diagonal tiles). If I use '4 direction' it works fine.

    I've tried switching squareTx.Direction based on slg_movement's PreTile and Tile conditions, but I can't get it to work and I'm not sure if this is correct approach.

    I'm still trying to play around with the switching, but you have any tricks/ideas to get around this, it would be much appreciated.

    Thanks again!

    best,

    lernie.

  • faulknermano

    You are right, it had miss something in my board system in squareTx layout.

    In squareTx's '8 direction' mode, the grid will become an octangle, although it looks like a tetragon. So that it will have 8 edges, you need put a "wall" for diagonal side, currently.

    I will try to solve it. Let me think....

    [Edit]

    You might try to turn the direction mode to 4 direction before requesting a path in slg_movement plugin.

  • Hi rexrainbow,

    Thanks for the suggestion. I've used 4 direction successfully, but I am currently trying to find a way to combine it: using 4 direction when it hits an edge, and 8 direction when no edge is involved.

    I'm trying to find a logic solution, but it would be nice to get your thoughts on it because you're obviously more familiar with the moving path algorithm.

    What I will attempt is this:

    -request a moving path from slg_movement

    -move chess accordingly

    -for every GridMove On tile, determine if current tile has an edge

    -if current tile has edge, switch to 4 direction

    -then get rid of moving path

    -request another moving path from current position to original destination

    (That's just the rough idea)

    (I will, of course, update if I get anything working)

    Thanks again!

  • faulknermano

    "using 4 direction when it hits an edge, and 8 direction when no edge is involved."

    • "Condition:Has edges around chess" and set parameter direction to (-1) to check if there is any edge around TileUID.
    • "Expression:NeigborUID2DIR" (new in board plugin, you need update board plugin) to get the direction from PreTileUID to TileUID.

    In 4 directions, the value is 0~3, in 8 directions, the value is 0~7.

    It might be -

    + NOT Edge :Has edges around chess : TileUID , dir to (-1) // no edge around TileUID

    • set cost to 1

    + ELSE

    + Board.NeigborUID2DIR( PreTileUID , TileUID ) >= 4 // diagonal

    • set cost to BLOCKING

    + ELSE

    + Edge :Has edge between chess ( PreTileUID , TileUID )

    • set cost to BLOCKING

    + ELSE

    • set cost to 1
  • Hi rexrainbow, I've updated the latest on GitHub, but the NeighborUID2DIR expression doesn't seem to be registered in the editor (need to update edittime.js, too?). Thanks!

  • faulknermano

    Yes, you need download these files. Or using this tool to update my plugins.

  • Thanks rexrainbow! Your download tool updated it, and now I can see the NeighborUID2DIR expression.

    However, just so you know your GitHub repository doesn't seem to be updated; I compared the new edittime.js with the one in my GitHub directory (which I'm always synching), and NeighborUID2DIR only appears in the tool-updated one, not in GitHub.

    Thanks again.

  • faulknermano

    I might forget submit the code, sorry.

  • rexrainbow, thanks for your help. I finally got it working! The first few times I tried to make it work, the function became messy. But during the debugging I started to understand how slg_movement's moving path function worked, and I came up with something more straightforward, and something that I could read and maintain later.

    Like you suggested, Board.NeighborUID2DIR was used to get 'check direction', used a 2-dim array to get the 'reverse direction', corner1 (left of direction), and corner2 (right of direction).

    Then I made 2 checks: first check is destination Tile; if an edge exists the 'reverse direction', or any of the reverse direction 'corners', it means tile is inaccessible: movement is blocked (cost = -1).

    Second check is PreTile: if edge exists in the 'check direction' of PreTile, or any of the check direction corners, then movement is blocked.

    Else, default variable cost value of 1 is used.

    Again, thanks for this suite of plugins you've made. Although at the beginning it was hard to use because I didn't quite understand how it worked 'under the hood', now that I have more experience with it, it is getting easier to tweak and get specific results, making it a powerful tool.

  • faulknermano

    Congratulations!

    Your request is too specific to implement in a simple way. It really need dig the board system more deeply, to get more information from board/edge.

    For tracing, you could dump PreTileUID and TileUID to console, under "on cost" event. Anyway, I am glad that you had came up this problem.

    "on cost" could be customized to do diffusing, see the demo in this post.

    Have fun!

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