2. Basic operation manual

4. Basic coding in UI.Flow (Part B)

57 views 2019-06-04 2019-06-04 peterletintech 1

Step 11. Replace the “3” block by dragging “random integer from to” block to the onto the “3” block.

Step 12. Drag the “0” block to set the random generation range.

Step 13. Set the random range to between 1 and 9.

Step 14. Test the code.

Button A is pressed once. The input1 result is increased by 7.

Button A is pressed twice. The input1 result is increased by 9.

Button A is pressed the third time. The input1 result is increased by 4

Step 15. Add a logic block. Drag “if do else” block under Logic inside “Button A pressed” block.

Step 16. Drag the operation blocks to the “do” area.

Step 17. Set up the condition for the “if do else” block. Drag the “ = ” block to the “if” area.

Step 18. Change the condition to input1 is less than or equal to 50.

Step 19. “else” block will run when the condition is not satisfied and the game will be over. Change the vaule of “result” label to “GAME OVER” and the colour to red.

Step 20. Test the final code.

Start

Button A is pressed once. The input1 result is increased by 7.

Button A is pressed once. The input1 result is increased by 9. After several presses.

The input1 result is 46.

Button A is pressed. The input1 result is increased by 8 and excceds 50. The condition will not be satisfied the next time.

Since the condition is not satisfied, the game is over.

Was this helpful?