Page 112 - Touchpad_Plus_V3.2_Class 5
P. 112
Becomes true when color1 touches
color2
Becomes true when a defined key
is pressed on the keyboard
Asks a question from the user and
waits for the answer
Stores the answer or input given by
the user
Let us develop a simple program where the cat sprite
moves towards a basketball when right arrow key is
pressed. The code for the cat sprite can be similar to
this.
STORING USER INPUT
The program can also be developed to take input from the
user. Earlier, we developed a program to divide 12 by 5.
Scratch gives an option to take input from the user also.
To develop a program to divide two numbers and find
the quotient, define the script of the sprite similar to the
one given alongside.
When the program is run, a small text input box opens at
the bottom of the stage. Type the value of the variable and
press Enter key or click on the tick mark symbol on the
Script to divide two numbers
right side of the text box.
User input Output
The final output of the program will be similar to the above image.
110 Plus (Ver. 3.2)-V

