Scratch is a programming language and an online community developed by the Lifelong Kindergarten Group at the Massachusetts Institute of Technology (MIT). It is designed to be used by people of all ages to create interactive stories, games, and animations.
To start programming with Scratch, you can follow these steps:
By following these steps, you can start programming with Scratch and create your own interactive stories, games, and animations.
Programming is done by moving instructions from the block category section to the script area.
The block category section contains programmable instructions grouped by color in order to be more mnemonic.
Blocks are lines or blocks of code that you drag into your project to create a script. Each resource can be associated with multiple scripts, and each script can have as many blocks as needed. As you gain experience with Scratch and start creating more complex projects, you’ll find that your scripts can get quite long and complex, so it’s important to find the most efficient way to create scripts. and the most efficient blocks possible. It’s a good skill to learn if you’re using Scratch as a starting point for teaching yourself or others how to code, because it’s important to write clean and efficient code. Later in this series, I’ll cover each block category in more detail and demonstrate their use through projects, but in this article, I’ll give you a quick overview of the different types of blocks and what you can do with them.
To use a block, simply select the asset it applies to, then drag it onto your scripts area.
To remove a block from a script, simply drag it to the left, away from the scripts pane. Note that you can only do this for the bottom block in a script or a block that is alone: if you drag a block out of the scripts pane that has other blocks attached below it, all blocks below will be also removed. If you want to do this, select the block immediately below the one you want to remove and drag it out of the script. Next, drag the block you want to remove (i.e. the bottom one) out of the scripts pane and drag the blocks you moved back into place.
Motion blocks are used to place your sprites on the stage or move them around. You can only use motion blocks with sprites, not with the scene.
Examples of Movement Blocks:
This instruction makes the sprite move
This instruction rotates the sprite 15 degrees
Appearance Blocks are purple in color and they control the appearance of your sprites and background, their size, and whether they are displayed in front or behind other elements. Appearance blocks also include blocks that allow you to display text.
Examples of Appearance Blocks:
This block makes the sprite visible on the Stage.
This block hides the stage sprite
Sound blocks are used to add sounds to the sprite.
Example of Sound blocks:
This block allows the sprite to produce a sound
Event Blocks are fundamental to Scratch because without them, nothing will happen. Each script will have an event when it starts that tells the script to run. This can be the green flag you click to start the project, or an event triggered while your project is running. Use all event blocks with the scene or your sprites: the names of some of them will change slightly depending on which one you are working with.
Event Examples
As soon as you click on the green flag with the mouse, the sprite (or sprite) follows the commands placed in the script area.
As soon as the space key is pressed on the keyboard, the following instruction will be executed. This event is independent of other objects.
Control blocks allow you to control blocks in your scripts, inserting conditional statements, loops, repeats and pauses.
Examples of control blocks:
This conditional block allows a set of blocks to execute if a condition is met.
This block allows instructions to be repeated indefinitely.
Sensor Blocks are used to identify what is happening at any given time and make your sprites or background react.
Examples of sensor blocks:
This Block detects key presses and mouse clicks.
This block is used to detect if items (including snarls and colors) touch each other or are within a given distance of each other. You can only use them with sprites, not with the scene.
Operator blocks allow you to make comparisons or perform arithmetic functions on different values and can be used in conjunction with data blocks or sense blocks, among others.
Examples of operator blocks:
This block is used to add two variables
This Boolean block used to combine values in control blocks like If and Repeat blocks
Variable type blocks allow you to create and manipulate variables in your animations and games. You can create two types of data: variables and lists. These can be used with sprites and with the scene.
Examples of variable blocks:
This Blocks is used to set the value of your variable
This block allows you to modify the value of your variable.
Use the dark purple « My Blocks » type blocks to create your own blocks. These are useful for making your code more efficient. If you have a set of blocks that you use repeatedly in your project, perhaps through sprites or scripts for echo sprite, you can define a single block that includes that set of blocks (or routine) and the use whenever you want to run the whole routine. It’s a bit like creating a function or a class in other programming languages.