If the user answers “yes” to the firstquestion, then they will go to one world. If he or she answers anything else, like “no”,“maybe,” “probably”, “I’m not sure.” “Hopefully so,” “yah”, “yep,“mos def,” – literally any other word – then they will go somewhere else.
To check if the answer is yes, use the equals operator found in the operators menu.
Drag the answer variable into the first blank, and type “yes” into the other.
You just programmed a condition! Now, you need to tell the computer what to do if “answer”equals yes, then what to do if answer equals anything else.
Click control, and drag out an “if/else” block. Attach it below the “ask” block.
Drag the condition into the top of the if/else block.
If the answer equals “yes,” then the backdrop should change.
Click the looks menu, drag a “switch backdrop to” block into the “if/else” statement,and change the value to the name of the appropriate backdrop. This example uses “woods,” butyou will choose the first backdrop you previously selected for your story.
Test it now. Click the block stack, and enter “yes.” The backdrop should switch to thebackdrop you selected. Great! “If” the user answers something otherthan “yes,” the stage should change to a different backdrop.
Drag another “change backdrop” block into the “else” portion of the if/else statement,and change the value to your second backdrop. Click the block stack to test this again,and enter “no.”
Great, it works. But, there’s one problem.
The backdrop never changes to the brick wallfor the start of the story. To reset the backdrop to the brick wall atthe start of the story, drag the “switch backdrop to brick wall” block to the topof the block stack. Finally, add a “when flag clicked” eventto start this code. Click the green flag to test this again, andtest some different answers to the main character’s question to find out how itwill react.
In the next video, you’ll program different stories for each backdrop.