Escape the Food -Scratch- (Extra)

by -Ecl-pse- in Circuits > Software

297 Views, 1 Favorites, 0 Comments

Escape the Food -Scratch- (Extra)

Escape the food Cover.png

In this step-by-step tutorial, I will show you how YOU can code your very own parrot and donut game. This project is endlessly customisable, as well!

Supplies

None! All you need is a computer.

Getting Into Scratch

First, go to your web browser. Type in "Scratch". The first result that shows up should say, "Scratch - Imagine, Program, Share". Click on it. It will bring you to the homepage, and you will see a few options in the bar at the top of your screen. Click on the "Create" option. After it loads, it will bring you to the coding screen, where code blocks are on the left. You should see a cat on the screen to the right. Delete it by going to the small cat picture below it and click the" trash" icon near it. Finally, scroll your mouse over to the cat icon with a little plus sign above it at the bottom right-hand side of your screen. When you do, a list of four options should show up; click on the magnifying glass icon. This will bring you to the sprite selection page.

Choosing the Characters

escape tyhe food 2.1.png
escape the food cast 1.1.png

Once you are in the sprite selection page, go to the search bar in the top left corner. First, search up "parrot". Choose the parrot sprite shown in the second picture. Next, go back to the sprite selection (where you found the parrot) and search "donut". There is only one donut option, so select that. You should now see both a parrot and a donut character on your side screen.

Adding Backgrounds

Right now, our friends' world is looking a bit empty. Let's choose some backdrops! First, scroll over to the "picture" icon next to the "new sprite" icon. Another pop-up will appear, and you want to click on the "search" icon. In the top selection bar, you'll see some filters for backgrounds. Search for "Blue Sky". I chose "Blue Sky" for the starting background. Once you click on your selection, it should bring you back to the code page and your sprites will now be in a blue sky!

When your done with the starting background, add 2 more backgrounds, using "Colourful City" and "Blue Sky 2" using the same steps above.

Decorating the Background

For "Blue Sky" , add a text stating how to start the game, by pressing the space bar. For "Blue Sky 2" add a little congratulations note and a "to retry:" . (There will be a sprite placed there)

Adding the First Block of Codes for the Parrot

Alright, what you've all been waiting for! (hopefully) On the left-hand side of your screen, there will be a few vertical columns with different options. On the farthest left column, you'll see some different categories of code. Click on the "Events" option in yellow. Once there, you should see a few code blocks. Drag and drop the "When *green flag is pressed" into the Code Area in the middle. Then, go over to the side screen with your sprites and drag the parrot into a position you like. Finally, drag the block that says "go to switch backdrop to ___" to the area immediately below the "when *green flag pressed" block. It should snap into place.

*The green flag is an icon

Adding More Codes for the Parrot

Esape th efood .png

First, go to "motion" in the block selection area. drag the block that says " go to x:__ y:__" and add it to your code chunk. Next, take out the block that says "point in direction __" and place it under "go to x:__ y:__". Afterwards, go back to "looks" and scroll down till you see "hide" add it under the "go to x:__ y:__". Now, go to "control" and take out "forever" and "if __ then". Connect the "if __ then" under the "forever". Connect the loop to your code chunk.

Go to "sensing" and take out the "touching mouse-pointer ?" and switch it to "Donut" ,then put it at the "__" . Go to "looks" and take out "switch backdrop to __" , change the "__" to "Blue Sky 2" also take out a "say __ for _ seconds" and change it to "say Oh no! for 1 seconds" . Afterwards, got to "events" and take out "wait _ seconds" change it to "wait 2 seconds". Place "say Oh no! for 1 seconds" on top of the "wait 2 seconds" followed by a "switch backdrop to Blue Sky 2" .

Adding the Codes for the Donut

Let's let our yummy donut have something to do. First, go back to the "events" section. Drag and drop a "when background switches to __" and switch the current "__" to "Colourful City"(or whatever you have renamed it to) . Go back to the "control" section, drag and drop a "wait 1 seconds" and place that under the "when background switches to __". Next, replace the "1" with "10". Go back to "looks" and take a "show" block and place it under the current line of codes. Go back to "control" and take out a "forever" and also a "wait 1 seconds", change the "1" to "5". Go back again to "motion" and take out a "go to random position". Add the "wait 5 seconds" and "go to random position" into "forever" with the "wait 5 seconds" on top. Now, duplicate the line of codes you have just done, 2 times. For the first one, change the first "wait _ seconds" to "15" and the next one to "3" . For the second duplicated one, change the first "wait _ seconds" to "20" and the last one to "1" . For the last bit, go to events and take out a "when backdrop switches to _" and change the "__" to "Blue Sky 2" .

Letting the Parrot Fly

Go to "events" and take out 4 "when space key pressed". Change 2 of the "when space key pressed" to "when right arrow key pressed" and the other 2 to "when left arrow key pressed" . Go to "control" and take out one "wait 1 seconds" and "repeat 10" , change the "1" to "0.13" and the "10" to "2" . Go to "motion" and take out "move 10 steps". Put the "wait 0.13 seconds" and "move 10 steps" into "repeat 2" , then connect them to "when right arrow key pressed" . Do the same for "when left arrow key pressed" , but change the "move 10 steps" to "-10" . That will let the parrot move smoothly. Now, go back to "control" and take out a "repeat 10" and change it to "2" , at the same time, take out a "wait 1 seconds" and change it to "0.11" . Go to "looks", now take out a "next costume" . Place the "wait 0.11 seconds" and the "next costume" into the "repeat 2" , the "wait 0.11 seconds" should be on top. Place the line of code into either "when right arrow key pressed" or "when left arrow key pressed" . Repeat the same code but place it into the other "event" block.

Finishing Codes for the Parrot

escape th efood .png

Go to "events" and take out 5 "when space key pressed" . Change all of them individually to "1" , "2" , "3" , "up arrow" and "down arrow" . Go to "motion" and take out another 5 "point in direction 90" . Change all of them individually to "90" , "129" , "58", "30" and "150" . Connect the "90" with the "2" , "129" with "3" , "58" with "1" , "30" with "up arrow" and "150" with "down arrow. Go back to events and take out a "when backdrop switches to __" and "when space key pressed" . Make sure the "__" inside is "Blue Sky 2".Then, go to "looks" and take out a "hide" and "when backdrop switches to __" . Make sure the "switch backdrop to __" 's blank is "Colourful City" . Connect the "when backdrop switches to __" with "hide" and "when space key pressed" with "switch backdrop to Colourful City" .

Extra Sprites

This time, you will need to make your own sprites, scroll your mouse over to the cat icon with a little plus sign above it at the bottom right-hand side of your screen. When you do, a list of four options should show up; click on the paint brush. This sprite will be your button to transition between the ending screen and the starting screen. Make a little box and fill it with the colour of your choice, then use the text box and type out "Click Here" and place it on top of the box. Align it with the words " To retry:" . (You should be at "Blue Sky 2")

Codes for "Click Here"

Go to "events" and take out one "when sprite clicked", and 3 "when backdrop switches to __" . For the "when backdrop switches to __" change them to "Colourful City" , "Blue Sky" and "Blue Sky 2" .

For "when sprite clicked" , get out a "switch backdrop to _" form looks and change it to "Blue Sky" before connecting it to "when sprite clicked" .

For "when backdrop switches to __" , take out 2 "hide" and one "show" . For " hide" connect it with "when backdrop switches to Colourful City" and "when backdrop switches to Blue Sky" . For "show" connect it with "when backdrop switches to Blue Sky 2"