How code blocks work in Scratch

Scratch is a free programming language and online community where people can create their own stories, games, and interactive animations. This is one of the most popular block-based coding tools, the most familiar programming language for children. Scratch has many different types of blocks and most blocks have special shapes on the top and bottom, this is so they can connect with each other. In this article, let’s find out all code blocks in Scratchfunctions and how blocks work.

Functions of code blocks in Scratch

Event Block

These yellow blocks have a special shape, convex at the top. These blocks are starting blocks, meaning they should be at the beginning of any code people create. Events are blocks that indicate when code will be run.

cac khoi trong Scratch 1

  • When clicking on the green flag: Run the code when the green flag is clicked (when the program starts).
  • When pressing the key: Run code when a key is pressed. Use the drop-down menu to select the key you want.
  • When clicking on this character: Run code when clicking Sprite.

Movement Block

These blue blocks allow the character to move, rotate, and glide.

cac khoi trong Scratch 2

  • Move 10 steps: This block allows the Sprite to be moved in the direction the character is facing, in an optional number of steps.
  • Rotate right/left 15 degrees: These blocks allow the Sprite to be rotated right or left, according to the desired number of degrees.
  • Go to location/Go to point x and y: This block allows the Sprite to “jump” to a location, a drop-down menu can be clicked to view different options.
  • Glide for 1 second to positions/points x and y: This block allows the character to glide smoothly across the screen to a location that people choose.
  • Set direction equal to 90/Facing towards object: These blocks allow adjusting the direction the character is facing.
People Also Read  Instructions for searching photos by text in Google Photos

Display Block

These purple blocks will change the character’s appearance.

cac khoi trong Scratch 3

  • Resize by amount/Set size to: These blocks change the size of the Sprite.
  • Change/set color effects: These blocks will change the color of the Sprite, use the drop-down menu to see other interesting effects.
  • Speak/Think: These blocks will create speech or thought bubbles for the character, with text in the code block.

Control Block

These orange blocks allow code to run and iterate continuously.

cac khoi trong Scratch 4

  • Continuous: The forever loop will continue to run code, as long as your program is running. Note that the forever loop has no notch at the bottom. This is because the loop will continue to run forever so nothing is added underneath.
  • Repeat: Repeat loop allows users to specify the number of times they want to run the code.

Sound Block

This section allows users to add sounds to their programs. Each Sprite has a different sound, but people can also add their own sounds from the Sounds tab. For example, ask your dog to bark or record some sounds for him to talk.

cac khoi trong Scratch 5

  • Start audio: This block will start playing sound. Any code blocks in this block will run while audio is playing.
  • Play the sound until the end: Will play sound until the end. Any code blocks in this block will run after the sound ends
Update at 15:22 - 16/07/2024
Vote
Avatar photo

Gameunition is an experienced gamer with a passion for exploring the gaming world. With years of gaming under their belt, they have honed their skills and become a master at hunting down game codes to claim rewards. Gameunition is not just a skilled player but also an outstanding code hunter, always willing to share their rewards and game knowledge with the gaming community. This has made them a respected figure in the gaming community, inspiring others with their dedication and expertise.

MORE CONTENT

Comment