How do I connect two blocks using no more than 3 lines?

0 favourites
  • 7 posts
From the Asset Store
Merge Blocks - Full Game
$19.60 USD
60% off
Place blocks on a board, join them together to form even bigger blocks!
  • Hi guys,

    Working on a prototype for a onet game.

    I need to connect two blocks using no more than 3 lines.

    Here is what I am trying to do

    The lines can connect two blocks together or separated when it takes 3 lines to connect them. It can't connect blocks where there is another block "blocking" it or diagonally.

    thanks,

    To all the ninjas out there rexrainbow, alextro and R0J0hound

    Tagged:

  • First came to mind is 'path finding' method. It's about makes auto route from A to B with regards to possible path. Another keyword would be A-star and flood fill.

  • I have tried every single tutorial I could find.

    The closest one is this one construct.net/en/tutorials/pathfinding-route-1368

  • You are in track then. Just add some layer of logic with it. For instance make unrelated blocks (other blocks) as an obstacle.

    Here my example for path routing:

    fisholith

    Great references you got there. Interactive demo from Pathfinding.js sure teach a lot with various algorithms.

    And cool video demonstrates alternative method to achieve it.

    I am about to implement the case for existing flood-fill range demo: https://dl.orangedox.com/UkkZMMQmTfgSKdbeYx

    Actually that would be first part of tutorial (perhaps in future).

  • Cool concept. I found a simple flood fill explanation that I could use for this problem. The only missing part is to know when 3 lines were formed and stop the program.

    I think I can accomplish that by counting the turns. if it is more than 3 , destroy the lines. what do you think?

    youtube.com/watch

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • I had never seen that game before, so I played an on-line version... it was quite fun! :)

    you will probably need to keep the board pieces in an array, for checking if a move is valid, if there are any moves possible, and reshuffling the board when necessary.

    Since after every player move you need to make sure there is at least one move possible, the only way to do that quick enough is looping through an array - definitely some tricky programming needed there! I would love to take a crack at it, but don't have time right now...

  • Record turn direction for each block path by comparing their angle. Each time the path turning different way add 1 to a variable that acts as turning counter. So if the counter reach 3, cancel the route.

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