Scratch My Blocks, Part 1: Create Custom Blocks | Tutorial

Alphabets Sounds Video

share us on:

In this lesson, students learn how to create custom blocks in Scratch, which allows them to simplify their coding by grouping a series of blocks into a single, named procedure. This not only makes their code more organized and easier to read, but also enables efficient updates, as changes to the custom block automatically reflect wherever it is used in the project. The lesson encourages creativity and lays the groundwork for exploring more advanced features in future lessons.

Scratch My Blocks, Part 1: Create Custom Blocks

Have you ever noticed the “My Blocks” section in Scratch? It’s a special place where you can create your own blocks to make coding easier and more fun! Let’s dive into how you can create a custom block and why it’s super helpful.

What Are Custom Blocks?

Imagine you’re working on a Scratch project, and you’ve put together a bunch of blocks to make something cool happen, like a dance move, a musical tune, or a drawing. This group of blocks is called a “procedure” or “routine.” In Scratch, you can give this group a special name and use it whenever you want in your project. This is where “My Blocks” comes in handy!

Creating Your Own Block

To start, click on “My Blocks” in the blocks palette and then click “Make a block.” You can name your block anything you like, but it’s best to choose a name that helps you remember what it does. For example, if you want your cat sprite to spin, you might call it “cat spin.”

After you click “OK,” you’ll see a new block in the scripts area that says “define.” This is where you’ll add all the blocks that make up your procedure. For instance, you could add blocks that make the cat spin in circles and then spin back the other way. Once you’ve set this up, you can use your new “cat spin” block in your main program whenever you want the cat to spin.

Why Use Custom Blocks?

Using custom blocks has many advantages. First, it makes your code easier to read and write. Instead of having a long list of blocks, you can use one custom block to do the same thing. This is especially helpful if you want to change something later. You only need to update the custom block, and it will change everywhere it’s used!

Custom blocks are also great for organizing your code. If you have a long sequence of blocks that do something specific, turning it into a custom block makes it easier to find and edit later. This is really useful as your program gets bigger and more complex.

Getting Creative with Custom Blocks

Custom blocks aren’t just for repeating actions. You can use them for any complex sequence of blocks. This helps you keep track of what your program does and makes it easier to debug and improve over time. You can even plan your custom blocks from the start or add them later as you see patterns in your code.

What’s Next?

In future lessons, we’ll look at how “My Blocks” compare to Broadcast blocks, share tips for using custom blocks effectively, and explore creating more advanced blocks with inputs. We’ll also talk about running blocks without refreshing the screen. There’s so much you can do with custom blocks. What will you create next?

  1. How did the concept of custom blocks in Scratch change your perspective on organizing and simplifying code?
  2. Can you think of a project where using custom blocks would have made your work easier or more efficient? How so?
  3. Reflect on a time when you struggled with a complex sequence of blocks in Scratch. How might custom blocks have helped in that situation?
  4. What are some creative ways you could use custom blocks in your future Scratch projects?
  5. How do you think the ability to create custom blocks can impact collaboration on Scratch projects with others?
  6. What challenges do you anticipate when creating and implementing custom blocks for the first time?
  7. How does the use of custom blocks in Scratch compare to similar features in other programming environments you are familiar with?
  8. What new insights or ideas did you gain from the article about the potential of custom blocks in programming?
  1. Create Your Own Dance Routine

    Imagine your favorite character is on stage ready to perform a dance. Use the “My Blocks” section in Scratch to create a custom block for a dance move. Name your block something fun, like “twirl” or “jump.” Once you’ve created your custom block, use it in a sequence to make a complete dance routine. Share your dance with the class and explain how you used custom blocks to make it easier!

  2. Musical Tune Challenge

    Compose a short musical tune using Scratch. Create a custom block for a specific part of the tune, like a chorus or a melody. Name your block something that describes the music, such as “happy chorus.” Use your custom block to repeat the tune in different parts of your project. Present your musical creation and discuss how custom blocks helped organize your code.

  3. Artistic Drawing with Custom Blocks

    Design a unique drawing using Scratch. Create a custom block for a specific pattern or shape, like a star or a circle. Give your block a descriptive name, such as “star pattern.” Use your custom block to repeat the pattern across your canvas. Show your artwork to the class and explain how using custom blocks made your drawing process more efficient.

  4. Storytelling with Custom Blocks

    Write a short story in Scratch using sprites and backgrounds. Create custom blocks for different scenes or actions, like “scene change” or “character dialogue.” Name your blocks to reflect their purpose. Use these blocks to organize your story into a clear sequence. Share your story with the class and describe how custom blocks helped you manage the story flow.

  5. Debugging Adventure

    Work on a Scratch project that has a bug or needs improvement. Identify a sequence of blocks that can be turned into a custom block to simplify the code. Create the custom block and name it based on its function, like “fix jump.” Use the custom block to replace the original sequence. Present your improved project and explain how custom blocks helped you debug and enhance your code.

Here’s a sanitized version of the provided YouTube transcript:

Have you seen the “My Blocks” category in the Scratch blocks palette? When you click on it, no blocks are present until you create one. Let’s explore how to create a customized block and when and why you might want to use them.

Let’s say you are creating a Scratch program and you’ve written a sequence of steps that performs a particular action. That action could be performing a complicated spin move, playing a set of musical notes, drawing a shape with the pen tool, performing some complex math, or anything else. That stack of blocks is known as a “procedure” or a “routine.” Most programming languages allow you to create a special name for a group of commands or lines of code and then call for that sequence to run at any point in the main program. In Scratch, we use “My Blocks.”

Click on “My Blocks” in the blocks palette and then click on “Make a block.” You can give your block any name you want, but I’d recommend something descriptive so you can recall later what this stack of blocks does. Let’s say I want to create a series of blocks that makes my cat sprite spin forward and backward. I’ll call my block “cat spin.” Once I click “OK,” you’ll see a new event handler block appear in the scripts area that says, “define.” Under this block, I want to add all the code blocks in my procedure.

For this example, I’ve added some repeating code that makes the cat whirl and turn forward in two complete circles and then reverse the whirl, turning in the opposite direction. Let’s click on this stack and see how it looks. Now that I’ve defined what my custom block does, let’s use it in my main program. When I want the spin to occur, I’ll grab my custom “cat spin” block now available in the blocks palette and place it in my main program. In this program that I’m writing, the cat will spin after each background change and say something after the spin.

Let’s see how this looks by clicking the green flag. The advantage of writing this procedure separately is that I can use one block to call for a whole set of steps to be run each time I need it. Creating separate procedures using custom blocks makes the code faster to write and read, and easier or quicker to edit. If I wasn’t using a custom block, this is how the code would look. Looking at them side-by-side, which is easier to read? And look, if I wanted to change the spin, I only have to edit it in one place, versus editing it in multiple places in my long single code sequence.

You don’t have to use a custom block just for code that will repeat. If you have a long, complex sequence that performs a particular action, you may want to define it as a custom block so you can more easily identify all the steps involved and edit it later. As a program becomes longer and more complex, it can be easy for a programmer to lose their place as they develop, debug, and refine the code over time. If you have planned out your program and know the procedures you want to define separately, you can set up your custom block at the very beginning. Or if you’ve written a program that is very long, you can revisit your program and identify repeating code or specialized code you want to define as separate procedures, create custom blocks, and use them to make your code more efficient to read, write, and edit.

In other videos, we’ll explore using My Blocks versus Broadcast blocks (which both can store a set of procedures), go over some tips and tricks for using My Blocks successfully, and explore creating more complex custom blocks using inputs. We’ll also discuss the option to run without screen refresh. The possibilities are endless. What will you create?

This version maintains the original content while ensuring clarity and coherence.

ScratchA computer program that helps you create stories, games, and animations using simple coding. – Example sentence: In our computer class, we used Scratch to make a fun animation with dancing animals.

BlocksPieces of code that you can connect together to create a program in Scratch. – Example sentence: I used different blocks to make my character move and jump in the game I created.

CodingThe process of writing instructions for a computer to follow. – Example sentence: We learned the basics of coding by creating a simple game using Scratch.

CustomSomething made or done to fit the needs of a particular person or task. – Example sentence: I created a custom background for my game to make it look like a jungle.

ProcedureA set of instructions that perform a specific task in a program. – Example sentence: I wrote a procedure to make my sprite spin around when I press the space bar.

RoutineA sequence of actions regularly followed in a program. – Example sentence: The routine in my game makes the character jump every time I press the up arrow key.

ProgramA set of instructions that a computer follows to perform a task. – Example sentence: We wrote a program in Scratch to make a cat chase a mouse across the screen.

SpriteA character or object in a computer program that can be controlled or animated. – Example sentence: I chose a dragon sprite for my game and made it fly around the screen.

DebugThe process of finding and fixing errors in a computer program. – Example sentence: I had to debug my program because the sprite wasn’t moving correctly.

CreativeUsing imagination to make something new or original. – Example sentence: We were encouraged to be creative and come up with our own unique game ideas in Scratch.

All Video Lessons

Login your account

Please login your account to get started.

Don't have an account?

Register your account

Please sign up your account to get started.

Already have an account?