Auto puzzle

Get help using Construct 2

Post » Tue Apr 23, 2013 5:11 pm

How do I make a sliding puzzle that the computer solves, or at least shuffles the pieces around, like here?
B
10
S
4
G
3
Posts: 210
Reputation: 5,273

Post » Tue Apr 23, 2013 6:58 pm

Off the top of my head, I'd use an array. Then find the "space" square within the array, and select a random square adjacent to the space. Move that selected square into the space. Then repeat. The more times you repeat, the more it'll be shuffled. After shuffling the array, you can then create and draw the squares relative to the array.

If you wanted to show the shuffling as it happens, you could do it without an array, and use overlapping at offset events to check if a tile is in adjacent squares.

Remember to store the positions of the solved puzzle before you shuffle. Then you can easily check if the player has solved it or not.
B
15
S
5
G
7
Posts: 877
Reputation: 5,650


Return to How do I....?

Who is online

Users browsing this forum: No registered users and 21 guests