Getting familiar with Scratch Interface
There are four basic elements for programming in mBlock:
Stage is a background or a “back-drop” for a project. In the figure, it is represented by the white background. You can paint, import, or take a photo from the camera and set it as your background. The Stage is where the sprites move, draw, and interact. The Stage has its own set of scripts, images, and sounds.
Sprites are the objects that perform actions in a project. They may be characters, objects, or items to be manipulated.
A costume is one of the many possible appearances of a sprite. Sprites may change their look to any of the available costumes. The panda the in the figure above is a sprite. Sprites understand and obey the sets of instructions that you give them. Projects often require more than one sprite, ad each of these sprites has a separate set of instructions exclusively for it.
Blocks are puzzle-shaped objects that are used to write codes (set of instructions) in Scratch. The blocks fit together like the pieces of a jigsaw puzzle where each data type (event, command, reported value, reported Boolean, or script end) has its own shape, and a specially shaped slot for it to be inserted into. This eliminates the typing errors that tend to occur when people use text-based programming languages.
The block palette is the area located between the stage and sprite pane and scripting area, as shown in the figure above. It consists of all the different colour-coded categories, also known as Palettes of blocks, given below:
Different blocks with different functions are located under the specific block palettes. If they go beyond the limit of the page vertically, a scroll bar is generally present that allows to scroll the list of blocks.
A script is a set of instructions for manipulating the attributes of the sprite and the stage. A script consists of a set of blocks that fit together like a jigsaw. For writing the script you must go to the specific Block Palette and drag and drop the block(s) in the Scripting Area. When you run a script, it executes every block sequentially from top to bottom. For a sprite, you can make multiple scripts which can run at the same time simultaneously. A script is used for controlling the actions of one or more sprites.
The following scripts are for controlling the movement of the sprite (a parrot in this case) in the stage. Script A is for switching between the two costumes so that the parrot appears to be flying; script B is for controlling the path of its movement. As per the script, whenever the parrot touches the right edge of the stage it goes back to the point -200,0 in the stage.