Project 533: Obstacle Course

4. Check distance to stones

We are going to help our character cross the river by clicking on whichever stone they should jump to next. When each stone is clicked on it will check if your character is close enough to that stone to jump to it and broadcast either a yes or no back to your character.
Starting point file for this challenge

Your goal

Steps

1. Add a "when this sprite clicked" block

Go into your Stone 1 sprite and add a "when this sprite clicked" block from the "Events" tab.

2. Add a "if ___ then ___ else ___" block

We want to be able to give our sprite different code for each outcome, so we are going to add an "if ___ then ___ else ___" block from the "Control" tab.

3. Check if it is less than 200 pixels away

Go to the green "Operators" tab and get a less than block "___ < ___". Change the second number to 200.

4. Get the distance to the Adventurer

To get the distance from the Stone sprite to the Adventurer sprite, go to the light blue "Sensing" tab and find the "distance to ___" block. Click on 'mouse-pointer' and select 'Adventurer' from the list. This block goes in the first space of your less than block.

5. Show variables to learn the distance

Go into the orange "Variables" tab and check the boxes next to all of the "Distance" variables. Now you will be able to see what the actual distance is between each stone and our character sprite.