Skip to content

Please update your browser

Your browser version is not supported by this site. CS First may not work properly. Learn more

3. The Glitch and a Response

Transcript

Now that you’ve added some foreshadowing to your story, you will program a “glitch” that you can reuse throughout the story.

Then, you will make your second character react to the glitch.

In “The Signal,” Gumball is the first to experience the glitches, and he struggles to explain them to Darwin.

Check out some examples.

What do you think?

Nah...

I think it's a bit...

You're right-- to desperate for attention.

Woo, how about this?

Yah, that one makes you look kind of... Yah, I get it-- too thinking it's cool, but lonely at school.

What just happened?

How about this?

Yah, that one makes you look...

Yah, too Canadian.

I really like this one, but do you think it makes like I have a fat head?

I uh...

To make a glitch for your character, you will write code that changes their appearance.

From the looks menu, drag out a “change effect by” block.

Click it to see what it does.

It changes the “color” value of the sprite by 25.

Click the dropdown, and select a few different effects to try.

There are many ways to change your sprite’s appearance.

Click the “clear graphic effects” block to return your character to normal.

Running the block once creates a small effect.

To make the effect more dramatic, run it repeatedly.

This is called a “loop.”

Click control, and drag a “repeat 10” block around the “change effect by” block.

Select an effect to repeat, and click the block to try it.

Cool.

Play around with the values to see the different effects you can create.

To reset each time, add the “clear graphic effects” block to the bottom of the stack.

Combine “effects” and “repeat” blocks to make as dramatic of an effect as you would like for your story.

Once you have an effect you like, add it to your block stack, and try it out.

Great!

Once you create a glitch, make the second character respond to it.

Select the second character.

Drag out a “say for 2 seconds block,” and type in what the character will say about the glitch.

These are just examples of what the secondary character might say when it sees the glitch happening.

Add a response that fits your story.

Click the block to run it.

Great!

The character responds.

Right now, your code stacks run like two separate programs.

To tell the story, you click one stack, then switch characters and click the other but there’s a better way.

Use the flag to run both block stacks.

Select the event menu.

An “event” tells code when to run.

There are many different types of events.

Click and drag out a “when flag clicked” block for both sprites.

This block will start the code when the flag is clicked.

Click the flag to try it out.

Both stacks run at the same time, but the second character responds too quickly.

To fix this, add a “wait” block between the “show” and “say” blocks.

Tinker with the time until the second character’s response to the glitch seems more natural.

Click the flag to try it out.

Great!

To build out more conversation in this scene, use “wait” and “say” blocks.

As computer scientists develop programs, they test their code often as they build it, then make improvements based on what they see in the test.

Now it’s your turn: Program a “glitch” using “repeat” and “change effect by” blocks.

Reset the “glitch” using a “clear graphic effects” block.

Add dialogue using “say for 2 seconds” blocks and “wait” blocks.

And finally run both characters’ code using “when flag clicked” blocks.

arrow_backward Back
Next arrow_forward
Instructions
  1. Program a "glitch" using "repeat" and "change effect by" blocks.
  2. Reset the "glitch" using a "clear graphic effects" block.
  3. Add dialogue using "say for 2 seconds" blocks and "wait" blocks.
  4. Run both characters' code using "when flag clicked" blocks.