Conditional Statements: Make Interactive Projects (Part 1)| Tutorial

Alphabets Sounds Video

share us on:

In this lesson, students learn about conditional statements in Scratch, which allow programs to react differently based on specific situations. By creating a dynamic fish game, they explore how to use blocks like “wait until” and “repeat until” to trigger actions, such as changing the fish’s costume or playing sounds when it interacts with a pufferfish. The lesson encourages experimentation with various conditional structures to enhance interactivity in their projects.

Conditional Statements: Make Interactive Projects (Part 1)

Have you ever wanted to create a fun and interactive program using Scratch? Some programs always do the same thing, but others can change and react differently each time you use them. To make these dynamic programs, we use something called conditional statements. These are special instructions that tell the program what to do in different situations.

Creating a Dynamic Fish Game

Imagine you have a game where you control a fish with your mouse. What if you want something special to happen when your fish touches another character, like a pufferfish? In Scratch, you can find conditional statement blocks under the Control category. These blocks help you set rules like “do this until something is true” or “if something is true, then do this.”

For our fish game, we’ll use a block called “wait until”. In the Sensing category, there’s a block called “touching mouse-pointer”. You can use this block to check if your fish is touching the pufferfish. Conditional statements can be either true or false. If the fish and pufferfish aren’t touching, it reports “false.” If they are touching, it reports “true.” These blocks are called Boolean blocks and have a special shape like an elongated hexagon.

Understanding “Wait Until” and “Repeat Until”

Let’s see how “wait until” and “repeat until” blocks work. If we use “wait until,” the program waits for the fish to touch the pufferfish before playing a sound. With “repeat until,” the sound keeps playing until the fish touches the pufferfish. It’s like the opposite effect!

Now, let’s make the fish show a different costume and think “Ouch” when it touches the pufferfish. Did you notice that “Ouch” only appears once? That’s because the program checks the condition just once. If we put this code inside a “forever” loop, the program keeps checking, and “Ouch” appears every time the fish touches the pufferfish.

Switching Costumes

What if we want the fish to switch back to its original costume when it’s not touching the pufferfish? If we put the costume-switching block inside the loop, the program quickly switches back and forth. Adding a small wait before checking can help us see the change more clearly.

Exploring More Options

There are many ways to achieve the same result. Instead of “wait until,” you could use an “if then” or “if then else” statement. By adjusting the “think” block, you can make the costume switch immediately when the fish stops touching the pufferfish.

What else can you try or add to your project? Experiment and have fun! In our next lesson, we’ll add some code to the pufferfish and learn how to fix problems with conditional statements. We’ll also explore more complex scripts by nesting conditional statements.

  1. How did the article change your understanding of conditional statements and their role in creating interactive programs?
  2. What insights did you gain about using Scratch for game development, particularly with the fish game example?
  3. Reflect on a time when you used or could have used conditional statements in a project. How might the concepts from the article have influenced your approach?
  4. What challenges do you anticipate when implementing “wait until” and “repeat until” blocks in your own projects?
  5. How do you think the use of loops, such as the “forever” loop, can enhance the interactivity of a Scratch project?
  6. In what ways could you apply the concept of switching costumes based on conditions to other types of projects or games?
  7. What are some creative ideas you have for experimenting with conditional statements in Scratch beyond the examples given in the article?
  8. How might you explain the importance of Boolean blocks to someone new to programming, based on your understanding from the article?
  1. Create Your Own Fish Game

    Use Scratch to create a simple game where you control a fish with your mouse. Add a pufferfish character and use conditional statements to make something special happen when your fish touches the pufferfish. Experiment with different actions like playing a sound or changing the fish’s costume.

  2. Conditional Statement Challenge

    Try using both “wait until” and “repeat until” blocks in your Scratch project. Observe how they behave differently. Can you make the fish say “Ouch” every time it touches the pufferfish? Use a “forever” loop to keep checking the condition.

  3. Costume Switch Experiment

    Design a Scratch project where your fish switches costumes when it touches the pufferfish. Add a small wait before checking the condition again to see the costume change more clearly. Can you make the fish switch back to its original costume when it’s not touching the pufferfish?

  4. Explore “If Then” and “If Then Else”

    Use “if then” and “if then else” blocks in your Scratch project to create different outcomes. For example, make the fish think “Ouch” only when touching the pufferfish and switch costumes immediately when it stops touching. Experiment with different scenarios and see what you can create.

  5. Share and Discuss

    Share your Scratch project with a classmate and discuss the different conditional statements you used. Explain how they work and what happens in your game. Ask your classmate for feedback and see if they have any suggestions for improvement or new ideas to try.

Sure! Here’s a sanitized version of the YouTube transcript:

Have you ever wanted to create an interactive Scratch program or one that offers multiple outcomes? Some Scratch programs are static, meaning the outcome is fixed and the same thing happens each time. Others are dynamic, capable of action or change each time they are run. To create dynamic programs, programmers can use conditional statement blocks to give instructions on how the program should respond in different circumstances.

For example, I have a program where a fish can be controlled by my mouse. What if I wanted a unique action to take place if the fish touches another sprite, like a pufferfish? Under the Control category in Scratch, I can find several conditional statement blocks that allow me to adjust the program based on specific conditions, such as “until something is true or false” or “if something is true or false, then.” For this fish game, I’m going to use a “wait until” block.

Under the Sensing category, I’ll grab the “touching mouse-pointer” block and use the dropdown menu to select my pufferfish sprite. Conditional statements can be true or false. If the sprites aren’t touching, this block will report “false.” If they are touching, it will report “true.” There are many conditions in Scratch that you can choose from to complete a conditional statement. Blocks that report “true” or “false” values are known as Boolean blocks, identifiable by their elongated hexagonal shape.

To see the difference between the “wait until” and “repeat until” conditional statement blocks, I’m going to have it play a sound. Let’s run the code and see what happens. With “wait until,” it waited until my fish was touching the pufferfish, and then the sound played. Now, let’s try the “repeat until” block and observe the difference. Notice that the opposite effect happened; it repeated the sound until the condition was true, meaning until the fish was touching the pufferfish.

I’m going to wait until the fish is touching the pufferfish, and then show one costume to start and another if they touch. I’ll also have the fish think “Ouch” when they touch. Did you notice that, once the fish touched the pufferfish, if they touched again, you don’t see “Ouch” again? That’s because the program is only checking if this condition is true once. If I put this code stack inside a “forever” loop, let’s see the difference. Now, each time the fish touches the pufferfish, you’ll see “Ouch!” because it’s continually checking to see if the condition (touching pufferfish) is true.

What if I want the sprite to switch back to the initial costume when it isn’t touching the pufferfish? Notice the difference when I have the block to switch back to the initial fish costume inside the loop versus outside the loop. When inside the loop, the program is constantly switching to the original costume, but then immediately checking to see if they are touching. If so, it shows the “Ouch” costume. It checks so quickly that our eyes don’t see the switch. But if I add a small wait just before the check, you can see what I mean.

There are often multiple solutions to accomplish the same goal. For instance, I could use an “if then” or “if then else” statement instead of a “wait until” conditional statement here. If I make a small adjustment to the “think” block in this “if then else” statement to remove the time, notice if I move my mouse away quickly, I can get the costume to switch immediately after they stop touching.

What else could you try or add? Tinker and experiment! In our next video, we’ll add some code to the pufferfish, too, and practice debugging conditional statements and making more complex scripts by nesting conditional statements.

This version removes any informal expressions and maintains a clear and educational tone.

Conditional StatementsInstructions in a program that only run when certain conditions are true. – In our game, the character jumps only if the conditional statement checks that the space bar is pressed.

ScratchA visual programming language that helps beginners learn to code by snapping together blocks. – We used Scratch to create a fun animation with a dancing cat.

ProgramA set of instructions that a computer follows to perform a task. – I wrote a program to calculate the total score of my math quiz.

FishA type of character or sprite that can be used in coding projects, often in games or animations. – In my underwater game, the fish swims around collecting coins.

PufferfishA specific type of fish sprite that can inflate and deflate, often used in coding projects for fun effects. – When the player gets too close, the pufferfish in my game puffs up to scare them away.

TrueA boolean value indicating that a condition or statement is correct or valid. – The program checks if the answer is true before moving to the next question.

FalseA boolean value indicating that a condition or statement is incorrect or invalid. – If the answer is false, the program will ask the question again.

BlocksVisual pieces in Scratch that represent code instructions and can be snapped together to create a program. – I used different blocks to make the character move and speak in my project.

CostumeA different appearance or outfit for a sprite in Scratch, used to change how it looks. – I changed the sprite’s costume to make it look like a superhero.

LoopA sequence of instructions that repeats until a certain condition is met. – I used a loop to make the character keep walking until it reaches the end of the path.

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?