Step 6: Choosing a Random Mole

Goal:


Now that we have a random hole chosen, we need to decide which mole to send through the hole

We have a bonus mole that is a lot quicker, but is worth a lot more points if hit. We want this mole to appear, but not all the time

To do this we pick a number between 1 and 10, and we only spawn this bonus mole if the number 5 is chosen.

This means that we have a 10% chance for the bonus mole to appear!

Steps:

  1. From Variables place a set to block underneath the block of code from the last step
  2. Inside the set to block on the left side, set the variable to be “moleChooser”
  3. From Operators, place a pick random block inside the set to block on the right side
  4. In the pick random block, set the left side to and the right side to 10
  5. From Control, place an if then…else block
  6. From Operators, place an “=” block inside the if then block
  7. From Variables place round “moleChooser” block on the left side of the “=” block
  8. Type in a 5 on the right side of the “=” block
  9. From Events place a broadcast block under the if then section of the if then…else block
  10. On the broadcast block, set the message to be “SendBonusMole”
  11. From Events place a broadcast block under the else section of the if then….else block
  12. On the broadcast block, set the message to be “SendNormalMole”

Code: