This forum is read only and just serves as an archive. If you have any questions, please post them on github.com/phoboslab/impact

Hi, I'm doing a puzzle game and I managed to make the movement of all parts, perform various validations that were required and the only thing I can think of is how to determine how to make all the pieces were placed in position and has figure properly armed.

I really would be helpful if you could give me ideas on how to do this.

thanks
This is the way I would approach it:

I would build the puzzle on a grid, and have some sort of snap-to-grid code in place for when a player dropped a puzzle piece. Since a grid can be represented as either a 1d or 2d array, I would compare the playing grid to a solution array.

For example, if you had a 3x3 puzzle:

```-------------
| 0 | 1 | 2 |
-------------
| 3 | 4 | 5 |
-------------
| 6 | 7 | 8 |
-------------
```

a solution array might look like [0,1,2,3,4,5,6,7,8]. Assign ids to each puzzle piece (in this case 0 through 8), and every time a puzzle piece is dropped, update another array with the positions of the puzzle pieces. Once the 2 arrays are equal, the puzzle has been solved.
Thats a great idea i try to do that, but the thing is that each piece had a diferent size and dont match with a regular array, its a little dificult to do this, dont you have any other idea ?
Thats a great idea i try to do that, but the thing is that each piece had a diferent size and dont match with a regular array, its a little dificult to do this, dont yo have any other idea?
Without knowing more details we can't really suggest anything. Is there only one solution to any given puzzle?
Page 1 of 1
« first « previous next › last »