create an interactive digital product using programming logic

79
Create an interactive digital Create an interactive digital product using programming product using programming logic logic

Upload: jeff

Post on 13-Jan-2016

36 views

Category:

Documents


0 download

DESCRIPTION

Create an interactive digital product using programming logic. OBJECTIVE. The objective of this lesson is for each student to create an interactive digital product using programming logic. Sample(s) of Behavior (SOBs) Build a script that enables a cat to walk - PowerPoint PPT Presentation

TRANSCRIPT

Page 1: Create an interactive digital product using programming logic

Create an interactive digital product Create an interactive digital product using programming logicusing programming logic

Page 2: Create an interactive digital product using programming logic

OBJECTIVEOBJECTIVEThe objective of this lesson is for each The objective of this lesson is for each

student to create an interactive digital student to create an interactive digital product using programming logic.product using programming logic.

Sample(s) of Behavior (SOBs)Sample(s) of Behavior (SOBs)Build a script that enables a cat to walkBuild a script that enables a cat to walkUse script tools for importing a Sprite, interaction, Use script tools for importing a Sprite, interaction, conditional and question blocks, and talkingconditional and question blocks, and talkingBuild a script for adding a Background – Repeat Blocks Build a script for adding a Background – Repeat Blocks – Export a Sprite– Export a SpriteUse variables, motion, looks, and interactionUse variables, motion, looks, and interactionBuild a script that generates two cat sprites into just oneBuild a script that generates two cat sprites into just oneModify a script by adding variablesModify a script by adding variablesProduce or add soundsProduce or add sounds

Page 3: Create an interactive digital product using programming logic

THE BEGINNING Continued

In the world of digital electronic systems, there are three basic kinds of devices: memory, In the world of digital electronic systems, there are three basic kinds of devices: memory, microprocessors, and logic. Memory devices store random information such as the contents of microprocessors, and logic. Memory devices store random information such as the contents of a spreadsheet or database. Microprocessors execute software instructions to perform a wide a spreadsheet or database. Microprocessors execute software instructions to perform a wide variety of tasks such as running a word processing program or video game. Logic devices variety of tasks such as running a word processing program or video game. Logic devices provide specific functions, including device-to-device interfacing, data communication, signal provide specific functions, including device-to-device interfacing, data communication, signal processing, data display, timing and control operations, and almost every other function a processing, data display, timing and control operations, and almost every other function a system must perform.system must perform.

Logic devices can be classified into two broad categories - fixed and programmable. As the Logic devices can be classified into two broad categories - fixed and programmable. As the

name suggests, the circuits in a fixed logic device are permanent, they perform one function or name suggests, the circuits in a fixed logic device are permanent, they perform one function or

set of functions - once manufactured, they cannot be changed. On the other hand, set of functions - once manufactured, they cannot be changed. On the other hand,

programmable logic devices (PLDs) are standard, off-the-shelf parts that offer customers a programmable logic devices (PLDs) are standard, off-the-shelf parts that offer customers a

wide range of logic capacity, features, speed, and voltage characteristics - and these devices wide range of logic capacity, features, speed, and voltage characteristics - and these devices can be changed at any time to perform any number of functions.can be changed at any time to perform any number of functions.

Page 4: Create an interactive digital product using programming logic

THE BEGINNING Continued

With programmable logic devices, designers use inexpensive software With programmable logic devices, designers use inexpensive software tools to quickly develop, simulate, and test their designs. Then, a design tools to quickly develop, simulate, and test their designs. Then, a design can be quickly programmed into a device, and immediately tested in a live can be quickly programmed into a device, and immediately tested in a live circuit. The PLD that is used for this prototyping is the exact same PLD circuit. The PLD that is used for this prototyping is the exact same PLD that will be used in the final production of a piece of end equipment, such that will be used in the final production of a piece of end equipment, such as a network router, a DSL modem, a DVD player, or an automotive as a network router, a DSL modem, a DVD player, or an automotive navigation system. There are no NRE costs and the final design is navigation system. There are no NRE costs and the final design is completed much faster than that of a custom, fixed logic device.completed much faster than that of a custom, fixed logic device.

Another key benefit of using PLDs is that during the design phase Another key benefit of using PLDs is that during the design phase customers can change the circuitry as often as they want until the design customers can change the circuitry as often as they want until the design operates to their satisfaction. That's because PLDs are based on re-writable operates to their satisfaction. That's because PLDs are based on re-writable memory technology - to change the design, the device is simply memory technology - to change the design, the device is simply reprogrammed. Once the design is final, customers can go into immediate reprogrammed. Once the design is final, customers can go into immediate production by simply programming as many PLDs as they need with the production by simply programming as many PLDs as they need with the final software design file.final software design file.

Page 5: Create an interactive digital product using programming logic

THE BEGINNING Continued

The value of programmable logic has always been its ability to shorten The value of programmable logic has always been its ability to shorten development cycles for electronic equipment manufacturers and help them get their development cycles for electronic equipment manufacturers and help them get their product to market faster. As PLD suppliers continue to integrate more functions product to market faster. As PLD suppliers continue to integrate more functions inside their devices, reduce costs, and increase the availability of time-saving IP inside their devices, reduce costs, and increase the availability of time-saving IP cores, programmable logic is certain to expand its popularity with digital designers.cores, programmable logic is certain to expand its popularity with digital designers.

Now we have a basic understanding of Programming Logic, let’s look at a way of Now we have a basic understanding of Programming Logic, let’s look at a way of developing an interactive digital product using “Scratch” programming logic developing an interactive digital product using “Scratch” programming logic program.program.

Page 6: Create an interactive digital product using programming logic

THE BEGINNING This is a sprite.

It can be any thing, person, or place you want it to be. You can control what a sprite does. They can only do those things if they know how to do them. Sprites already know how to do some things, but it is your job to make sprites do more complicated things by using the few simple things that they already do know how to do. So in a way, you are teaching the sprite what to do. You can teach it to walk, run, jump, talk, or anything else you are clever enough to teach them to do.

You can tell a sprite to do something it already knows by putting a Script Block into the Script Window. To pick which Sprite you are controlling, select it from the window on the bottom right. Your sprites can be seen in action in your World Preview Window.

Page 7: Create an interactive digital product using programming logic

THE BEGINNING Continued

In this lesson you will teach a cat to walk when certain keys are pressed on the keyboard. In this lesson you will teach a cat to walk when certain keys are pressed on the keyboard.

In order to make the cat do something, you have to tell it, step by step, everything it must do. In order to make the cat do something, you have to tell it, step by step, everything it must do.

To give the cat a simple walk, you must tell the sprite how to do the following: To give the cat a simple walk, you must tell the sprite how to do the following: – Move in the direction you want to walk Move in the direction you want to walk – Move your legs Move your legs – Move to the keyboard Move to the keyboard – Turn aroundTurn around

Page 8: Create an interactive digital product using programming logic

THE BEGINNING Continued

      Tell the cat to move by dragging to the script window. Tell the cat to move by dragging to the script window.

A positive (+) # number moves →to the right. A negative (-) # number moves ←to the left. A positive (+) # number moves →to the right. A negative (-) # number moves ←to the left.

You can activate script blocks by double clicking their colored areas. Try it out. You can activate script blocks by double clicking their colored areas. Try it out.

Sprites can have different costumes. They can switch between →← costumes to change the way they look. Sprites can have different costumes. They can switch between →← costumes to change the way they look. This sprite has 2 costumes already. The cat’s legs are in different positions. If it switches back ← and This sprite has 2 costumes already. The cat’s legs are in different positions. If it switches back ← and forth→ between these costumes, the cat will look like it is taking steps. forth→ between these costumes, the cat will look like it is taking steps.

Click in the Top Left Menu. Click in the Top Left Menu.

Find and drag it into the script window. Find and drag it into the script window.

You can connect blocks on their tops and bottoms.You can connect blocks on their tops and bottoms.

Page 9: Create an interactive digital product using programming logic

THE BEGINNING Continued

These two blocks tell the cat take one cat-step to the right. These two blocks tell the cat take one cat-step to the right.

Why does the block say 10 steps? Why does the block say 10 steps?

Here, ‘steps’ means: # number of pixels → to move in the direction that the sprite is facing. Here, ‘steps’ means: # number of pixels → to move in the direction that the sprite is facing. You will learn more about this in Lesson 3. You will learn more about this in Lesson 3.

Pixels are tiny blocks of color that are combined together to make images. Pixels are tiny blocks of color that are combined together to make images.

When Script Blocks are connected, they activate together, starting from the top.When Script Blocks are connected, they activate together, starting from the top. One way to respond to the keyboard is to add to the top of a list of One way to respond to the keyboard is to add to the top of a list of commands. The commands will then start when a certain key is pressed. commands. The commands will then start when a certain key is pressed.

You can find this command by clicking in the Top Left Menu. You can find this command by clicking in the Top Left Menu.

Drag to the script Drag to the script

window and snap it to the top window and snap it to the top

of your list.of your list.

Change the keystroke to right Change the keystroke to right

arrow instead of space. arrow instead of space.

Click the Green Flag to start Click the Green Flag to start

your scripts.your scripts.

Page 10: Create an interactive digital product using programming logic

THE BEGINNING Continued

From here on, you will start seeing this image: From here on, you will start seeing this image:

When you see this, it means that you should click the Green Flag and test out your When you see this, it means that you should click the Green Flag and test out your program.program.

Now that there is a cat sprite that can walk to the right, you need to make one that can Now that there is a cat sprite that can walk to the right, you need to make one that can walk to the left. walk to the left.

The Stamp is a World Tool. The Stamp is a World Tool. Stamping a sprite makes a copy of it.Stamping a sprite makes a copy of it.

Page 11: Create an interactive digital product using programming logic

THE BEGINNING Continued

Make a copy of the cat sprite by stamping it. Make a copy of the cat sprite by stamping it.

Select Sprite 2. You can use this new sprite to walk left.Select Sprite 2. You can use this new sprite to walk left.

Each sprite has its own Scripts, Costumes Each sprite has its own Scripts, Costumes

and Sounds. Everything gets copied and Sounds. Everything gets copied

when you used the stamp tool. when you used the stamp tool.

It is best to name a sprite after what it is.It is best to name a sprite after what it is.

Change the name to “catLeft”.Change the name to “catLeft”.

Page 12: Create an interactive digital product using programming logic

THE BEGINNING Continued

Click the Costumes TabClick the Costumes TabClick the Edit button to edit costume2. Click the Edit button to edit costume2.

The editing window will open. The editing window will open.

Click the Flip Horizontally button to make Click the Flip Horizontally button to make the cat face the other way.the cat face the other way.

Page 13: Create an interactive digital product using programming logic

THE BEGINNING Continued

You must do the same thing for the other costume. You must do the same thing for the other costume.

If you have not done so already, rename the sprite that is facing right, to catRight. If you have not done so already, rename the sprite that is facing right, to catRight.

To make the sprites work together, you have to only have one showing at a time. It is easy to To make the sprites work together, you have to only have one showing at a time. It is easy to hide and show sprites as long as you can figure out when to do it. hide and show sprites as long as you can figure out when to do it.

You want catLeft to show when the left arrow is pressed and hide when the right arrow is You want catLeft to show when the left arrow is pressed and hide when the right arrow is pressed. pressed.

You want catRight to show when the right arrow is pressed and hide when the left arrow is You want catRight to show when the right arrow is pressed and hide when the left arrow is pressed.pressed. Click in the Top Left Menu. Find and .Click in the Top Left Menu. Find and . Make the sprite hide and show when it needs to for both sprites.Make the sprite hide and show when it needs to for both sprites.

Page 14: Create an interactive digital product using programming logic

THE BEGINNING Continued

Both of the sprites are just different views of the same cat so you want both sprites to move at Both of the sprites are just different views of the same cat so you want both sprites to move at

the same time even if they are not showing. the same time even if they are not showing.

Page 15: Create an interactive digital product using programming logic

THE BEGINNING Continued

Page 16: Create an interactive digital product using programming logic

THE BEGINNING Continued

Save your project so you can use it later. Save it as “Lesson 1” in a new folder Save your project so you can use it later. Save it as “Lesson 1” in a new folder “Lessons”.“Lessons”.

To make a new folder, click the new folder button in the save window.To make a new folder, click the new folder button in the save window.

Page 17: Create an interactive digital product using programming logic

THE BEGINNING Continued

Things To Remember Things To Remember

You can control what a sprite does. You are teaching the sprite what to do. You can teach it to You can control what a sprite does. You are teaching the sprite what to do. You can teach it to walk, run, jump, talk, or anything else you are clever enough to teach them to do. In order to walk, run, jump, talk, or anything else you are clever enough to teach them to do. In order to make the cat do something, you have to tell him, step by step, everything he must do. make the cat do something, you have to tell him, step by step, everything he must do.

Sprites can have different costumes. They can switch between →← costumes to change the way Sprites can have different costumes. They can switch between →← costumes to change the way they look. they look.

When Script Blocks are connected, they activate together, starting from the top. When Script Blocks are connected, they activate together, starting from the top.

Pixels are tiny blocks of color that are combined together to make images. Pixels are tiny blocks of color that are combined together to make images.

Clicking the Green Flag will start scripts under the “When Green Flag Clicked” blocks. Clicking the Green Flag will start scripts under the “When Green Flag Clicked” blocks.

One way to respond to the keyboard is to add a “When key Pressed” to the top of a list of One way to respond to the keyboard is to add a “When key Pressed” to the top of a list of commands. The commands underneath it will then start when that certain key is pressed. commands. The commands underneath it will then start when that certain key is pressed.

Each sprite has its own Scripts, Costumes and Sounds. Everything gets copied when you used the Each sprite has its own Scripts, Costumes and Sounds. Everything gets copied when you used the stamp tool. stamp tool.

You can hide and show sprites by using the “hide” and “show” blocks in the Looks menu. You You can hide and show sprites by using the “hide” and “show” blocks in the Looks menu. You can also show a sprite by right clicking (control click for Mac) the sprite button under the World can also show a sprite by right clicking (control click for Mac) the sprite button under the World Preview Window and clicking show. Preview Window and clicking show.

You can face a sprite the opposite way by editing the costume and flipping it horizontally.You can face a sprite the opposite way by editing the costume and flipping it horizontally.

Page 18: Create an interactive digital product using programming logic

IMPORTING A SPRITE, INTERACTION, CONDITIONAL AND QUESTION BLOCKS, AND TALKING

Open up the file you saved from Lesson 1. Open up the file you saved from Lesson 1.

Click the Import New Sprite Button.Click the Import New Sprite Button.

Open the Things Folder.

Page 19: Create an interactive digital product using programming logic

IMPORTING A SPRITE, INTERACTION, CONDITIONAL AND QUESTION BLOCKS, AND TALKING

Continued

Scroll down and find the key.Scroll down and find the key.

Page 20: Create an interactive digital product using programming logic

IMPORTING A SPRITE, INTERACTION, CONDITIONAL AND QUESTION BLOCKS, AND TALKING

Continued

It is always helpful to name sprites. Rename the sprite to “key.”It is always helpful to name sprites. Rename the sprite to “key.”

This sprite is very big compared to the cat so you should make it smaller. Choose the Shrink Tool in the World Tools then shrink the key to make it look better.

Keep clicking the sprite with the shrink tool until it looks like the cat could hold it.

Page 21: Create an interactive digital product using programming logic

IMPORTING A SPRITE, INTERACTION, CONDITIONAL AND QUESTION BLOCKS, AND TALKING

Continued

Keep clicking the sprite with the shrink tool until it looks like the cat could hold it.

Working with the key scripts:

For this program, you should show the key sprite as soon as the Green Flag is clicked.

Page 22: Create an interactive digital product using programming logic

IMPORTING A SPRITE, INTERACTION, CONDITIONAL AND QUESTION BLOCKS, AND TALKING

Continued

To make it look like the cat is taking the key, you can hide it when the cat touches it. To do this, you need to use a conditional block. These blocks have pointy edges on the side and they fit into holes that have pointy edges on the side. Question blocks are used to ask true or false questions. You can use them by putting them into conditional blocks to perform actions depending on the answer.

Blocks that ask conditional blocks have an empty spot for you to put questions in. The questions look like rectangles with pointy ends. To complete a conditional block command, you have to put a question in it.

Right now, you want to ask if the key is touching the sprite.

Find the Touching question block:

Touching is a sense, so look for it in the Sensing Menu.

To use a question block, you need to say what to do when the question is true. One way you can do this is by putting the question into the ‘Wait Until’ conditional block. The ‘Wait Until’ block is in the Control Menu.

Page 23: Create an interactive digital product using programming logic

IMPORTING A SPRITE, INTERACTION, CONDITIONAL AND QUESTION BLOCKS, AND TALKING

Continued

Connect the Wait Until block to the show block. Then put the Touching block into the Wait Until block. Put a hide block under them.Connect the Wait Until block to the show block. Then put the Touching block into the Wait Until block. Put a hide block under them.

Using the drop-down menu, change the setting of the block so that it will check if the key is touching catLeft.

By adding these 3 commands, it is like you are saying, “wait until the key is touching the catLeft sprite and then hide the key.”

Page 24: Create an interactive digital product using programming logic

IMPORTING A SPRITE, INTERACTION, CONDITIONAL AND QUESTION BLOCKS, AND TALKING

Continued

You may have noticed that the cat does not pick up the key when the cat is facing right. You may have noticed that the cat does not pick up the key when the cat is facing right. That is because you never told it to. In order to do that, you have to ask if the key is That is because you never told it to. In order to do that, you have to ask if the key is touching either catLeft or catRight. That way, if the key is touching either one, then it touching either catLeft or catRight. That way, if the key is touching either one, then it will hide. will hide.

Notice that right now you cannot put both questions into the Wait Until block at the Notice that right now you cannot put both questions into the Wait Until block at the same time. In order to put both in there, you have to say: same time. In order to put both in there, you have to say:

Wait Until question 1 is true OR question 2 is true. Wait Until question 1 is true OR question 2 is true.

One way to combine questions, is to put them both into an OR question block. You can One way to combine questions, is to put them both into an OR question block. You can find this block in the Numbers Menufind this block in the Numbers Menu

Page 25: Create an interactive digital product using programming logic

IMPORTING A SPRITE, INTERACTION, CONDITIONAL AND QUESTION BLOCKS, AND TALKING

Continued

To go one step further, you can make the key only hide if it is touching the cat AND the down arrow is pressed. To go one step further, you can make the key only hide if it is touching the cat AND the down arrow is pressed. You’re sure to have played games where in order to pick up an item, you have to press a certain button or key. You’re sure to have played games where in order to pick up an item, you have to press a certain button or key.

To do that, you have to add a ‘Key Pressed’ question block. To do that, you have to add a ‘Key Pressed’ question block.

Finding out whether a key pressed is a sense, just like touching, so you can find it in the Sensing Menu.

Earlier, you combined two questions by using the OR block. They turned into one question. Now you must do it again, but this time, using an AND block.

Wait Until question 1 is true AND question 2 is true.

You want the cat to be touching the key and you want the down arrow to be pressed to signal that the person operating the keyboard wants to pick up the key.

There, you can find the AND block.

Page 26: Create an interactive digital product using programming logic

IMPORTING A SPRITE, INTERACTION, CONDITIONAL AND QUESTION BLOCKS, AND TALKING

Continued

You have to be careful about what order you put the AND & OR blocks. Remember that they You have to be careful about what order you put the AND & OR blocks. Remember that they combine questions. The order of combination is important.combine questions. The order of combination is important.

The top question set is what you want. It means, “is the down arrow pressed and is the key touching the cat?”

The bottom question set is not right. It means, “is the down arrow pressed while the key sprite is touching catLeft or is the key just touching catRight?”

Page 27: Create an interactive digital product using programming logic

IMPORTING A SPRITE, INTERACTION, CONDITIONAL AND QUESTION BLOCKS, AND TALKING

Continued

Working with catLeft scripts:Working with catLeft scripts:

You can also use question blocks to You can also use question blocks to make the cat say somethingmake the cat say something when it is when it is touching the key. touching the key. Another way to use question blocks is to put them into Another way to use question blocks is to put them into If blocksIf blocks. . Using an If block is like saying, “If the question is true then do what is within the Using an If block is like saying, “If the question is true then do what is within the block.” The ‘Wait Until’ block is a lot like an If block. In fact, it is an If block that block.” The ‘Wait Until’ block is a lot like an If block. In fact, it is an If block that just sits around and waits until the question is true. just sits around and waits until the question is true. So, here, you want to say, “If the cat is touching the key then say, ‘I found a key!’” So, here, you want to say, “If the cat is touching the key then say, ‘I found a key!’” You want to say this over and over again though; otherwise it will only be checked You want to say this over and over again though; otherwise it will only be checked once when the Green Flag is clicked. The Forever If block checks if the condition once when the Green Flag is clicked. The Forever If block checks if the condition is true forever.is true forever. The Forever If block is found in the Control Menu.The Forever If block is found in the Control Menu.

Put a When Green Flag Clicked start block into the script window underneath the walking scripts.

Connect a Forever If block to that.

Put a Touching block into the Forever If block. Change the value of this to “key.”

Page 28: Create an interactive digital product using programming logic

IMPORTING A SPRITE, INTERACTION, CONDITIONAL AND QUESTION BLOCKS, AND TALKING

Continued

Find the Say __ For __ Seconds block in the Looks Menu. Find the Say __ For __ Seconds block in the Looks Menu.

Put it in the Forever If block.

Find the Think __ For __ Seconds block.

Put it in the Forever If block. Change what the cat thinks and says.

Page 29: Create an interactive digital product using programming logic

IMPORTING A SPRITE, INTERACTION, CONDITIONAL AND QUESTION BLOCKS, AND TALKING

Continued

You can copy a list of blocks to another sprite by clicking on the top block and dragging it to You can copy a list of blocks to another sprite by clicking on the top block and dragging it to that sprite. that sprite.

Click the top Green Flag Block and drag it to the other cat sprite. This will copy it there. Click the top Green Flag Block and drag it to the other cat sprite. This will copy it there.

Page 30: Create an interactive digital product using programming logic

IMPORTING A SPRITE, INTERACTION, CONDITIONAL AND QUESTION BLOCKS, AND TALKING

Continued

You could have used the Wait Until block again to make this happen, but here, it is not the best choice. When you use the wait until You could have used the Wait Until block again to make this happen, but here, it is not the best choice. When you use the wait until block, the script underneath it will only happen once. What if the user doesn’t read fast enough then they will not know what to do. block, the script underneath it will only happen once. What if the user doesn’t read fast enough then they will not know what to do.

Save your programSave your program as “Lesson 2” in your “Lesson” folder. as “Lesson 2” in your “Lesson” folder.

Things To Remember

Use AND blocks when you have two question that both need to be true. Use OR blocks when you only need one of two questions to be true. The order that you combine questions does make a difference. There are many different ways to do the same thing. forever if {commands}=forever

{ wait until {commands} }=forever { if {commands} } You can copy a list of commands to another sprite by dragging them to the sprites icon

in the bottom right part of the window.

Page 31: Create an interactive digital product using programming logic

ADD A BACKGROUND – REPEAT BLOCKS – EXPORT A SPRITE Open up the file you saved from Lesson 1. Open up the file you saved from Lesson 1.

Changing the Background:Changing the Background:Isn’t that white background getting boring? It is really easy to change. In Scratch, the Isn’t that white background getting boring? It is really easy to change. In Scratch, the

background is actually called the Stage. It works a lot like a sprite because it can have background is actually called the Stage. It works a lot like a sprite because it can have costumes and scripts too. costumes and scripts too.

To edit the Stage, select it from where you normally select different sprites.To edit the Stage, select it from where you normally select different sprites.

Page 32: Create an interactive digital product using programming logic

ADD A BACKGROUND – REPEAT BLOCKS – EXPORT A SPRITEContinued

Click the Background tab (where the Costume Tab is normally) to see the backgrounds.Click the Background tab (where the Costume Tab is normally) to see the backgrounds.

You can draw your own background or import one that is already made. Right now, just import one. Click the Import Button. A window will pop up that will allow you to choose a background. Navigate to the “Indoor” folder and then find “room2.”Now that you added a background, it is time to make the cat jump.

Page 33: Create an interactive digital product using programming logic

ADD A BACKGROUND – REPEAT BLOCKS – EXPORT A SPRITEContinued

Working with catRight scripts:

First, add a When Key Pressed block to the scripts catRight.

Change it to “up arrow.”

To make it look like the cat is jumping, you need to make the cat move up and then down. You can do that by changing the “y position”. Changing the Y position moves a sprite up or down.

Find the ‘Change Y By’ block in the Motions Menu.

A good amount to have the cat jump is 100. There are a lot of ways to do that. Some ways will look different than others. If you move the cat up 100 just one time then back down 100 then it will look like the cat is warping. If you move the cat up by 25 for four times, then it will still look choppy or laggy. The key to smooth motion is to make a lot of small steps. However, there is no need to make more steps than you need to make a movement look smooth.

Page 34: Create an interactive digital product using programming logic

ADD A BACKGROUND – REPEAT BLOCKS – EXPORT A SPRITEContinued

You can change the Y more than once an easy way or a hard way.

Both of these scripts move the sprite 100 pixels up. Using a repeat block is much simpler and easy to change later if you need to.

Page 35: Create an interactive digital product using programming logic

ADD A BACKGROUND – REPEAT BLOCKS – EXPORT A SPRITEContinued

Find the Repeat block in the Control Menu.

Put the Change Y By block into the repeat block.

Copy that and change the value in the Change Y Block to “-10” to make the sprite move down 100 pixels so it will be back where it started.

Attach those blocks to the When Key Pressed block.

Remember that the cat has 2 sprites: one for facing left and one for facing right. Like in the previous lessons, you have to click the top block in your list and drag it to the other cat sprite to copy it there. Copy the jump script into catLeft.

Page 36: Create an interactive digital product using programming logic

ADD A BACKGROUND – REPEAT BLOCKS – EXPORT A SPRITEContinued

Duration of jump ÷ # steps = wait time      0.5 seconds ÷ 20 steps = 0.025 seconds per step                          (10 up, 10 down) Once you are satisfied with how the cat jumps, save your program as “Lesson 3” in your “Lesson” folder.

Page 37: Create an interactive digital product using programming logic

ADD A BACKGROUND – REPEAT BLOCKS – EXPORT A SPRITEContinued

Make the cat jump to get the key: Make the cat jump to get the key: You already made a key sprite that hides. It is in Lesson 2 program file. Open up your program from Lesson 2 (make sure you save what you have started for lesson 3). You already made a key sprite that hides. It is in Lesson 2 program file. Open up your program from Lesson 2 (make sure you save what you have started for lesson 3).

You can export sprites in Scratch. Exporting a sprite is useful because you can then import it into a different Scratch program. Once you have lesson 2 open, right click (control click for Mac) You can export sprites in Scratch. Exporting a sprite is useful because you can then import it into a different Scratch program. Once you have lesson 2 open, right click (control click for Mac) the key sprite and click export. You can also export a sprite by clicking the export button next to its name near the top center of the window.the key sprite and click export. You can also export a sprite by clicking the export button next to its name near the top center of the window.

Export it as “hiding key” to a new folder, “lesson sprites”. Now open up your Lesson 3 program again.

You can import the sprite you just exported just like you would any other sprite. Click the Import New Sprite Button.

Page 38: Create an interactive digital product using programming logic

ADD A BACKGROUND – REPEAT BLOCKS – EXPORT A SPRITEContinued

Import “hiding key.” Move the key sprite to the top shelf in your background by dragging it there.

In Lesson 2, you had the key disappear when the cat was touching it AND when the down arrow was pressed. It is not necessary to press the down arrow in this case, so you need to take that part out of the Key scripts.

Now you should be able to have the cat jump up and grab the key. Save your program as “Lesson 3” in your “Lesson” folder.

Page 39: Create an interactive digital product using programming logic

ADD A BACKGROUND – REPEAT BLOCKS – EXPORT A SPRITEContinued

Things To Remember Things To Remember

In Scratch, the background is actually called the Stage. It works a lot like a sprite because it In Scratch, the background is actually called the Stage. It works a lot like a sprite because it can have costumes and scripts too. To edit the Stage, select it from where you normally can have costumes and scripts too. To edit the Stage, select it from where you normally select different sprites. Click the Background tab (where the Costume Tab is normally) to select different sprites. Click the Background tab (where the Costume Tab is normally) to see the backgrounds. see the backgrounds.

There are a lot of ways to move a sprite. Some ways will look different than others. If you There are a lot of ways to move a sprite. Some ways will look different than others. If you move a sprite 100 just one time then it will look like the sprite is warping. If you move the move a sprite 100 just one time then it will look like the sprite is warping. If you move the sprite by 25 for four times, then it will still look choppy or laggy. The key to smooth motion sprite by 25 for four times, then it will still look choppy or laggy. The key to smooth motion is to make a lot of small steps. However, there is no need to make more steps than you need is to make a lot of small steps. However, there is no need to make more steps than you need to make a movement look smooth. to make a movement look smooth.

If a sprite is moving too fast, you should add a Wait block in between movements. If a sprite If a sprite is moving too fast, you should add a Wait block in between movements. If a sprite is then moving too slow, then you are waiting too long. To be sure of the right time, you can is then moving too slow, then you are waiting too long. To be sure of the right time, you can always use the following formula:always use the following formula:

– Duration of movement ÷ # steps = wait time Duration of movement ÷ # steps = wait time

You can export sprites in Scratch. Exporting a sprite is useful because you can then import it You can export sprites in Scratch. Exporting a sprite is useful because you can then import it into a different Scratch program. Right click (control click for Mac) the sprite button under into a different Scratch program. Right click (control click for Mac) the sprite button under the World Preview Window and click export. You can also export a sprite by clicking the the World Preview Window and click export. You can also export a sprite by clicking the export button next to its name near the top center of the window. export button next to its name near the top center of the window.

Page 40: Create an interactive digital product using programming logic

VARIABLES Open up the file you saved from Lesson 3.

Now that you know how to make the cat be able to pick up a key, you can make the cat use the key for something.

In this lesson you will learn how to make the key activate a robot.

Import a pre-made robot sprite by first clicking the import button. Find it by looking in the “Fantasy” folder. It is called “robot3.”

Place the robot sprite on the right side of the world where the cat will be able to walk to it.

Page 41: Create an interactive digital product using programming logic

VARIABLES Continued

To recap, the cat can get the key and you want to robot to do something when the cat walks up to the robot with the key. The first thing you need to do is somehow be able to tell whether or not the cat has the key or not. To recap, the cat can get the key and you want to robot to do something when the cat walks up to the robot with the key. The first thing you need to do is somehow be able to tell whether or not the cat has the key or not.

In order to do this, you need something that can hold onto information for you so you can ask for the information later. Variables hold information. In order to do this, you need something that can hold onto information for you so you can ask for the information later. Variables hold information.

To create a variable, you must first click the variables button in the Top Left Menu. Then click “Make a Variable.”To create a variable, you must first click the variables button in the Top Left Menu. Then click “Make a Variable.”

Always name a variable after what it is used for. So for this one, you should name it “has key?” because you want to use it to be able to tell whether or not the cat has the key or not.

When you make variables, you want to ask yourself, “what sprites need to use the variable?” If the variable is only going to be used by one sprite, then you mark “for this sprite only” when you make it.

Page 42: Create an interactive digital product using programming logic

VARIABLES Continued

If the variable needs to be used by more than one sprite, then you mark “for all sprites” when you make it.

This variable will be used by all sprites.

In Scratch, variables hold numbers. So you can set the variable to “0” when the cat does not have the key and set it to “1” when the cat has the key.

When the green flag is clicked, the cat will start out not having the key, so you will have to set the variable to “0” right away.

Add a When Green Flag Clicked block to the robot’s script. To set the variable, add a “set has key? to []” block and set it to “0.”

Page 43: Create an interactive digital product using programming logic

VARIABLES Continued

Navigate to the Key script and find the where the key hides when the cat touches it. Under that, you can add another “set has key? to []” block and set it to “1.”

Now you can use the variable to find out if the cat has the key. Now use can have the robot do something if the cat walks up to it with the key.

In the robot script, add another When Green Flag Clicked block. You will want to always check if the cat is touching the robot. You will also always want to check if the cat has the key or not. You can do both of these checks will a Forever If block.

The “has key?” variable can be accessed by putting it where a number would usually go. To check if the cat has the key, you can ask if it is equal to “1.” The ‘is equals’ question block can be found in the Numbers Menu.

Page 44: Create an interactive digital product using programming logic

VARIABLES Continued

Now whenever the cat is touching the robot and has the key, whatever is in the Forever If Now whenever the cat is touching the robot and has the key, whatever is in the Forever If block will be carried out. For this lesson you can just make the robot shift back and forth like block will be carried out. For this lesson you can just make the robot shift back and forth like it is turned on. All you have to do is have it move to the right and back to the left. You will it is turned on. All you have to do is have it move to the right and back to the left. You will want to add a pause (wait block) after each movement though. The pause will allow you to see want to add a pause (wait block) after each movement though. The pause will allow you to see the movements. Otherwise the robot will move so fast that it will look like it is standing still. the movements. Otherwise the robot will move so fast that it will look like it is standing still.

Save your program as “Lesson 4” in your “Lesson” folder.

Page 45: Create an interactive digital product using programming logic

VARIABLES Continued

Things To Remember Things To Remember In Scratch, variables hold numbers. In Scratch, variables hold numbers.

To create a variable, you must first click the variables button in the Top Left Menu. Then click “Make a Variable”. To create a variable, you must first click the variables button in the Top Left Menu. Then click “Make a Variable”.

Always name a variable after what it is used for. When you make variables, you want to ask yourself, “what sprites need to Always name a variable after what it is used for. When you make variables, you want to ask yourself, “what sprites need to use the variable?” If the variable is only going to be used by one sprite, then you mark “for this sprite only” when you make it.use the variable?” If the variable is only going to be used by one sprite, then you mark “for this sprite only” when you make it.

Variable can be used to keep track of answers to questions too. You can just assign answers to certain numbers. For example: Variable can be used to keep track of answers to questions too. You can just assign answers to certain numbers. For example: one (1) can be used for ‘yes’ and zero (0) can be used for ‘no.”one (1) can be used for ‘yes’ and zero (0) can be used for ‘no.”

Page 46: Create an interactive digital product using programming logic

PRACTICE WITH VARIABLES, MOTION, PRACTICE WITH VARIABLES, MOTION, LOOKS, AND INTERACTIONLOOKS, AND INTERACTION

Open up the file you saved from Open up the file you saved from Lesson 1Lesson 1. .

First off, get rid of that bland white background by changing it to the “boardwalk” scene from the First off, get rid of that bland white background by changing it to the “boardwalk” scene from the “Outdoors” folder. (If you don not remember: select the stage sprite, background tab, import…) “Outdoors” folder. (If you don not remember: select the stage sprite, background tab, import…)

You can delete “background1” once you added the “boardwalk background.You can delete “background1” once you added the “boardwalk background.

Page 47: Create an interactive digital product using programming logic

PRACTICE WITH VARIABLES, MOTION, LOOKS, PRACTICE WITH VARIABLES, MOTION, LOOKS, AND INTERACTIONAND INTERACTION

ContinuedContinued

Now you are going to need to reposition the cat sprite on solid ground. Remember to do both Now you are going to need to reposition the cat sprite on solid ground. Remember to do both sprites (catRight and catLeft). sprites (catRight and catLeft).

Import the “fish3” sprite from the “Animals” folder.Import the “fish3” sprite from the “Animals” folder.

Shrink it down to a reasonable size using the shrink tool.

Page 48: Create an interactive digital product using programming logic

PRACTICE WITH VARIABLES, MOTION, LOOKS, AND PRACTICE WITH VARIABLES, MOTION, LOOKS, AND INTERACTIONINTERACTION

ContinuedContinued

So now you have a cat, a fish, and some water. You can make a game out of these things. So now you have a cat, a fish, and some water. You can make a game out of these things. What about if you make the fish jump out of the water and try to make the cat catch it. What about if you make the fish jump out of the water and try to make the cat catch it.

You already know how to move sprites. And you know how to make things disappear when You already know how to move sprites. And you know how to make things disappear when they touch the cat. You can even keep score now that you know how to use variables. they touch the cat. You can even keep score now that you know how to use variables.

The first step is to send the fish to a spot in the water so you can make it look like it is The first step is to send the fish to a spot in the water so you can make it look like it is jumping out. jumping out.

If this is going to be a game, you are going to want to have the fish jump out of the water in If this is going to be a game, you are going to want to have the fish jump out of the water in different places. That means that you have to put different values of X into the Go To block different places. That means that you have to put different values of X into the Go To block every time the fish shows up again. You also know that you are going to have to put the every time the fish shows up again. You also know that you are going to have to put the script to make the fish jump into a repeat block so that is happens more than once. For script to make the fish jump into a repeat block so that is happens more than once. For simplicity, you can put a forever block under a When Green Flag Clicked block. simplicity, you can put a forever block under a When Green Flag Clicked block.

You can You can send the fish sprite directly to a certain spotsend the fish sprite directly to a certain spot by using the Go To block. You can by using the Go To block. You can find it in the Motion Menu.find it in the Motion Menu.

Page 49: Create an interactive digital product using programming logic

PRACTICE WITH VARIABLES, MOTION, LOOKS, AND PRACTICE WITH VARIABLES, MOTION, LOOKS, AND INTERACTIONINTERACTION

ContinuedContinued

How do you find out where to put the fish? You are going to want the fish to jump out of the water in different places. That means that the X position will have to be different every time. Since you need different numbers within a certain range, you can use the “pick random #” block. This block is used to pick random numbers in between the numbers you give it. You can find it in the Numbers menu.

To find out what numbers to pick in between, you have to find the farthest X position to the left and the right that you want the fish to go. For example, if you leave the numbers at 1 and 10, then the fish will only be in between 1 and 10. To find the X positions, you can move your mouse over the World Preview Window. The coordinates of where the mouse pointer is will be shown just below and to the right of the World Preview Window. The center of the world is at (0,0).

Page 50: Create an interactive digital product using programming logic

PRACTICE WITH VARIABLES, MOTION, LOOKS, AND PRACTICE WITH VARIABLES, MOTION, LOOKS, AND INTERACTIONINTERACTION

ContinuedContinuedYou are going to have to find the Y position now. The Y position will be the height of where the fish jumps out of the water. It will be the same every time, so you do not have to use random numbers and you can just enter that number directly into the “go to” block. You can test is by double clicking the block.

Fish cannot jump out the water sideways, so why don’t you make it look up when it is coming out the water… Find the Point in Direction block located in the Motion menu.

Page 51: Create an interactive digital product using programming logic

PRACTICE WITH VARIABLES, MOTION, LOOKS, AND PRACTICE WITH VARIABLES, MOTION, LOOKS, AND INTERACTIONINTERACTION

ContinuedContinuedYou are going to be showing and hiding the fish, so it would be a good idea to You are going to be showing and hiding the fish, so it would be a good idea to make sure the fish is showingmake sure the fish is showing right now because it is about to jump out of the water. right now because it is about to jump out of the water.

Now that the fish is in its starting position and facing the right way, you can make it jump to the top of the screen. To do this, Now that the fish is in its starting position and facing the right way, you can make it jump to the top of the screen. To do this, keep changing the Y position until it is greater than the highest Y valuekeep changing the Y position until it is greater than the highest Y value . Find the highest Y value of . Find the highest Y value of the World Preview Window. You can use the Repeat Until block make the fish move up until it is past that number. Find it in the Controls menu. The “Greater Than” (>) block is in the Numbers menu. You can access the Y the World Preview Window. You can use the Repeat Until block make the fish move up until it is past that number. Find it in the Controls menu. The “Greater Than” (>) block is in the Numbers menu. You can access the Y position of a sprite by using the number block called “Y position” in the Motion menu. It is a variable and changes when the sprite moves in Y direction. position of a sprite by using the number block called “Y position” in the Motion menu. It is a variable and changes when the sprite moves in Y direction.

Just like when you made the cat move, you need to add a wait block when the fish moves. If you don’t do this, the fish will move way too fast and the game will be too hard.Just like when you made the cat move, you need to add a wait block when the fish moves. If you don’t do this, the fish will move way too fast and the game will be too hard.

Page 52: Create an interactive digital product using programming logic

PRACTICE WITH VARIABLES, MOTION, LOOKS, AND PRACTICE WITH VARIABLES, MOTION, LOOKS, AND INTERACTIONINTERACTION

ContinuedContinued

The fish will need to move down just the opposite as it moves up. You can copy the script that The fish will need to move down just the opposite as it moves up. You can copy the script that moves it up and reverse it.moves it up and reverse it.

Page 53: Create an interactive digital product using programming logic

PRACTICE WITH VARIABLES, MOTION, LOOKS, AND PRACTICE WITH VARIABLES, MOTION, LOOKS, AND INTERACTIONINTERACTION

ContinuedContinued

You need to point the fish down, change Y by “-10” and have it repeat until the Y position is Less Than the lowest Y value.

There is a trick to quickly change between less than, greater than, and equals. You can right click (control click for Mac) the colored part of the block to get a dropdown menu.

Page 54: Create an interactive digital product using programming logic

PRACTICE WITH VARIABLES, MOTION, LOOKS, AND PRACTICE WITH VARIABLES, MOTION, LOOKS, AND INTERACTIONINTERACTION

ContinuedContinued

The fish doesn’t really look like its jumping from the water to the ground though. You can The fish doesn’t really look like its jumping from the water to the ground though. You can make it make it look more realistic by changing the size of the fishlook more realistic by changing the size of the fish. It will look more real if the fish is smaller as . It will look more real if the fish is smaller as it jumps out of the water and bigger when it is falling to the ground. That will make it look like it it jumps out of the water and bigger when it is falling to the ground. That will make it look like it is coming at you. is coming at you.

It is really easy to change the size of a sprite. Find the Set Size To % block in the Looks menu.It is really easy to change the size of a sprite. Find the Set Size To % block in the Looks menu.

Set the size before the fish starts moving up and again before the fish starts moving down.

The percentage for the larger size will already show up in the “set size to %” block. You should place that first by putting it right before the scripts that start moving the fish down.

To find the percentage for the smaller size, shrink down the fish so that it looks like it is near the water. Now click the arrow from the world tools and then double click the fish. That will refresh the values in the script menu. The “set size to %” block will now have the percentage for the smaller fish.

Page 55: Create an interactive digital product using programming logic

PRACTICE WITH VARIABLES, MOTION, LOOKS, AND PRACTICE WITH VARIABLES, MOTION, LOOKS, AND INTERACTIONINTERACTION

ContinuedContinued

It still looks a little off, doesn’t it? Maybe it would look better if you add a pause in between when it gets to the top and when it comes down. If you do this though, you’re going to need to hide the fish as soon as it reaches the top and show it again when it starts coming down. Otherwise the fish will pause where you can still see it.

That looks much better. Now that the fish looks right, you can have it interact with the cat. You need to stop the fish and hide it if it touches the cat on the way down. Right now, on the way down, it keeps going unless it reaches the bottom.

You need to add, “if it is touching the cat.”

Page 56: Create an interactive digital product using programming logic

PRACTICE WITH VARIABLES, MOTION, LOOKS, AND PRACTICE WITH VARIABLES, MOTION, LOOKS, AND INTERACTIONINTERACTION

ContinuedContinued

So now the fish will stop either when it gets to the bottom of the screen or when it touches the So now the fish will stop either when it gets to the bottom of the screen or when it touches the cat. You can use this information to keep score. If the fish is touching the cat, that means it cat. You can use this information to keep score. If the fish is touching the cat, that means it caught it and you should increase the score. Otherwise, if the fish is not touching the cat then caught it and you should increase the score. Otherwise, if the fish is not touching the cat then it was missed and the score should be decreased. it was missed and the score should be decreased.

Find the If Else block in the Control menu. Add the condition “if touching the cat.”Find the If Else block in the Control menu. Add the condition “if touching the cat.”

Make a new variable called “score.” Instead of setting the variable to a certain value, you Make a new variable called “score.” Instead of setting the variable to a certain value, you can just add or subtract to the value it already has. can just add or subtract to the value it already has.

To do that you use the “Change score By” block. It alters a variable that you made, so it will To do that you use the “Change score By” block. It alters a variable that you made, so it will be in the variables menu. be in the variables menu. Put one of these blocks in both the If and Else openings. Change Put one of these blocks in both the If and Else openings. Change it to “-1” for the else. it to “-1” for the else.

Page 57: Create an interactive digital product using programming logic

PRACTICE WITH VARIABLES, MOTION, LOOKS, AND PRACTICE WITH VARIABLES, MOTION, LOOKS, AND INTERACTIONINTERACTION

ContinuedContinued

When you use a “Change variable By” block, a positive number will add that number to the When you use a “Change variable By” block, a positive number will add that number to the variable. A negative number will subtract that number from the variable. You can also think of variable. A negative number will subtract that number from the variable. You can also think of it as a positive (+) number increases the variable and a negative (-) number decreases it. it as a positive (+) number increases the variable and a negative (-) number decreases it.

You should always have a score reset when the Green Flag is clicked. If you do not, then You should always have a score reset when the Green Flag is clicked. If you do not, then when you start a new game, you will still have the score from the last game. when you start a new game, you will still have the score from the last game. Add a When Add a When Green Flag Clicked block with “Set score to 0” block underneath itGreen Flag Clicked block with “Set score to 0” block underneath it . An alternative way to . An alternative way to reset the score each time would be to place the “Set score to 0” block above the Forever block reset the score each time would be to place the “Set score to 0” block above the Forever block in the script you already have.in the script you already have.

Save your program as “Lesson 5” in your “Lesson” folder.

Page 58: Create an interactive digital product using programming logic

PRACTICE WITH VARIABLES, MOTION, LOOKS, AND PRACTICE WITH VARIABLES, MOTION, LOOKS, AND INTERACTIONINTERACTION

ContinuedContinuedThings To Remember Things To Remember

The “Pick Random Number” block is used to pick a random number in between the numbers The “Pick Random Number” block is used to pick a random number in between the numbers you give it. You can find it in the Numbers menu. you give it. You can find it in the Numbers menu. To find the X positions, you can move your mouse over the World Preview Window. The To find the X positions, you can move your mouse over the World Preview Window. The coordinates of where the mouse pointer is will be shown just below and to the right of the coordinates of where the mouse pointer is will be shown just below and to the right of the World Preview Window. The center of the world is at (0,0). World Preview Window. The center of the world is at (0,0). Changing the size of a sprite can make it seem closer or farther away. Changing the size of a sprite can make it seem closer or farther away. It is really easy to change the size of a sprite. You can use the Shrink and Enlarge World It is really easy to change the size of a sprite. You can use the Shrink and Enlarge World Tools. You can also do it using the “Set Size To %” block or the “Change Size By” block in Tools. You can also do it using the “Set Size To %” block or the “Change Size By” block in the Looks menu. the Looks menu. There is a trick to quickly change between less than, greater than, and equals. You can right There is a trick to quickly change between less than, greater than, and equals. You can right click (control click for Mac) the colored part of the block to get a dropdown menu. click (control click for Mac) the colored part of the block to get a dropdown menu. When you use a “Change By” block, a positive number will add that number to the variable. A When you use a “Change By” block, a positive number will add that number to the variable. A negative number will subtract that number from the variable. You can also think of it as a negative number will subtract that number from the variable. You can also think of it as a positive (+) number increases the variable and a negative (-) number decreases it. positive (+) number increases the variable and a negative (-) number decreases it. You should always have a score reset when the Green Flag is clicked. If you do not, then You should always have a score reset when the Green Flag is clicked. If you do not, then when you start a new game, you will still have the score from the last game. when you start a new game, you will still have the score from the last game. To move a sprite out of the screen, you have to repeatedly move the sprite to towards an edge To move a sprite out of the screen, you have to repeatedly move the sprite to towards an edge until it reaches the edge (position > edge for top and right) (position < edge for bottom and until it reaches the edge (position > edge for top and right) (position < edge for bottom and left). Then you have to hide it once it gets there. left). Then you have to hide it once it gets there.

Page 59: Create an interactive digital product using programming logic

TURN TWO CAT SPRITES INTO JUST ONETURN TWO CAT SPRITES INTO JUST ONE Open up the file you saved from Open up the file you saved from Lesson 5Lesson 5. .

Right now your cat is two sprites. That makes it hard to move it around because you need to Right now your cat is two sprites. That makes it hard to move it around because you need to move both at the same time. It is not very hard to turn those two sprites into one. Things will move both at the same time. It is not very hard to turn those two sprites into one. Things will be less complicated from now on when you deal with the cat sprite. be less complicated from now on when you deal with the cat sprite.

The first thing you need to do is make 4 costumes in 1 sprite. This is possible by choosing The first thing you need to do is make 4 costumes in 1 sprite. This is possible by choosing either cat sprite, but this lesson explains how to do this by choosing the “catRight” sprite. either cat sprite, but this lesson explains how to do this by choosing the “catRight” sprite.

Delete the catLeft sprite. Now rename the catRight sprite to just “cat”. You will need to make Delete the catLeft sprite. Now rename the catRight sprite to just “cat”. You will need to make new costumes for facing the other direction. You learned how to flip sprites around in Lesson new costumes for facing the other direction. You learned how to flip sprites around in Lesson 1. To make the new sprites, you can copy the ones that are already there then flip them around 1. To make the new sprites, you can copy the ones that are already there then flip them around to face the other direction. How to do this was explained in Lesson 1. They can keep their to face the other direction. How to do this was explained in Lesson 1. They can keep their names. names.

Now you should have 4 costumes for the cat sprite: 2 facing right and 2 facing left. How do Now you should have 4 costumes for the cat sprite: 2 facing right and 2 facing left. How do you know when to ask the cat to switch into which costume? Well, you can worry about that in you know when to ask the cat to switch into which costume? Well, you can worry about that in a little while. The first thing you need to do is delete all of the script in the cat sprite by a little while. The first thing you need to do is delete all of the script in the cat sprite by dragging it over to the menu area.dragging it over to the menu area.

Page 60: Create an interactive digital product using programming logic

TURN TWO CAT SPRITES INTO JUST ONETURN TWO CAT SPRITES INTO JUST ONE ContinuedContinued

Starting again from scratch, you know that you need to ask when keys are being pressed. You Starting again from scratch, you know that you need to ask when keys are being pressed. You can try a different way this time. But you need to ask over and over again like you did when can try a different way this time. But you need to ask over and over again like you did when you were asking if the fish was touching the cat. You also did the same thing when you asked you were asking if the fish was touching the cat. You also did the same thing when you asked if the cat was touching the robot. Now you can do it again by asking if a key is being pressed. if the cat was touching the robot. Now you can do it again by asking if a key is being pressed.

Add a Green Flag Clicked block. Now you need to do something over and over again when a Add a Green Flag Clicked block. Now you need to do something over and over again when a question is true, so add a Forever If block. Forever if what? Forever, if a key is pressed. You question is true, so add a Forever If block. Forever if what? Forever, if a key is pressed. You can find the Key [] Pressed block in the Sensing Menu. can find the Key [] Pressed block in the Sensing Menu.

So what do you want to do when the key is pressed? Well, you need to switch costumes and So what do you want to do when the key is pressed? Well, you need to switch costumes and move the cat. One good thing is that you will not have to show or hide any cat sprites because move the cat. One good thing is that you will not have to show or hide any cat sprites because now there is only one. You are probably wondering how you can tell which costume to switch now there is only one. You are probably wondering how you can tell which costume to switch to. If you know which costume the cat is wearing then you can figure out which one to switch to. If you know which costume the cat is wearing then you can figure out which one to switch it to. it to.

Variables are used to keep track of things. Make a new variable called “which costume?”Variables are used to keep track of things. Make a new variable called “which costume?”

Whenever you switch to a different costume, make sure you also set the “which Whenever you switch to a different costume, make sure you also set the “which costume?” variable.costume?” variable.

Page 61: Create an interactive digital product using programming logic

TURN TWO CAT SPRITES INTO JUST ONETURN TWO CAT SPRITES INTO JUST ONE ContinuedContinued

It can help to draw out what you know and what you want to know. It can help to draw out what you know and what you want to know.

Wearing 1Wearing 1

Wearing 2Wearing 2

Wearing 3Wearing 3

Wearing 4Wearing 4

Right Arrow PressedRight Arrow Pressed

Switch to 2Switch to 2

Switch to 1Switch to 1

Switch to 1Switch to 1

Switch to 1Switch to 1

That sure helps. Now you can see that when the right arrow is pressed, then you need to switch the That sure helps. Now you can see that when the right arrow is pressed, then you need to switch the costume to 1 unless it is already 1. If it is already 1 then you need to switch it to 2. costume to 1 unless it is already 1. If it is already 1 then you need to switch it to 2.

Now, in the Forever If right key pressed block, you can say, “if ‘which costume?’ is 1 then switch it Now, in the Forever If right key pressed block, you can say, “if ‘which costume?’ is 1 then switch it to 2, otherwise (else) change it to 1.” Remember that once you switch the costume, you need to set to 2, otherwise (else) change it to 1.” Remember that once you switch the costume, you need to set the “which costume?” variable to whichever costume you just switched to.the “which costume?” variable to whichever costume you just switched to.

Page 62: Create an interactive digital product using programming logic

TURN TWO CAT SPRITES INTO JUST ONETURN TWO CAT SPRITES INTO JUST ONE ContinuedContinued

Remember that drawing out a problem helps figure it out. See how you can do something very similar for facing left as you did for facing right. Remember that drawing out a problem helps figure it out. See how you can do something very similar for facing left as you did for facing right.

Wearing 1Wearing 1Wearing 2Wearing 2Wearing 3Wearing 3Wearing 4Wearing 4Left Arrow PressedLeft Arrow PressedSwitch to 3Switch to 3Switch to 3Switch to 3Switch to 4Switch to 4Switch to 3Switch to 3

Now you can see that when the left arrow is pressed, then you need to switch the costume to 3 unless it is already 3. If it is already 3 then you need to switch it to 4. Instead dragging the same blocks into the Now you can see that when the left arrow is pressed, then you need to switch the costume to 3 unless it is already 3. If it is already 3 then you need to switch it to 4. Instead dragging the same blocks into the script block menu as you just did, you can just copy the whole script from the Green Flag Clicked block down. Now all you have to do is change values. Just change everything from right to left. Easy, huh? script block menu as you just did, you can just copy the whole script from the Green Flag Clicked block down. Now all you have to do is change values. Just change everything from right to left. Easy, huh?

You can also set which costume the cat is wearing when the Green Flag is clicked. It can just be costume 1. So add another Green Flag Clicked block. Add a “Switch to Costume 1” block underneath that. You can also set which costume the cat is wearing when the Green Flag is clicked. It can just be costume 1. So add another Green Flag Clicked block. Add a “Switch to Costume 1” block underneath that. Then set the “which costume?” variable to “1.”Then set the “which costume?” variable to “1.”

Page 63: Create an interactive digital product using programming logic

TURN TWO CAT SPRITES INTO JUST ONETURN TWO CAT SPRITES INTO JUST ONE ContinuedContinued

The cat doesn’t move yet. Add those commands now by putting a ‘move steps’ block and The cat doesn’t move yet. Add those commands now by putting a ‘move steps’ block and ‘wait’ block under the If Else blocks. ‘wait’ block under the If Else blocks.

Do you remember how you sensed if the cat was touching the fish in the last lesson? Do you remember how you sensed if the cat was touching the fish in the last lesson?

Now you don’t need to ask if the fish is touching either sprite. You can take one of those out Now you don’t need to ask if the fish is touching either sprite. You can take one of those out and make sure it reads only “cat.”and make sure it reads only “cat.”

Adding Jump

Now that the cat is only one sprite, you can more easily make it do other things too. It would be handy for the cat to be able to jump. You can make it jump when the space bar is pressed. The height of the jump is up to you. Use whatever amount looks good. Remember that you want to repeat moving up then repeat moving down the same amount.

Page 64: Create an interactive digital product using programming logic

TURN TWO CAT SPRITES INTO JUST ONETURN TWO CAT SPRITES INTO JUST ONE ContinuedContinued

The cat looks a little funny when it runs in the air. It would look better if it were not running. The cat looks a little funny when it runs in the air. It would look better if it were not running. That means that you need to only change the costumes if the cat is not jumping. That is That means that you need to only change the costumes if the cat is not jumping. That is another thing to keep track of. another thing to keep track of.

Make variable called “jumping?” It is a variable that only needs to be used by the cat so make Make variable called “jumping?” It is a variable that only needs to be used by the cat so make sure you check “for this sprite only.” You want “jumping?” to be “1” the whole time the cat is sure you check “for this sprite only.” You want “jumping?” to be “1” the whole time the cat is jumping, so set it right before the cat starts jumping. Then when the cat is done, set it back to jumping, so set it right before the cat starts jumping. Then when the cat is done, set it back to “0.” Set those now in your jump script. “0.” Set those now in your jump script.

Now, in both your scripts for moving left and right, put costume switch scripts inside an IF Now, in both your scripts for moving left and right, put costume switch scripts inside an IF block. And you can say, “if the cat is not already jumping then switch costumes.” (if jumping block. And you can say, “if the cat is not already jumping then switch costumes.” (if jumping = 0) = 0)

Now that cat does not switch costumes when it is jumping. It looks better though, when the cat Now that cat does not switch costumes when it is jumping. It looks better though, when the cat is wearing costume 2 or 4, and not 1 or 3. is wearing costume 2 or 4, and not 1 or 3.

Page 65: Create an interactive digital product using programming logic

TURN TWO CAT SPRITES INTO JUST ONETURN TWO CAT SPRITES INTO JUST ONE ContinuedContinued

You can make the cat only wear costumes 2 or 4 when it is jumping.You can make the cat only wear costumes 2 or 4 when it is jumping.

Wearing 1Wearing 2Wearing 3Wearing 4When JumpingLooks funny soSwitch to 2Do nothingLooks funny soSwitch to 4Do nothing

So if the cat is wearing costume 1 then switch it to costume 2. If the cat is wearing costume 3 then switch it to costume 4. You are going to want to do this costume check after you set “jumping?” to “1” and before you start moving the cat.

Make sure it works by testing it out.

Save your program as “Lesson 6” in your “Lesson” folder.

Page 66: Create an interactive digital product using programming logic

TURN TWO CAT SPRITES INTO JUST ONETURN TWO CAT SPRITES INTO JUST ONE ContinuedContinued

Things To Remember Things To Remember

Drawing out a situation can help you figure out what needs to happen and when. Drawing out a situation can help you figure out what needs to happen and when.

When you use a variable to keep track of something, you need to make sure that you set that When you use a variable to keep track of something, you need to make sure that you set that variable to the appropriate value after changing what you are keeping track of. If you do not variable to the appropriate value after changing what you are keeping track of. If you do not then that variable is not keeping track of anything. then that variable is not keeping track of anything.

If you know what costume a sprite is wearing and you know what costume you want it to wear If you know what costume a sprite is wearing and you know what costume you want it to wear then you can always make that happen. Draw out which costume it should be wearing and then you can always make that happen. Draw out which costume it should be wearing and when. You should be able to see some kind of pattern. You might need to keep track of when. You should be able to see some kind of pattern. You might need to keep track of something so that you know when to switch costumes. If you do a good job keeping track then something so that you know when to switch costumes. If you do a good job keeping track then you can ask about it later. you can ask about it later.

Page 67: Create an interactive digital product using programming logic

ADDING ENEMIESADDING ENEMIES

Open up the file you saved from Open up the file you saved from Lesson 6Lesson 6. .

The game is a little easy right now. There is always room to add more things. The game is a little easy right now. There is always room to add more things.

Bouncy Balls.Bouncy Balls.

Go Go herehere and download a pre-made bouncy ball script that is on that page. Import the bouncy and download a pre-made bouncy ball script that is on that page. Import the bouncy ball sprite into your program. ball sprite into your program.

That is cool how you can just import a sprite like that. It actually looks like a bouncy ball. That is cool how you can just import a sprite like that. It actually looks like a bouncy ball. How could you make that useful? How could you make that useful?

What about if you made it into an enemy? You could have the cat’s health go down when you What about if you made it into an enemy? You could have the cat’s health go down when you get accidentally hit. That would make the game more interesting. get accidentally hit. That would make the game more interesting.

Page 68: Create an interactive digital product using programming logic

ADDING ENEMIESADDING ENEMIES ContinuedContinued

You are going to have to change some numbers. There are only two numbers that you have to You are going to have to change some numbers. There are only two numbers that you have to mess with: mess with:

– y start for bouncy ball y start for bouncy ball – how fast it goes up how fast it goes up

The ball bounces from the right to the left. The only way to get around it would be to jump over The ball bounces from the right to the left. The only way to get around it would be to jump over it or go under it. it or go under it. You need to make the ball bounce high or low.You need to make the ball bounce high or low.

If you make the ball go up fast and fall slow then it will bounce high. If you make the ball go up If you make the ball go up fast and fall slow then it will bounce high. If you make the ball go up slow and fall fast, it will bounce low. You are going to want to change the ‘y start’ to the Y slow and fall fast, it will bounce low. You are going to want to change the ‘y start’ to the Y position where the cat’s feet are. That way, it will look like it will actually hit the cat. position where the cat’s feet are. That way, it will look like it will actually hit the cat.

Make sure to hit the Green Flag button again every time you change a number. If you do not, Make sure to hit the Green Flag button again every time you change a number. If you do not, then you will not be able to see the changes. Can you figure out why that is? then you will not be able to see the changes. Can you figure out why that is?

Once you think you made the bouncy ball move so that you can avoid it, double check by playing Once you think you made the bouncy ball move so that you can avoid it, double check by playing it for a little while. it for a little while.

Okay, okay, now you need to make some health so that the cat gets hurt when you get Okay, okay, now you need to make some health so that the cat gets hurt when you get accidentally hit. Make a new variable for all sprites, called “health”. How can you make it go accidentally hit. Make a new variable for all sprites, called “health”. How can you make it go down when the cat gets hit? What should the health start at? How much should the health go down when the cat gets hit? What should the health start at? How much should the health go down each time the cat gets hit? What happens when you die? Hmm… Do not worry about game down each time the cat gets hit? What happens when you die? Hmm… Do not worry about game over yet. That will be covered in the next lesson.over yet. That will be covered in the next lesson.

Page 69: Create an interactive digital product using programming logic

ADDING ENEMIESADDING ENEMIES ContinuedContinued

Okay, okay, now you need to make some health so that the cat gets hurt when you get Okay, okay, now you need to make some health so that the cat gets hurt when you get accidentally hit. Make a new variable for all sprites, called “health”. How can you make it go accidentally hit. Make a new variable for all sprites, called “health”. How can you make it go down when the cat gets hit? What should the health start at? How much should the health go down when the cat gets hit? What should the health start at? How much should the health go down each time the cat gets hit? What happens when you die? Hmm… Do not worry about down each time the cat gets hit? What happens when you die? Hmm… Do not worry about game over yet. That will be covered in the next lesson. game over yet. That will be covered in the next lesson.

For now, you can just make the health change. The first thing you need to think about, is how For now, you can just make the health change. The first thing you need to think about, is how many times you think you should be able to get hit before you die. 10 times? So, why not many times you think you should be able to get hit before you die. 10 times? So, why not make the MAX health, 10. If you do that, you only need to change the health by “-1” each make the MAX health, 10. If you do that, you only need to change the health by “-1” each time the cat gets hit. You also know that your health always start at the MAX. time the cat gets hit. You also know that your health always start at the MAX.

Health should be a variable that is only used by the cat. You will not be able to access that Health should be a variable that is only used by the cat. You will not be able to access that variable from the bouncy ball’s script. variable from the bouncy ball’s script.

Sprites can communicate commands to each other. In Scratch, it is called broadcasting. One Sprites can communicate commands to each other. In Scratch, it is called broadcasting. One sprite broadcasts a signal and then the other sprite hears it and follows the script underneath sprite broadcasts a signal and then the other sprite hears it and follows the script underneath the “When I receive” block. the “When I receive” block.

Page 70: Create an interactive digital product using programming logic

ADDING ENEMIESADDING ENEMIES ContinuedContinued

See See Broadcast and Conversation ExampleBroadcast and Conversation Example. .

So, first, you need to have the balls broadcast a signal when the health needs to change. You So, first, you need to have the balls broadcast a signal when the health needs to change. You can find the broadcasting blocks in the Control Menu. There are “broadcast” and “broadcast can find the broadcasting blocks in the Control Menu. There are “broadcast” and “broadcast and wait” blocks. In this case you do not want to wait for the health to go down, you just want and wait” blocks. In this case you do not want to wait for the health to go down, you just want to say that it should happen. The broadcast should happen when the cat gets hit. Another way to say that it should happen. The broadcast should happen when the cat gets hit. Another way to look at it is: the broadcast should happen when the health needs to go down. If you think to look at it is: the broadcast should happen when the health needs to go down. If you think about it in the later way, you can more easily find the right block to put the “broadcast” block about it in the later way, you can more easily find the right block to put the “broadcast” block underneath.underneath.

In the bouncy ball script, add a “When Green Flag Clicked” start block and check over and over again to see if the ball is touching the cat. If it is, you need to, first, hide the ball, then broadcast, “decrease health” so that the cat can receive “decrease health” and decrease its “health” variable. Then set X to “-250”. This will send the ball to the edge of the screen so that it resets.

In the cat’s script, add a “when I receive ‘decrease health’” start block. Then, underneath that, decrease the ‘health’ variable by adding a “change health by -1” block. You also need to make sure that the health resets to “10” each time the green flag is clicked. Add a “set health to” block under the “when green flag clicked” block that has the costume initialization under it.

Page 71: Create an interactive digital product using programming logic

ADDING ENEMIESADDING ENEMIES ContinuedContinued

Initialization is needed in many cases to set they way things should be at the start of a program. So Initialization is needed in many cases to set they way things should be at the start of a program. So far, in the cat’s script, you should have initialized the cat’s costume and the health. They can be far, in the cat’s script, you should have initialized the cat’s costume and the health. They can be under the same “when green flag clicked” block. In the fish’s script, you should have initialized the under the same “when green flag clicked” block. In the fish’s script, you should have initialized the score. score.

Now you need to be a game tester. Does the health go down like it should? Now you need to be a game tester. Does the health go down like it should?

Now that you made one bouncy ball enemy, why not make another one? Now that you made one bouncy ball enemy, why not make another one?

Use the stamp in the world tools menu to make a copy of the bouncy ball. Rename the both sprites to Use the stamp in the world tools menu to make a copy of the bouncy ball. Rename the both sprites to “high ball” and “low ball”. Now change settings so that you have one bouncy ball bounce high and “high ball” and “low ball”. Now change settings so that you have one bouncy ball bounce high and one that bounces low. The high one should be high enough to walk under and the low one should one that bounces low. The high one should be high enough to walk under and the low one should bounce so that the cat can jump over it. bounce so that the cat can jump over it.

If you want to change how fast the cat moves, you can change the wait time in its scripts.If you want to change how fast the cat moves, you can change the wait time in its scripts.

Page 72: Create an interactive digital product using programming logic

ADDING ENEMIESADDING ENEMIES ContinuedContinued

Have you ever played any games before where your character flashes when it gets hit? You Have you ever played any games before where your character flashes when it gets hit? You can make the cat flash to let you know when you have been hit. Since you want that to happen can make the cat flash to let you know when you have been hit. Since you want that to happen at the same time that the health goes down, you can add it after you decrease the health under at the same time that the health goes down, you can add it after you decrease the health under the “when I receive ‘decrease health’” in the cat’s scripts.the “when I receive ‘decrease health’” in the cat’s scripts.

How can you make the cat flash? You will want to repeatedly hide and show the cat. You will How can you make the cat flash? You will want to repeatedly hide and show the cat. You will want to wait in between though. Make sure that you end up with the cat showing.want to wait in between though. Make sure that you end up with the cat showing.

Save your programSave your program as “Lesson 7” in your “Lesson” folder. as “Lesson 7” in your “Lesson” folder.

Page 73: Create an interactive digital product using programming logic

ADDING ENEMIESADDING ENEMIES ContinuedContinued

Things To Remember Things To Remember

There are a lot of scripts that you can find and import to make your programs more interesting. It can There are a lot of scripts that you can find and import to make your programs more interesting. It can be very helpful to use other peoples’ scripts. Often, you change scripts slightly to adapt them to your be very helpful to use other peoples’ scripts. Often, you change scripts slightly to adapt them to your program. program.

It is very common to need to initialize variables when the program starts. Health and score variables It is very common to need to initialize variables when the program starts. Health and score variables will always need to be initialized. If you don’t do this, the health and score will carry over from the will always need to be initialized. If you don’t do this, the health and score will carry over from the last time you played. last time you played.

Broadcasting is very useful because it allows sprites to communicate to each other. This becomes Broadcasting is very useful because it allows sprites to communicate to each other. This becomes important as your programs utilize more sprites. When one sprite senses something that should make a important as your programs utilize more sprites. When one sprite senses something that should make a different sprite do something, then the first sprite must tell the second sprite about that thing. For different sprite do something, then the first sprite must tell the second sprite about that thing. For example, in this lesson, the ball found out that it was touching the cat. The cat isn’t watching out for example, in this lesson, the ball found out that it was touching the cat. The cat isn’t watching out for that so it needs the bouncy balls to tell it when it gets hurt. So, the bouncy balls need to let the cat that so it needs the bouncy balls to tell it when it gets hurt. So, the bouncy balls need to let the cat know by broadcasting “decrease health”. See know by broadcasting “decrease health”. See Broadcast and Conversation ExampleBroadcast and Conversation Example. .

A program can be greatly improved by adding reactions to actions. In this lesson, you should have A program can be greatly improved by adding reactions to actions. In this lesson, you should have had the cat flash when it got hit by a bouncy ball. By doing this, the program becomes more had the cat flash when it got hit by a bouncy ball. By doing this, the program becomes more interactive and more enjoyable. It also serves as providing incentive so that you do not want to get hit interactive and more enjoyable. It also serves as providing incentive so that you do not want to get hit by the bouncy balls.by the bouncy balls.

Page 74: Create an interactive digital product using programming logic

SOUNDS AND GAME OVERSOUNDS AND GAME OVER Open up the file you saved from Open up the file you saved from Lesson 7Lesson 7. .

In this lesson you will learn about the script blocks in the Sounds Menu. Adding sounds to In this lesson you will learn about the script blocks in the Sounds Menu. Adding sounds to your program can make it seem completely different. Hearing your program react is almost as your program can make it seem completely different. Hearing your program react is almost as good as seeing it. good as seeing it.

Scratch allows you to import sounds and record your own. You can play the sounds by using Scratch allows you to import sounds and record your own. You can play the sounds by using script blocks. That allows you to add sound effects. How do sound effects fit into your script blocks. That allows you to add sound effects. How do sound effects fit into your program? program?

Sound effects notify the person using your program of a key moment by playing a sound. Sound effects notify the person using your program of a key moment by playing a sound. Sounds work a little like costumes. You can add sound clips to sprites. Those sounds will only Sounds work a little like costumes. You can add sound clips to sprites. Those sounds will only work with the sprite you added them to. So if you want the sound to be played by more than work with the sprite you added them to. So if you want the sound to be played by more than one sprite then you have to import them again. one sprite then you have to import them again.

One key moment in your program is when the fish jumps out of the water. This would be a One key moment in your program is when the fish jumps out of the water. This would be a good time to add a sound effect. You could play some sort of splashing noise. good time to add a sound effect. You could play some sort of splashing noise.

Page 75: Create an interactive digital product using programming logic

SOUNDS AND GAME OVERSOUNDS AND GAME OVERContinueContinue

There are many sound clips included with Scratch. You can find a sprite’s sounds by clicking There are many sound clips included with Scratch. You can find a sprite’s sounds by clicking the Sounds tab after selecting a sprite. The Sounds tab is next to the Costumes tab. Importing the Sounds tab after selecting a sprite. The Sounds tab is next to the Costumes tab. Importing sounds is just like importing costumes. (Tip: When you are looking for sounds, you can click sounds is just like importing costumes. (Tip: When you are looking for sounds, you can click once on the sound file to hear a preview of that sound.) once on the sound file to hear a preview of that sound.)

Once you add a sound to a sprite, you can play that sound by using the “play sound” script Once you add a sound to a sprite, you can play that sound by using the “play sound” script block. Put that block in your script so that it will activate at the appropriate time. For the fish block. Put that block in your script so that it will activate at the appropriate time. For the fish jumping sound, you would put the block in the script where the fish begins to jump. jumping sound, you would put the block in the script where the fish begins to jump.

Add sounds for the other key moments in your program. Some key moments in your program Add sounds for the other key moments in your program. Some key moments in your program would be: when the fish jumps out of the water, when the balls bounce, when the cat gets hit, would be: when the fish jumps out of the water, when the balls bounce, when the cat gets hit, and when the cat catches a fish. and when the cat catches a fish.

It is also possible to add background music. Background music is not part of any single sprite. It is also possible to add background music. Background music is not part of any single sprite. It has to do with all the sprites, so you can add the script for it into the Stage scripts. There is a It has to do with all the sprites, so you can add the script for it into the Stage scripts. There is a folder included with Scratch that has music loops. These music loops are made so that they folder included with Scratch that has music loops. These music loops are made so that they can be played over and over again. You will want the sound to stop playing before you start can be played over and over again. You will want the sound to stop playing before you start playing it again. To do that, you can use the “play sound and wait” block. And you will want playing it again. To do that, you can use the “play sound and wait” block. And you will want to repeat that over and over again. to repeat that over and over again.

Page 76: Create an interactive digital product using programming logic

SOUNDS AND GAME OVERSOUNDS AND GAME OVERContinueContinue

Now that you have sound effects, you game is almost over… Game Over. Now that you have sound effects, you game is almost over… Game Over. Well, not yet, not until you make the game over screen. Well, not yet, not until you make the game over screen.

You can cover the whole screen with a sprite. You can also make a sprite You can cover the whole screen with a sprite. You can also make a sprite that reads game over. When the health is zero, then it is game over. So all that reads game over. When the health is zero, then it is game over. So all you need to do to make a Game Over screen is make a new sprite that you need to do to make a Game Over screen is make a new sprite that hides at first and then shows when the health is zero. You can also add a hides at first and then shows when the health is zero. You can also add a sound when this happens.sound when this happens.

Page 77: Create an interactive digital product using programming logic

SourcesSources

http://scratch.mit.edu/http://scratch.mit.edu/

http://www.xilinx.com/company/about/http://www.xilinx.com/company/about/programmable.html programmable.html

Page 78: Create an interactive digital product using programming logic

SUMMARYSUMMARY

THE BEGINNINGTHE BEGINNING

IMPORTING A SPRITE, INTERACTION, CONDITIONAL AND QUESTION IMPORTING A SPRITE, INTERACTION, CONDITIONAL AND QUESTION BLOCKS, AND TALKINGBLOCKS, AND TALKING

ADD A BACKGROUND – REPEAT BLOCKS – EXPORT A SPRITEADD A BACKGROUND – REPEAT BLOCKS – EXPORT A SPRITE

VARIABLESVARIABLES

PRACTICE WITH VARIABLES, MOTION, LOOKS, AND INTERACTIONPRACTICE WITH VARIABLES, MOTION, LOOKS, AND INTERACTION

TURN TWO CAT SPRITES INTO JUST ONETURN TWO CAT SPRITES INTO JUST ONE

ADDING ENEMIESADDING ENEMIES

SOUNDS AND GAME OVERSOUNDS AND GAME OVER

Page 79: Create an interactive digital product using programming logic

QUESTIONS????QUESTIONS????