Skip to content
Transcript

In this video, you will use the if else block to program a decision based on the answer variable.

If the user answers to the first question, then they will go to one world.

If he or she answers like no, maybe, probably, I'm not sure, hopefully so, ya, yep, most 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 then type yes into the other.

You just programed a 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.

Change the value to the name of the appropriate backdrop.

You will choose the first backdrop you previously selected for your story.

Test it now.

Click the blockstack and enter yes.

The backdrop should switch to the backdrop you selected.

Great!

If the user answers something other than 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 blockstack to test this again, and enter no.

Great, it works!

But, there's one problem.

The backdrop never changes to the brick wall for the start of the story.

To reset the backdrop to the brick wall at the start of the story, drag the switch backdrop to brick wall block, to the top of the blockstack.

Finally, add a when flag clicked even to start this code.

Click the green flag to test this again, and test some different answers to the main character's question to find out how it will react.

In the next video, you'll program different stories for each backdrop.

Instructions

  1. Create the condition the program will base its decision on.
  2. Go to one backdrop if the user answers "yes."
  3. Go to a different backdrop if user doesn't answer "yes."
  4. Program the story to always start with the brick wall backdrop.