2026年1月25日日曜日

What is block and how to use it in Scratch programming?

 📋

In Scratch, a block is a single command or instruction. Think of it as a physical puzzle piece that contains a specific "rule" for the computer to follow. Instead of typing code, you snap these pieces together to build a program.


1. The Anatomy of a Block

Blocks are designed with "notches" (indents) and "bumps" so that they only fit together if the logic makes sense.

There are six main shapes of blocks, each serving a different purpose:

ShapeNameWhat it doesExample
Rounded TopHat BlocksThey start every script. They "listen" for an event (like a click).When green flag clicked
Rectangle with NotchStack BlocksThe main "action" blocks. They perform a command.move (10) steps
Diamond/HexagonBoolean BlocksThey check if something is True or False.touching mouse-pointer?
Rounded EndsReporter BlocksThey hold values (numbers or words).score, x position
"C" ShapedC-BlocksThey wrap around other blocks to repeat them or check conditions.forever, if...then
Flat BottomCap BlocksThey stop a script or the whole project.stop all

2. How to Use Blocks

Using blocks is a simple three-step process:

  1. Find: Look through the Block Palette on the left. They are color-coded (e.g., Blue for Motion, Yellow for Events).

  2. Drag: Click and hold a block, then drag it into the Scripts Area (the big empty space in the middle).

  3. Snap: Bring one block close to the bottom of another. You’ll see a gray highlight appear; let go, and they will "click" together like magnets.


3. The Color Palette (Categories)

Scratch organizes blocks into colors so you can find them instantly:

  • 🔵 Motion: Moving and turning.

  • 🟣 Looks: Changing costumes, speech bubbles, and size.

  • 🌆 Sound: Playing music and sound effects.

  • 🟡 Events: The "triggers" that start the code.

  • 🟠 Control: Loops (forever) and logic (if/then).

  • 🧪 Sensing: Detecting touching, colors, or mouse position.

  • 🟢 Operators: Math ($+$, $-$, $\times$, $\div$) and comparing numbers ($>$, $<$, $=$).

  • 🧱 My Blocks: Where you can create your own custom blocks!


4. Pro Tip: Deleting and "Un-snapping"

  • To un-snap: Grab the block below the one you want to keep and pull it away.

  • To delete: Drag any block or stack back into the Block Palette area, or right-click it and select "Delete Block."

  • To test: Just click on a single block or a stack in the Scripts Area to see it run immediately on the stage—you don't even have to click the Green Flag!

Would you like to learn how to create your own "My Blocks" (Functions) to keep your code clean and organized?

📋

0 件のコメント:

コメントを投稿