Program block introduction
6 block types:
1、Boot block:It is to start each script, they have a rounded top and a raised bottom, you can only place blocks under them.
2、Execution block:Is the module that executes the commands, they have a notch at the top and a bump at the bottom that can be placed above and below them.
3、Type C block:These blocks are also referred to as "packets" that can be looped through their internal programs or check if the condition is true.
4、Logic block:Is a conditional statement, they are not true or false, it is like asking your friend: "2+2=4?" They will tell you "yes" or "no".
5、Report block:Values, they are rounded and the report block can hold numbers and strings. For example, ask a friend, "What is 2+2?" They will answer "4". It can not only answer the equation, it can also reply to a variable, such as "What is your age?" They may answer: "15."
6、Stop block:It's the block that ends the script, they have a grooved top and a flat bottom, so you can't place any blocks under them.
8 basic Scratch blocks
1、Motion
Features | Screenshots | Description |
---|---|---|
mobile | Let the character move a certain distance on the stage. The bigger the value, the farther it moves. | |
mobile | Move the character to the corresponding position | |
mobile | Let the character slide to the corresponding position within the specified time | |
mobile | Easily set motion trajectories by changing x and y coordinates | |
mobile | Move to the object location | |
mobile | When the character is in motion, it will bounce if it hits the edge of the stage, and the character movement is on the stage. | |
direction | Rotation angle | |
direction | Specify role orientation, combined with move instructions to move the character in the specified direction | |
direction | Set the role face toward the object |
2、Exterior
Features | Screenshots | Description |
---|---|---|
speak | Let the character speak, there is time limit to limit the length of time, no time to say | |
speak | Let the character think, if there is time limit, it will limit the duration, and if there is no time, think about it | |
Exterior | Let the character show or hide | |
modeling | Characters can have many shapes, and shape switching allows the character to make many different actions. | |
modeling | Combine loops and wait for use, let the characters move smoothly | |
Special effects | Add visual effects to the character | |
background | A program can have a lot of backgrounds, and the roles are in different scenes by switching backgrounds. |
3、Sound
Features | Screenshots | Description |
---|---|---|
Play/stop sound | Play/stop background sounds and character sound effects | |
Sound effect | Add sound effects | |
volume | Set the volume |
4、Event
Features | Screenshots | Description |
---|---|---|
occur | Start directly, click on the green flag to start the code below | |
occur | Start the following code when a specific button is pressed. The default is the space bar. You can also use the other buttons in the drop-down menu to control the program. | |
occur | Click on the character in the stage and the following program will run. | |
occur | When the stage background is switched to the background, the following procedure is executed. | |
broadcast | When the sound or timer is greater than the specified value, execute the following program | |
broadcast | When the program runs to the broadcast module, it will simultaneously execute a new program starting with "when received" | |
broadcast | When the program runs to broadcast and waits for the module, it will execute a new program starting with "when received". After the new program runs, it can execute the broadcast and wait for the program behind the module. |
5、Control
Features | Screenshots | Description |
---|---|---|
wait | Wait for the corresponding time to continue the following program, or continue the above program corresponding time | |
wait | The execution condition is in the diamond block. When the condition is met, the following program is executed, otherwise it waits | |
cycle | The execution condition is in the diamond block. When the condition is met, the following program is executed, otherwise the internal program is repeatedly executed. | |
cycle | Execute the internal program the corresponding number of times, then jump out and execute the following program | |
cycle | Repeated execution of internal procedures | |
judgment | In the diamond block, the internal program is executed when the condition is met, and then the following program is executed. If the condition is not satisfied, the following program is executed. | |
judgment | In the diamond block, the internal program is executed when the condition is satisfied, and the internal program is executed when the condition is not satisfied. | |
termination | Stop all: stop all programs; stop the current script: stop the current sequence; stop other scripts for the role: stop all programs except the current program column | |
clone | Clone the current role or other roles | |
clone | Delete all clones | |
clone | Control the clone to execute the following program |
6、Detection
Features | Screenshots | Description |
---|---|---|
ask | Can be used in conjunction with | |
condition | Events detected between programs | |
condition | Reflect the xy coordinates of a character | |
Timer | Timing function |
7、Operator
Features | Screenshots | Description |
---|---|---|
Operator | Implement addition, subtraction, multiplication and division | |
Comparison | Achieve comparative size | |
And or | Logic or module: When one of the diamond modules satisfies the condition, the program executes, and when it is not established, the program does not execute; | |
And or | Logic and module: The program is executed only when the conditions in the diamond module are met, otherwise it is not executed; | |
And or | Not a module: when the condition is not met, the program executes, otherwise it is not executed. | |
random number | Randomly take an integer in the specified range, including the number of ends | |
connection | Connect two quantities | |
Detection | Detects the value of a specified position character in a quantity | |
Detection | Detect the length value of a quantity | |
Judge | Determine if a quantity contains another quantity | |
evaluate | Find the remainder of the value division | |
evaluate | Round the decimal part of the value | |
evaluate | Taking the absolute value of the value, rounding down, rounding up, square root |
8、Variable
Features | Screenshots | Description |
---|---|---|
definition | Create variable | |
definition | Define the variable name and determine the creation variable | |
data | Variable assignment | |
data | Add one value to the variable | |
data | Call variable value | |
Show/hide | Show or hide variables on the Stage | |
definition | Create an array | |
definition | Define the array name and make sure to create an array | |
data | Add a quantity to the array | |
data | Delete the first item in the array | |
data | Insert a quantity into the specified position in the array | |
data | Replace the specified item in the array with an amount | |
data | Get the value of the specified item in the array | |
data | Determine the position of a quantity in the array | |
data | Get the length value of the array | |
data | Determine if the specified amount is included in the array | |
data | Show or hide an array on the Stage | |
data | Add or remove items from the array on the Stage |