How to make a puzzle game?
100062114
Member Posts: 13
I try to code a game which is like a puzzle.
The computer generate a puzzle, for example, a L-type.
The user can drag the puzzle to a grid plane, the puzzle can be automatically put in the grid plane exactly.
How do I make gamesalad do these things?
Comments
Okay so firstly you want to make your L shape object (I will just call it actor 1) to be able to be clicked and dragged. Here's what I would do:
Double click on actor 1 and create a new rule:
When all conditions are valid:
Constrain attribute:
Constrain attribute:
Now you should be able to drag and drop actor 1 around, while in preview mode.
For the 'snapping into place' feature it's a little more complicated. First you will need your 'grid' (I will just call it actor 2) so create that. You will also need to create to attributes, so in your inspector, go to Game ->Attributes -> and click the '+' symbol at the bottom. Create a new integer called something like 'X-position' and another called 'Y-position'. Now we need to set them to whatever position actor 2 is at (double click on actor 2 in the camera window and click the little symbol next to 'Position' to find this). If you are planning on moving actor 2 around, I would suggest constraining these attributes to the position of actor 2. To do this, double click on actor 2 in the inspector and add two attributes:
Constrain attribute:
Constrain attribute:
Okay now we need to create a new rule in Actor 1, in order to snap it into place. Obviously you can replace the number 20 with any number you like, depending on how close or far you need to be before it will snap into place:
When all conditions are valid:
Change Attribute:
Change Attribute:
Of course this is just assuming you only want to snap it to one place, as opposed to anywhere in the grid. But hopefully this will give you a good starting point. Let me know if you have any trouble.