scratch maze 2015

Report 4 Downloads 37 Views
Scratch Lessons:

Make a Maze Game, Part 1 See these squiggly lines? Anything written inside them gives you helpful tips and information on WHY you are writing the code. If you don’t care, than just follow what’s written and shown in each numbered step. Sooooo what are we doing here? Why are we making a maze game? Welp, this is actually more than just a maze game. It is an OBESITY maze game. Over the next four lessons, you’ll design a maze with a “maze runner”. If the maze runner hits the walls of the maze, an annoying sound will happen and they will have to return back to the beginning. As the maze runner goes from the start of the maze to the end, he/she will be collecting food. Each food gains him/her calories. But *CAREFUL*, you will design the maze so that if you’re runner collects more than 2000 calories, they lose!

1. Go to Scratch.mit.edu. Click “Sign in”.

2. Enter username: techbrarian

Password: Student1

1

3. Click “Create”

4. Name your maze.

5. Press the scissor and then delete the cat.

6. Now your going to choose a new sprite (character) to run your maze. Press the “choose sprite from library ” button.

2

7. Select your sprite and click “ok”.

a

8. Copy the code blocks below so that your sprite moves using the arrow keys.

3

9. Now let’s draw a maze. Start by clicking on “Paint a new Sprite.”

10. Draw a maze using the line tool and the eraser.

4

11. You probably notice that your maze runner is way too big. Click on the shrink tool and make him/her smaller.

*Note: If the maze is getting in the way of shrinking or moving your maze runner, use the arrow keys to move your maze runner away from the maze. 5

12. Take a moment to name your maze runner and your maze. Do this by clicking on the , typing in the name, and then pressing the back arrow . 1

2

3

4

6

5

Should end up looking like this

6

13. Now, let’s record a sound that plays when your maze runner hits the maze by accident. Click “Sounds”. Press the “X” to delete the old sound. 2 1

14. Click “Record new sound.”

15. Click “Allow”.

7

16. Click the record button and make a noise. Press the stop button when you’re done. Name your sound.

3

1

2

17. Next, return back to the Scripts tab. Create a code block that forever looks for something to happen (we’ll see what it’s looking for next.)

18. So here’s what we’re look for: Does the maze runner touch the maze? If it does, then we want it to make our sound happen. Below is the code for this:

8

19. Now press the green flag and try it out!

One more thing... So you know how you wrote this:

You can also write the code so that you forever look to see if your maze runner touches a color. In this case, my maze is black-- so I can look to see if my maze runner touches black. If it does, then I make the sound happen:

9

Scratch Lessons:

Make a Maze Game, Part 2 In this lesson, you’ll learn how to get your maze runner back to the beginning when he/she hits the wall. You’ll also be giving your maze runner a goal to get to: Health. If they reach it, they will win.

1. Go to Scratch.mit.edu. Click “Sign in”.

2. Enter username: techbrarian

3. Go to “My Stuff”

Password: Student1

to get your project.

1

4. Find your project and click “See Inside”

5. Move your maze runner to the start of the maze. Not to get too mathematical on you, but every single part of your maze has an exact x (left to right) and y (up and down) coordinate. Notice that it changes when you move your maze runner in order to show its new x and y-coordinate.

2

6. Now drag the code that makes the maze runner return back to the beginning if it touches the maze. Also, add the code that makes the maze runner return to its starting position when the green flas is clicked (when the game starts over).

7. Now try it out!

3

8. Now let’s create a way to win. Paint a new sprite and use the text tool to write the word “HEALTH”. 1

3 2

9. Name the costume “HEALTH”.

4

10. Click “Paint New Costume”. Use the Text tool to write “YOU WIN”. 1

3

2

11. Change the name of the costume to “YOU WIN”.

5

12. Switch back to “Scripts”. Drag “HEALTH” to the end of the maze.

13. Take a moment to name your sprite “HEALTH”. Do this by clicking on the and then pressing the back arrow .

, typing in the name,

1

2

3 6

14. Now, use the following code to have “YOU WIN” appear when your Maze Runner touches “HEALTH”. The code also has you switch back to “HEALTH” at the start of the game.

*BONUS: See if you can make a sound happen if the maze runner touches “HEALTH”. 7

Scratch Lessons:

Make a Maze Game, Part 3During class we talked about counting caloires.

In general, you should eat no more than 2000 calories each day (for your exact number go to: bit.ly/techbrarian_calorie). There’s more to eating than calories-- like the biggest enemy sugar and your best friend: fiber. But for now, let’s just use the idea of calories for your maze.

1. Start by going to google.com and click on “Images”.

2. Look up an unhealthy food.

3. Drag a picture of the food you want onto the desktop.

1

4. Now, import your unhealthy food as a new sprite.

5. Make sure that “Desktop” is selected. Double-click on your first unhealthy food (BTW, your’s doesn’t have to be a bacon cheeseburger).

6. Use the Eraser Tool to erase the background of your unhealthy food.

2

7. Click on “Scripts”. Shrink the unhealthy food and place it where you want it.

It’s always smart to name your Sprites because it helps make your scripts sound like real sentences. So let’s name your burger.

8.

Click on the burger’s “i”.

9. Name your unhealthy food. Click the arrow to return back.

3

10. Now, click on “Scripts” and in the “Data” section select “Make a Variable”.

A variable is something that changes. Most of the things that you can change in Scratch like your Sprite’s location, color, and the sounds it makes are built into the code blocks that Scratch gives you. But there’s something that changes in your maze game that Scratch doesn’t have in its code blocks: calories. Your maze game is about how the calories you’ve eaten change depending on which foods you touch, right? Well, you’re going to have to create a code block that says that.

11. Call your variable “calories”.

4

12. Now create the following code:

The code says “if your unhealthy food touches the maze runner, than the calories go up by 1.” But my unhealthy food is much more than 1 calorie. So how many calories is my unhealthy food? Let’s look it up online. Remember, my unhealthy food is a bacon cheeseburger, but you pick whatever food you wnat!

13. Go to CalorieKing.com. Search for your unhealthy food.

5

14. Select the unhealthy food that best matches what you were imagining.

15. Memorize the calories and return back to your Scratch maze.

6

16. Change the calories from 1 to the number of calories you found your unhealthy food really had.

17. Lastly, drag code to make the food hide once it’s touched by the maze runner. Though, don’t forget to have it show when the green flag is clicked (when the game starts over).

7

18. Now repeat all the steps until you have at least 5 unhealthy foods and 5 healthy foods.

8

Scratch Lessons:

Make a Maze Game, Part 4In this lesson, you’ll have to do a little MATH!

Don’t be nervous, though. If you’re having trouble understanding it, you can always just copy the code blocks shown in the pictures. The code we’re writing says “if your calories are greater than 2000, tell the game over sprite to appear.”

1. First off, notice that the calories keep adding up, even if you re-start the game. To set the calories back to zero when you start the game, click on your Maze Runner and write the following code:

2. Now, we’re going to create a code block that says: “If calories are greater than 2000...”

1

1

2

3

2

Next we are going to make a broadcast. We haven’t done this before. A broadcast is a message sent from one sprite to another. Think of it like sending a text message to one of your friends telling her what to do. For example, imagine broadcasting a message to your friend to meet at Foot Locker at 3pm...she knows exactly what do once she receives the message. In this case, we are going to create a broadcast that tells the “Game Over” sprite to appear if the Maze Runner eats greater than 2000 calories.

3. Create a “new message” to broadcast.

4. Call it “More than 2000”.

3

5. Drag the message as shown:

6. Now, create a “Game Over” sprite so that it can appear when the maze runner gets greater than 2000 calories. 1

2

4

7. Click on the “Select” tool and then click back on “Game Over”. Drag the corners of “Game Over” to make your words bigger.

8. use the paint bucket to paint the background.

9. Finally, create the code that tells “Game Over” to show itself when it receives the “More than 2000” message. Also, make sure the “Game Over” sprite hides when the game begins again. AND THAT’S IT !

5

Challenge: Teach other about obesity by making your game cooler. Here are two ideas.

1. SUGAR is the enemy of health. It gives us energy, but we eat more than we need, so our body stores it as FAT. We pump out insulin so our bodies can use the sugar we eat. BUT if you eat too much sugar, your insulin pump BREAKS. Your body can’t use the sugar anymore. If this happens, all the sugar floating around can hurt your body. It can make you dizzy, messes up your heart, and can cause your to LOSE body parts. Soooo what about going back to CalorieKing.com and looking up the sugar for each food? As teens, you are allowed to have up to 32 grams of sugar. Like you did with “calories” in Lesson 3, create a new variable called “sugar”. Make the game over if your maze runner eats greater than 32 grams of sugar.

1

2

3

6

2. If sugar is the enemy of healthy, than FIBER is your best friend. Fiber slows sugar from coming out of food so that your body has time to use it (instead of storing it as fat and breaking your insulin pump). Fiber is like a helpful shell around the sugary food. You can find fiber in food like whole wheat bread, brown rice, fruits, and vegetables. Soooo how about making piles of fiber around the maze. If you touch it, calories go down.

7