Scratch My Blocks, Part 3: Custom Blocks with Parameters | Tutorial

Alphabets Sounds Video

share us on:

In this lesson, students learn how to create custom blocks in Scratch that can perform different functions by using parameters. Custom blocks help organize code, allow for code reuse, and simplify complex scripts, making projects more manageable and versatile. By incorporating parameters, users can customize the behavior of their blocks, enabling dynamic interactions such as changing what a character says or where it moves on the screen.

Scratch My Blocks: Custom Blocks with Parameters

Welcome to another fun adventure with Scratch! In this lesson, we’re going to learn how to make our own special blocks that can do different things each time we use them. These are called “custom blocks,” and they can make your Scratch projects even cooler!

Why Use Custom Blocks?

Custom blocks are like magic tools that help you organize your code. You can use them to:

  • Keep a sequence of code that works well together.
  • Reuse code without having to write it over and over again.
  • Make your code easier to understand by breaking it into smaller parts.

But what if you want your custom block to do something a little different each time? That’s where parameters come in!

Creating a Custom Block with Parameters

Let’s say you want your character to say something different each time. Here’s how you can do it:

  1. Click on “Make a Block” and give it a name like “speak and say.”
  2. Add an input, which is like a blank space where you can put different words or numbers each time you use the block. Name this input something like “what to say.”
  3. In the scripts area, add the code you want under the “define” block. Use the input you created by dragging it into the “speak” and “say” blocks.

Now, when you use this custom block in your program, you’ll see a blank bubble where you can type in what you want your character to say. Run the code, and watch your character speak the words you entered!

More Examples with Custom Blocks

Let’s try another example. Imagine you want to move your character to different places on the screen. You can create a custom block with inputs for the X and Y coordinates. This way, you can easily change where your character goes each time you use the block.

Here’s a fun idea: use a custom block to set up a math game! You can create a block that asks a math question using two numbers you provide. The program can then check if the answer is right and respond accordingly.

Endless Possibilities

You can even use multiple custom blocks together or put one custom block inside another. The possibilities are endless, and you can create amazing projects with these tools. Don’t forget to check out other “My Blocks” videos for more tips and tricks.

Now it’s your turn! What awesome things will you create with custom blocks in Scratch?

  1. What was your initial reaction to the concept of custom blocks in Scratch, and how do you think they could enhance your projects?
  2. Can you think of a specific project where using custom blocks with parameters would significantly improve the code structure or functionality? Describe the project and your ideas.
  3. Reflect on the process of creating a custom block with parameters. What challenges do you anticipate, and how might you overcome them?
  4. How do you think using custom blocks can help in learning programming concepts beyond Scratch?
  5. Discuss a scenario where reusing code with custom blocks could save time and effort. How would you implement this in a Scratch project?
  6. What are some creative ways you can use custom blocks to make your Scratch projects more interactive and engaging?
  7. Consider the example of using custom blocks for a math game. How would you expand on this idea to create a more complex educational game?
  8. Reflect on the statement “The possibilities are endless” regarding custom blocks. What does this mean to you, and how does it inspire your approach to creating projects in Scratch?
  1. Create Your Own Custom Block

    Start by creating a custom block in Scratch. Think of a simple task you want your character to perform, like saying a greeting. Use the “Make a Block” feature and add a parameter to change the greeting each time. Experiment with different phrases and see how your block works!

  2. Design a Mini Game

    Use custom blocks to design a mini game. Create a block that moves your character to random positions on the screen. Add parameters for speed and direction. Challenge yourself to make the game more interesting by adding obstacles or goals!

  3. Storytelling with Custom Blocks

    Write a short story using custom blocks. Create blocks for different scenes or actions in your story. Use parameters to change the dialogue or actions in each scene. Share your story with classmates and see how they use custom blocks in their stories!

  4. Math Quiz Challenge

    Develop a math quiz using custom blocks. Create a block that asks a math question with two numbers as parameters. Program it to check the answer and give feedback. Test your quiz with friends and see who can get the most correct answers!

  5. Collaborative Project

    Work with a partner to create a collaborative Scratch project. Each of you can create custom blocks for different parts of the project. Combine your blocks to make a fun and interactive program. Present your project to the class and explain how you used custom blocks!

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

In previous videos on Scratch My Blocks, we’ve explored creating a custom block, tips and tricks for success, and when and why you might want to use them. The My Blocks category of blocks may be used to protect a sequence of code that has been proven to work, collect a sequence of code that will be used repeatedly, or to parse out sections of code for easier assembly elsewhere.

However, the blocks we’ve created so far perform the exact same steps each time. What if we want to execute the same procedure each time the custom block is called in the main program, but with small changes, like the text shown, the coordinates used, or adjusting the value in one or more of these blocks? Let’s learn how to create a My Block that can be customized each time it is used.

Let’s start by setting up a custom block that has the character speak and say certain text simultaneously. You’ll see the code stack I want to use here. I’ll click “Make a Block” and give it a descriptive name, like “speak and say.” Since I want to customize the text my sprite will speak and say each time, I’m also going to add an input. With an input in place, the custom block will use the parameter (the data I provide) in the input bubble when I use the block. In this case, the input I’m choosing is “number or text.” To remember what the input is, I’ll give it a descriptive name, like “what to say.”

Back in my scripts area, I’ll add the desired code sequence under the “define” block. Then, in place of static text in the “speak” and “say” blocks, I’ll use the input I created while making my block. To get the input, click on the input label in the “define” block and drag it to place it in a code block. I want to use the same text in both the “speak” and “say” blocks, so I’ll do that twice.

Now, when I use this custom block in my main program, you can see the blank input bubble where I can enter the parameter, in this case, my custom text. Let’s run the code to see how it looks. “Hi! I’m a dragon. I have hot breath.” I’m able to use the same code sequence and customize it repeatedly without rewriting this code stack each time. If I need to make edits to the procedure, I only need to make changes under the “define” block to update everywhere the block is used in my main program.

Let’s see another example where I want to customize the X and Y coordinates every time I run my custom block. As I create my custom block, I can add labels between inputs to help me remember what is what as I use the block and fill in the parameters.

Here’s one more example where I’m using a custom block to help me set up a math game. In this case, I’m providing the two numbers in my question each time I use the custom block. The program uses those parameters in my custom block to ask the question, check the user’s answer, and provide the appropriate response.

I can even set up multiple custom blocks with or without inputs and use them together, or add a custom block inside another custom block. Be sure to check out the tips and tricks shared in the other “My Blocks” videos for more information. The possibilities are endless. What will you create?

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

ScratchA visual programming language that lets you create games and animations by snapping together code blocks. – Example sentence: In Scratch, you can make a cat dance by arranging the blocks in the right order.

BlocksPieces of code in Scratch that you can snap together to create a program. – Example sentence: To make the sprite move, you need to use the motion blocks in Scratch.

CodeA set of instructions written in a programming language that a computer can understand and execute. – Example sentence: When you write code, you are telling the computer what to do step by step.

CustomSomething that is made or modified to fit a particular need or requirement. – Example sentence: You can create a custom sprite in Scratch to make your project unique.

ParametersValues or settings that you can change to affect how a program or function behaves. – Example sentence: By adjusting the parameters, you can change how fast the sprite moves across the screen.

InputInformation or data that is entered into a computer or program for processing. – Example sentence: The program asks for your name as an input to greet you personally.

CharacterA symbol or letter that can be used in text or programming. – Example sentence: Each character you type on the keyboard is stored as data in the computer.

SayA command in Scratch that makes a sprite display a speech bubble with text. – Example sentence: You can use the “say” block to make the sprite introduce itself to the audience.

ProgramA complete set of instructions that a computer follows to perform a task. – Example sentence: We wrote a program in Scratch that makes the sprite jump when you press the spacebar.

CoordinatesNumbers that determine the position of a point on a grid or screen, usually defined by x and y values. – Example sentence: In Scratch, you can use coordinates to place your sprite exactly where you want it on the stage.

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?