In this step, you will create a puzzle where a handwheel needs to be turned.
The scripts for this puzzle are quite similar to the button puzzle, so you can copy those scripts over and then edit them.
Drag the two scripts you created for the button sprite on to the handwheel sprite, to copy them to that sprite.
The when flag clicked
script is the first one that needs to be changed.
Create a new variable called handwheel turned
, and use that variable instead of the button pressed
variable.
Choose: Change the completion number to whatever you would like it to be. We chose 3
in the example.
Like a real handwheel, the handwheel sprite will only be able to turn a small number of degrees at a time, so the angle it has been turned will need to be stored.
Create a new variable called turned
and set it to 0
when the game starts.
Now you can edit the when this sprite clicked
script, so that when the handwheel sprite is clicked repeatedly it turns a small amount each time until it completes a full revolution. When it has completed the right number of full turns (3
times in the example), the puzzle will be solved.
Add blocks so that each time the handwheel sprite is clicked, it turns
degrees and the 15
variable increases by turned
15
.
Test: Move the Monet sprite (or your character sprite) close to the handwheel and then click on the handwheel sprite. It helps to be in fullscreen mode, so that you can’t drag the handwheel sprite around.
When the
variable reaches turned
360
, then the handwheel has been turned once; this can now be stored in the handwheel turned
variable.
Use a nested if
to change the handwheel turned
and reset the
variables. A nested turned
is when one if
is placed inside another.if
Test: Move your character sprite close to the handwheel, and then click on it. You might have to adjust the distance that the character needs to be from the handwheel.
Tip: You can click and drag your Monet (or character) sprite around, to bring it closer to the handwheel, for instance. This will save you time, as you won’t keep on having to use the controls.