How do I get this sliding puzzle to detect, tiles in the wished position?

1 favourites
  • 11 posts
From the Asset Store
Each tile 64 by 64 pixels - Ultimate Tile Set for your awesome games
  • Hi!

    I stumbled upon a nut I cannot crack used far too long yesterday and really can't think of any more solution for this, I hope someone in here can help...

    Have been trying to make a Sliding Puzzle, following this tutorial.

    https://www.youtube.com/watch?v=uk2B1ja9mVc&ab_channel=GameDesignwithReilly

    Wanted to make some changes to it myself to match what I wanted to use, but the problem is this, when playing the game is completes when the numbers is in the right order 0 to 7 in this case.

    I want them to stand in line, and not with the space between them, all these pictures are being completed because the Frames are in the correct order.

    The code to check for completion are this:

  • Hi, you can achieve this in a more dynamic way, such as storing pieces position in an array and track that, or checking their positions in relation to others. However, you can always hard code it like this:

    Assign an instance variable called 'id' to the pieces (ranging from 1 to 8 in order) and check the X position of the last piece (with id 8).

  • Hi, you can achieve this in a more dynamic way, such as storing pieces position in an array and track that, or checking their positions in relation to others. However, you can always hard code it like this:

    Assign an instance variable called 'id' to the pieces (ranging from 1 to 8 in order) and check the X position of the last piece (with id 8).

    Thx! a lot Cesisco. Just implemented it into the game, and It works good.. Still needs some more testing on it. But thanks again

  • cesisco

    Maybe a stupid question, but have been playing some games now and some seems impossible to solve is there a way to minimize that risk or remove it totally ?😅

  • The tutorial randomizes the tiles by literally setting them to random values. To make the puzzle always solvable you’d want to start with the solved state and have it do say 100 random moves, but I guess that’s a different problem to solve.

  • The tutorial randomizes the tiles by literally setting them to random values. To make the puzzle always solvable you’d want to start with the solved state and have it do say 100 random moves, but I guess that’s a different problem to solve.

    Yeah okay, will try playing around with some ideas I have just been sketching down... But thanks for the answer.

  • Probably, you can store a bunch of 'initial' states that you consider possible to solve in an array, or you can procedurally generate the initial state before the game begins. This can be done by starting from the 'solved' state and then making a certain number of random possible moves until it's shuffled. The more moves you make, the more difficult the puzzle will be.

    EDIT:I guess R0J0hound already mentioned this faster than I did :)

  • Try Construct 3

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

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

    Just hitting my head towards a new wall, the puzzle game is on an other layer with, parallax and scale rate set to 0. So a UI follows the player but the problem is when I'm showing it in the game the mouse and all the controls are totally off... I now the thing with the mouse absolute and all that with different layers according to parallax, is there a fix?? :(

  • cesisco

    Just hitting my head towards a new wall, the puzzle game is on an other layer with, parallax and scale rate set to 0. So a UI follows the player but the problem is when I'm showing it in the game the mouse and all the controls are totally off... I now the thing with the mouse absolute and all that with different layers according to parallax, is there a fix?? :(

    Hi, without more information, it's hard to tell what's going on, but keep in mind that the Tile Movement behavior uses Grid offset X and Y settings, so take a look and check if it's related to that.

  • cesisco

    Again thanks for the help.

    Been a great help for me and for my project/game, really just couldn't see a way though it.

  • cesisco

    Again thanks for the help.

    Been a great help for me and for my project/game, really just couldn't see a way though it.

    No problem. Keep on going and keep in mind that the primary role of a dev is solving problems and searching the web for solutions. If you are building something without facing any problems, it may be because you are working on something that isn't worth building.

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