Use the 'turn' block
Now that we have defined the instructions for our custom 'turn' block, we need to use the block somewhere in our code. We're going to add it to the 'if then else' block that detects if the beetle touches the maze.
Before we turn, we'll need to program the beetle to move backwards a small bit first and then turn, otherwise it will be constantly touching the wall.
To make the beetle move backwards, we will make it move:
steps x -2
If steps is set to 5 then the sum is:
5 x -2 = -10
Add the following code so that it runs if the beetle touches the maze:
when [space v] key pressed
if < touching [maze v] >then // add code into here
move ((steps) * (-2)) steps
move (steps) steps
Once you've added this code, click the green flag and press the space bar again. If your beetle touches a wall, it should now move back a bit and then randomly turn before moving forward again. You've now programmed the beetle to work it's way through the maze!