Skip to content

Please update your browser

Your browser version is not supported by this site. CS First may not work properly. Learn more

5. Answer the Question

Transcript

In this video, check *if* player 2’s answer is the same as the right answer.

In the monkey sprite, click control and drag out an “if/else” block.

The condition needs to check *if* the "right answer" is the same as, or equal to, player 2’s response.

From the operators menu, drag an "equals" operator into the if statement.

Then, add an answer variable from sensing and the "right answer" variable from data.

If you’re having trouble finding the variables, the categories are color coded.

So, you can find an orange variable block in the orange data category.

Finally, add a "say" block to each part of the if statement to tell whether the answer is right or wrong, and attach the if statement under the final "ask" block.

Try it all out now!

You might also add a "say for 2 seconds" block after storing player 1’s answer that instructs player 2 to click the sprite when ready to guess.

You may also want to hide the variable displays so the right answer isn’t shown to player 2.

To do this, click the data menu and uncheck the "right answer" variable.

Then, click the sensing menu, and uncheck the answer variable.

Ask your neighbor to try it and play a quick game with you!

See if you can guess each other’s drawings.

Once you’ve finished this step, be sure to name, share and write instructions to your game.

Now it’s your turn: If the right answer equals player 2's answer, then tell player 2 the answer is correct, else tell them the answer is wrong and to try again.

arrow_backward Back
Next arrow_forward
Instructions
  1. Program a winning condition if player 2 answers the drawing correctly.