Seattle Coder Dojo Scratch Projects Menu
Teachers: Feel free to use anything you find here in your own Scratch classes.
If you have questions or comments, send me email at michaeladamkatz at yahoo dot com.
You can find links to older Seattle Coder Dojo Projects here.

Novice
If you are new to Scratch, start here and work through these guided tutorials. And even if you are not new to Scratch, you can learn a lot by doing these tutorials. All of these tutorials can be found at http://scratch.mit.edu. Just click Create to start a new project, then click on the question mark (?) in the upper-right corner of the screen to expand the tutorials areas.
"Getting Started With Scratch" tutorial
Go to Scratch and click "Create" to start a project. On the right edge of the screen there is a bar with a question mark at the top. Click the question mark to open the tutorial panel. Click the Getting Started with Scratch link at the top, then follow the steps of the tutorial. Ask a mentor if you have questions or get stuck. (Don't worry about the step at the end for shaing your project. You don't have to share the project if you don't want to.)
"Animate Your Name" tutorial
Go to Scratch and click "Create" to start a project. On the right edge of the screen there is a bar with a question mark at the top. Click the question mark to open the tutorial panel. Click the Animate Your Name link near the top, then follow the steps of the tutorial. Ask a mentor if you have questions or get stuck. (Don't worry about the step at the end for shaing your project. You don't have to share the project if you don't want to.)
"Dance, Dance, Dance" tutorial
Go to Scratch and click "Create" to start a project. On the right edge of the screen there is a bar with a question mark at the top. Click the question mark to open the tutorial panel. Click the Dance, Dance, Dance link, then follow the steps of the tutorial. Ask a mentor if you have questions or get stuck. (Don't worry about the steps at the end for adding your own pictures or shaing your project. You don't have to do these steps if you don't want to.)
"Create a Pong Game" tutorial
Go to Scratch and click "Create" to start a project. On the right edge of the screen there is a bar with a question mark at the top. Click the question mark to open the tutorial panel. Click the Create a Pong Game link, then follow the steps of the tutorial. Ask a mentor if you have questions or get stuck. (Don't worry about the steps at the end for shaing your project. You don't have to share it if you don't want to.)
"Race to the Finish" tutorial
Go to Scratch and click "Create" to start a project. On the right edge of the screen there is a bar with a question mark at the top. Click the question mark to open the tutorial panel. Click the Race to the Finish link, then follow the steps of the tutorial. Ask a mentor if you have questions or get stuck. (Don't worry about the steps at the end for shaing your project. You don't have to share it if you don't want to.)
"Hide and Seek Game" tutorial
Go to Scratch and click "Create" to start a project. On the right edge of the screen there is a bar with a question mark at the top. Click the question mark to open the tutorial panel. Click the Hide and Seek Game link, then follow the steps of the tutorial. Ask a mentor if you have questions or get stuck. (Don't worry about the steps at the end for shaing your project. You don't have to share it if you don't want to.)
"Create a Virtual Pet" tutorial
Go to Scratch and click "Create" to start a project. On the right edge of the screen there is a bar with a question mark at the top. Click the question mark to open the tutorial panel. Click the Create a Virtual Pet link, then follow the steps of the tutorial. Ask a mentor if you have questions or get stuck. (Don't worry about the steps at the end for shaing your project. You don't have to share it if you don't want to.)

Choosing and Planning a Beginner, Intermediate, or Advanced Project
Talk with a mentor if you need advice choosing or planning a project.
To show you need help choosing or planning a project, hold up a peace sign like this dog is doing.
To plan your project, answer these questions:
  • What sprites will I use in this project?
  • What is the basic plan for writing the sprite scripts?
  • Is there anything I need to learn about Scratch before doing this project?
  • Is there anything I need to learn about programming in general before doing this project?
  • Will I need a "forever" loop in this project? Will I need more than one?

Beginner
Just because this is the "Beginner" category doesn't mean all the projects are super easy. If you are a beginner and you find some of these projects hard, don't worry; just keep asking questions and take your time. Keep practicing and you will get it. If you are a more advanced Scratcher, most of these projects include challenges that you will find interesting, so if a project here sounds like fun, go for it.
Learn Your XY Coordinates!
BIG SECRET: You can either create this project from scratch using the guides below, or you can just play the game to practice your XY coordinates by clicking on the period at the end of this sentence.
The varialbes and the "Stage" script:

The Beetle script:

The Mouse script (very much like the Beetle -- use the copy tools to make it easy):

The Ghoul script:

The Gift script (very much like the Ghoul -- use the copy tools to make it easy):

Ask for help if you need it.
Halloween Scene
Follow this link and remix the project: https://scratch.mit.edu/projects/182736114/#editor
BIG SECRET: Ask a mentor about using Alt-tab (or command-tab) to switch quickly between screens.
The "Stage" script:

The "lightning" script:

The "message" script:

The "bat" script:

Ask for help if you need it.
Rube Goldberg Mousetrap (practice with broadcasting messages)
Follow this link and remix the project: https://scratch.mit.edu/projects/25434547/#editor
BIG SECRET: Ask a mentor about using Alt-tab (command-tab on the Macintosh) to switch quickly between instructions and project.
Sequence of events:

  1. When flag is clicked all sprites go to their starting positions, starting angles, starting costumes, starting hide/show
  2. Mouse comes out
  3. Cheese moves backward toward mouse
  4. Switch switches
  5. Panel drops
  6. Car goes down ramp, changes angle, and continues across floor until it pushes the match up
  7. Rocket catches fire and flies up and hits bowling ball
  8. Bowling ball rolls off shelf and falls on seesaw
  9. Seesaw changes sides
  10. Cage flies up and over and lands on mouse
Ask for help if you need it.
Plants vs. Zombies
Follow this link and remix the project: https://scratch.mit.edu/projects/126981912/#editor
BIG SECRET: Ask a mentor about using Alt-tab (or command-tab) to switch quickly between screens.
The "cow" script:

The "zombie" script:

Project ideas:
  • Use the Stage to make a cool background.
  • Try different cow speeds.
  • Try different zombie speeds and frequenies.
  • Make a different type of zombie that the cow has to avoid.
Ask for help if you need it.
Mirror Art: Learning about the X,Y grid
Go to Scratch and click "Create" to start a project.
Set up scripts for the cat sprite (Sprite1) as shown in the picture. Use the Set Size block to set the cat's size to 25%. When the script is done, click the green flag to watch the cat follow the mouse and trace a line.
Add the beetle sprite and set up its script as shown in the picture. When the script is done, click the green flag to watch the beetle "mirrow" the cat's position in the Y axis.
Add the mouse and dragon sprites. The mouse's script is like the Beetle's, but mirror's the cat's position in the X axis. The dragon's script is like the Beetle's, but mirrors the cat in both the X axis and the Y axis.
Angry Turkeys
Follow this link and remix the project: https://scratch.mit.edu/projects/129252513/#editor
BIG SECRET: Ask a mentor about using Alt-tab (or command-tab) to switch quickly between screens.
The "turkey" script:

The "objects" script:

Project ideas:
  • Use the Stage to make a cool background.
  • Make it so you get points for hitting Homer or Ned (and they disappear).
  • Make it so you die when you hit the knife or the arrow.
  • Make "dead" costumes for Homer and Ned for when they get killed.
  • Make a "dead" costume for the turkey for when it gets killed.
Ask for help if you need it.
Feline Fighters
Open this document: FelineFighters.pdf
Go to Scratch and click "Create" to start a project.
Create four sprites as in the document, two cats and two apples. Create the scipts for each sprite by copying what is shown in the document.
Ask for help if you need it.
Automatic, Manual, and Random Sprites
Go to Scratch and click "Create" to start a project.
Name the cat sprite "Manual". Use four "when ___ key pressed" event blocks to make it so that when you use the left, right, up, and down arrows the cat moves 10 steps in the direction you've indicated. Use the "change x by" and "change y by" blocks to make the cat move.
Add another sprite (whatever character you want) and name it "Automatic". Make it so that when the green flag is clicked the sprite positions itself in the lower-left corner of the screen (use a "goto x y" block). It then glides (use a "glide" block) to the lower-right corner of the screen, then to the upper-right corner of the screen, then to the upper-left corner of the screen, then back to the lower-left corner of the screen. You will use four "glide" blocks. Once you have it working, put the four "glide" blocks in a "forever" loop so the sprite will keep moving around the border of the screen forever.
Add another sprite (whatever character you want) and name it "Random". Make it so that when the green flag is clicked the sprite glides to a random location on the screen, then glides to another random location on the screen, and so on, forever. Use a "glide" block with two "random" blocks, one for picking the x and one for picking the y. Make it so it's also random how long each glide is, anywhere from 1 to 5 seconds.
Endless Stairs
Follow this link and remix the project: https://scratch.mit.edu/projects/93401759/#editor
This project has several sprites, but we'll just use the "stairs" for now.
Make a stick figure sprite.
Make the stick figure walk up the stairs forever. Use a "forever" loop with four "glide" blocks.
Make another stick figure walk down the stairs forever.
Make the stick figure say "hi" to each other when they pass on the stairs.
Add costumes to make the stick figures look like they are walking.
Lip Synching
Follow this link and remix the project: https://scratch.mit.edu/projects/64847448/#editor
Guide
rest
M
P
B
ah (hot)
ay (height)
ee (heat)
a (hat)
i (hit)
S, N, D, K
G, CH
R, Oh, W
Th, L
F, V
Challenge: Use a list (or two lists) to avoid having to use a code block for each mouth position.
Perpetually Prepared Penguin
Follow this link and remix the project: https://scratch.mit.edu/projects/24621469/#editor
Add a "when ___ key pressed" block to the "thermometer" sprite to make it so that when you press the up arrow the "temperature" variable increases by 2. In addition to using a "change" block, you'll need to broadcast a "show temperature" message.
Add a "when ___ key pressed" block to the "thermometer" sprite to make it so that when you press the up arrow the "temperature" variable increases by 2.
In the "penguin" sprite, make a few more costumes for the penguin, showing the penguin at different temperatures. Make one for when it's cold, one for when it's very cold, one for when it's normal, one for when it's hot, and one for when it's very hot.
Change the "penguin" code so that it shows your different costumes depending on the temperature. That is, if the temperature is average, show the plain penguin. If the temperature is cold (perhaps less than 45 degrees) show the penguin with its "cold" costume (maybe a sweater). If the temperature is very code (perhaps less than 30 degrees) show the penguin with its "very cold" costume (maybe a heavy jacket and snow boots). If the temperature is very hot (perhaps over 100), show the penguin with its "very hot" costume (maybe the swim suit). It's up to you how many costumes you want (how many temperature levels) and what they are.
Bonus: make the penguin say something appropriate for the weather whenever the temperature changes.
Maze
Go to Scratch and click "Create" to start a project.
On the Stage, change backdrop1 to Vector Mode. Click with the arrow to select the white background and use the Delete key to delete it.
Pick a pen color, and then use the rectangle tool to create a maze. For instance, you could draw a maze that looks like the picture below (or a simple maze, don't worry about making it complicated, and don't worry if your walls are all exactly the same size).

Shrink the cat sprite down so that it is small enough to move through your maze.
Add a "when flag clicked" block to the cat to position the cat at the start of the maze when the flag is clicked.
Add four "when ___ key pressed" blocks to the cat script, one for each arrow key. Each block is similar, but let's do the "when up arrow key pressed" first. When the user pressed the up arrow, we want the cat to move up 5 pixels, so use a "change y by" block.
But what happens when the cat touches a wall? We can keep the cat from moving through the wall by checking if it's touching wall color. If so, we want to move it back the number of pixels it just moved. For the "when up arrow key pressed" block, this means we first move the cat up 5 pixels (as we already did in the previous step), and then use an "if" block to check if it's touching the wall color, and if so we move it down 5 pixels. When the code runs, you'll notice that it's so fast that you don't actually see the cat move into the wall and then back out. If you want to prove to yourself that it does go into the wall, you can add a "say" block to say "I'm touching the wall" for two seconds before it moves back.
Complete the other three "when ___ key pressed" blocks similar to the "when up arrow key pressed" block.
You should now have a basic maze game. Here are some ideas for things you can add:
  • Put in something to check when the player has finished the maze. One way to do this is to add another small sprite at the maze exit, and you can check that the cat is at the end of the maze by whether it's touching that sprite. You can add a new (purple) block called "CheckMazeFinished" to do this check. Another way to do your "CheckMazeFinished" block is to just check that the cat's x and y coordinates are within certain ranges. You might try doing it both ways and see which way you like best.
  • Make some moving obstacles, such as a spinning line. To do this, make a new sprite that is a red line. For the sprite's script, use a "forever" loop that simply changes it's direction by 1 or 2 each time through the loop. In the cat script, make a new (purple) block called CheckDeath. In this block, check if the cat is touching the color red, and if so send it back to the start of the maze.
  • Make a "portal" in the maze that has two points. Make two new sprites, one for each end of the portal. When the cat touches one of the portal sprites, it is automatically "teleported" to the other portal sprite. (Not quite on it, but near it. Why is this important?) When it touches the other portal sprite, it is automatically "teleported" to the first portal sprite.
  • Make a "robot" that moves through the maze randomly. Use a "pick random" block to pick a direction for the robot to move, and then move the robot 5 pixels in that direction. The robot is similar to the cat in that if it touches a wall it should move back 5 pixels in the opposite direction. It can make a big difference when you pick a new direction for the robot. One way is to pick a new direction for each move. That will make your robot jitter around quickly, but it won't tend to get very far. Another way is to pick a direction, then move in that direction until it hits a wall, and then pick a new direction. This will make your robot move through the maze much more efficiently.
Arrows and Boxes
In this project you use a simple arrow and box to make lots of interesting patterns, including some 3D-style patterns similar to Minecraft.
Open this project and remix it: https://scratch.mit.edu/projects/78798510/#editor
Open this document: ArrowsAndBoxes.pdf
In the cat's script, enter the two functions at the top of the document. Use the "arrow" function to draw as many of the patterns as you can shown in the first part of the document (the images made of blue lines). To draw the ones where the arrow grows and shinks you'll need to use a variable to keep track of the arrow size.
Now use the "box" sprite's script to draw the box images you see in the second half of the document. Do this by using the "stamp" command to draw the box on the screen.
Movie Story / Joke Animation
One type of Scratch program is a "movie", which is just a long sequence of animations that tell a story. The image above shows all the blocks you need to make a movie. This project will help you get familiar with the "broadcast" and "broadcast and wait" blocks.
In this project you will use the Stage as the "director" of the movie. That is, the Stage is where you'll write most of the scripts. However, in Scratch, a script cannot control another sprite directly. To get the Stage script to control the other sprites, you'll need to use "broadcast" and "broadcast and wait". The difference between these two is that "broadcast and wait" waits for the recieving sprite to finish its "when I recieve" block before continuing on, while "broadcast" does not wait.
Think of a story you want to tell that involves a main character and one or two secondary characters. If you already know the story you want to tell, great. If not, here is a special challenge. Try to think of a story where the characters will say each of the following lines somewhere in the story (not necessarily in the order they are listed below). The challenge is to make a story where it more or less makes sense for each of these lines to be said.
  • Apparently I can breathe under water.
  • I'm free!
  • I thought I'd never reach the top!
  • That's so beautiful it makes me want to cry!
  • Ouch!
  • Why is everything upside down?
  • Get out of my way!
  • Get me out of here!
  • That was more slippery than it looked!
  • Hey, who turned out the lights?
  • Suddenly I seem to have the ability to fly!
Or make a mini-movie that shows a joke. Here are some joke ideas:
  • What's brown and sticky? ...... A stick! remix project
  • What does a snail say when it's riding on a turtle's back? ...... Weeeee!!
  • Why did the chicken cross the playground? ...... To get to the other slide!
  • Why did the spider cross the road? ...... To get to his web site!
  • What did zero say to eight? ...... Nice belt!
  • Where did the king keep his armies? ...... In his sleevies!
  • How do you make a tissue dance? ...... Put a little boogie in it!
  • Why was 6 afraid of 7? ...... Because 7 8 9!
  • Two muffins are in an oven. 1st muffin: Do you think it's getting hot in here? ...... 2nd muffin: Ahh! A talking muffin!
  • How did Cookie Monster feel after eating a whole box of cookies in bed? ...... Pretty crummy!
  • What has 4 wheels and flies? ...... A garbage truck!
  • What do you call a bear with no teeth? ...... A gummy bear!
  • How do you catch a squirrel? ...... Climb up a tree and act like a nut!
Remember, the Stage is the "director" of the movie, so the main scripting happens in the Stage. Think of your story as a sequence of scenes. The first scene is called "intro". Make a new block called "intro" (as in the picture) and call this block from the "when flag clicked" block (as in the picture). Add code to the "intro" block. Set the backdrop to your starting backdrop. Show your main character. Use "say" and "wait" and "glide" commands to have your main character. Since the Stage cannot make your main character sprite do things directly, it needs to broadcast messages to the sprite. For instance, the Stage might broadcast a message like "do intro" to the main character sprite. When the main character sprite receives this message it might show itself, say something, glide somewhere on the screen, say something else, and so on.
Keep adding to your "intro" script until your intro scene is complete. Perhaps the intro scene involves your main character and another character having a short conversation. When the "intro" scene is done, add another scene (maybe the scene is called "at the beach" if your story has a beach) by adding another purple block and calling this block in your "when flag clicked" block. In this way, keep adding actions to your scenes and more scenes until your story is done.
Charlie Brown Football
This project is similar to the Movie Story, but is a very specific sequence from a famous cartoon. If you haven't done the Movie Story project yet, at least look at the picture shown with that project, since it shows the blocks you need for this project also.
Click this link and remix the project: https://scratch.mit.edu/projects/45791408/#editor
Using the sprites in the project, make the following movie sequence:
  • In the intro screen, Lucy shows Charlie Brown the football and says, "I'll hold the football and you kick it."
  • Charlie brown says, "You always pull the football away right before I kick it."
  • Lucy says, "Trust me, this time I promise to hold it."
  • Charlie Brown says, "Hmmm, well, okay."
  • Then we jump to a scene using background2 showing Charlie Brown standing there alone on the right side of the screen.
  • After a few seconds, Charlie Brown runs to the left side of the screen. You can make him run by switching back and forth between the "run1" and "run2" costumes as he moves to the left.
  • When Charlie Brown reaches the left side of the screen the scene quickly flips back to background1 and we see Charlie Brown enter from the left side of the screen. Lucy is there holding the ball.
  • Charlie Brown keeps running and just before he reaches Lucy she pulls back the ball.
  • Charlie Brown starts flying through the air and flies off the screen to the left.
  • The scene quickly flips back to background2 and we see Charlie Brown fly in from the left.
  • Charlie Brown flies up in the air and flips over two times while screaming.
  • Charlie Brown lands on his back. As an extra challenge, use the "dust" sprite to make a dust cloud as Charlie Brown lands. By changing the size and "ghost effect" of the dust cloud you can make it look like it's growing and fading.
  • Finally, Lucy appears next to Charlie Brown and says, "Ha ha! Tricked you again, Charlie Brown!"
Crazy Cat Claws
Open this document and follow the instructions: CrazyCatClaws.pdf
Ask for help as you need it.
Quiz
Go to Scratch and click "Create" to start a project.
Make a quiz game that asks you several questions in a row. The questions can be about math, movies, geography, or anything you want to ask.
Use an ask block to make the cat ask a question. Then use an "if" statement, the "answer" block, and an "=" block to check if they got the right answer. If so, make the cat say "Correct!". If not, make the cat say "Nope. The right answer is ___." (put the answer where the blank line is)
Once you have your first question working, add several more questions.
Make it so that at least one of your questions allows two different correct answers. For instance, if one of your questions was "What is 2 + 3?", you could allow the user to answer either "5" or "five". Use an "or" block to allow both answers.
Add a variable called "score" that keeps track of how many questions you got right. Start the score at 0 and increase it by 1 each time the user answers a question correctly.
Challenge: At the end of the quiz, tell the use how many questions they got right, and also show a percent. For instance, if you asked them 8 questions and they got 6 right, the cat would say "You answered 4 out of 8 questions correctly. That's 75%." You can construct this sentence using several "join" blocks. You can compute the percentage by dividing the number correct by the number of questions and then multiplying by 100.
Big Challenge: You probably noticed that you repeated a lot of code asking all those questions. In fact, the code for each question was basically the same, and the only thing that changed was the text of the question and the correct answer. We can make the program much shorter by putting all of the questions in a list, and all of the answers in another list.
  • Make a list called "questions", and enter the text of each question as an item in the list.
  • make a list called "answers" and put the answer to each question as an item in the list, in the same order as your "questions" list. (For this challenge, don't worry about allowing two answers for your questions, we'll just stick with one answer for now.)
  • Make a variable called "question number" and start it at 1.
  • Use a repeat loop to ask each question in the list. Use an "item" to access the items of the "questions" and "answers" lists.
Row of Houses
Go to Scratch and click "Create" to start a project.
Shrink the cat down to a small size so it's easy for you to see the pen trail.
Write a function (purple block) called "Square" that draws a square with sides of size 40. Use a "repeat 4" loop. To test your function, drag the cat to different places on the screen and then click the "Square" function.
Write a function called "Triangle" that draws a triangle with sides of size 40. As for help if you can't figure out the angle to use.
Write a function called "House" that draws a house by calling the Square function and then calling the Triangle function. You may have to move the sprite a bit between the two function calls. Alternatively, you should be about to modify Square or Triangle a bit to make it that House can simply call Square and then call Triangle.
Write a function called RowOfHouses that draws 5 houses in a row, with a bit of space between each house.
Bonus: Modify all of the functions you've written (Square, Triangle, House, RowOfHouses) to make a number input called "size", and to use the size as the side length of the shapes, instead of the fixed value 40 that we used above. Start with the Square function. Once it has the size input, you should be able to draw squares of any size. (Try it out!) Then add the "size" input to Triangle also. Similarly, add the "size" input to House and RowOfHouses. Note that House and RowOfHouses "pass on" the input value to the functions they call. If this input stuff is confusing, don't worry, it's a bit tricky. But it's also important. Talk with a mentor or another student to ask questions about inputs.
Bonus: Write a loop to fill the screen with houses of random sizes in random locations.
Bonus: Make a variable called "current size" and use it to write a function called ShrinkingRow. Make ShrinkingRow draw a row of 10 houses where each house is a bit smaller than the one before it.
Apple Catcher game
Go to Scratch and click "Create" to start a project.
Add a "catcher" sprite that you can either draw or find an appropriate sprite from the library. The catcher is some kind of bowl or something else that could catch apples.
The code for the "catcher" sprite positions the sprite at the bottom of the screen, and lets you move it back and forth across the bottom of the screen using the left and right arrows. You can use brown "when ___ key pressed" blocks for this, or for smoother motion you can use blue "key ___ pressed?" blocks inside of "if" statements.
Add an "apple" sprite. When the flag is clicked, do a "forever" loop that starts the apple in a random position at the top of the screen, and then has the apple move down the screen until it touches the catcher or reaches the bottom. You can modify the speed at which the apple falls to make the game as challenging as you want.
Make a variable called "score". If the apple touches the catcher, increase the score. If the apple hits the bottom of the screen without touching the catcher, decrease the score.
Use cloning to make it so lots of apples are falling at once. Make one apple clone per second. When an apple touches the catcher or the bottom of the screen, delete the clone.

Intermediate
These projects are different from the Beginner projects because they all require you to add variables to keep track of things.
Rules of Thumb for Intermediate and Advanced Scratch Programming
Moire Patterns
Make a program to draw pictures like the one above. Pick a point on the screen, and then use the pen to draw a line from that point to each point along the top of the screen, stepping by some amount. For instance, if the point you picked was x = 40, y = 25 and you were stepping by 5, you'd draw a line from 45, 25 to the point -240, 180 (top-left of the screen), then a line from 45, 25 to the point -235, 180, and so on until you had gone all the way across, ending with a line from 45, 25 to 240, 180 (top-right of of the screen). Then continue the process for the right side of the screen, the bottom of the screen, and the left side of the screen.
Pick a random x, y for the starting location. You can also pick a random stepping distance (perhaps from 2 to 10 pixels) and a random color. Make the cycle repeat over and over.
You'll need to use variables to keep track of the starting x, y location, the stepping distance, and the progress along each side.
Number Guessing Game
Write a program where the cat plays a number guessing game with you. The cat thinks of a number between 1 and 1000. In a "repeat until" loop, the cat asks you to guess a number, and tells you whether your guess is too high or too low. If your guess is correct, the cat tells you that you are right, exits the loop, and tells you how many guesses it took you. You will need at least two variables for this: one to hold the secret number, and one to keep track of the number of guesses.
Now use a second sprite to play the same game, but where you pick the number and the computer does the guessing. Here is a plan: Use two variables to keep track of the range of possible numbers. At the start, these variables are 1 and 1000. Each time through the loop, guess the number that is half way between these values. So let's say the number you pick in your head is 123. Here is how the game would go:
  • The first time through the loop, the computer guesses 500.
  • You respond by saying "high". Now the computer knows the number is between 1 and 499.
  • It's next guess is 125.
  • You respond by saying "high". Now it knows the number is between 1 and 124.
  • It guesses 62.
  • You respond by saying "low". Now it knows the number is between 63 and 124.
The game continues in this way until the computer guesses your number. Hint: You'll need to use the "floor" function to keep the computer from guessing decimal numbers. Why is this?
Adventure Game
Make a game where you have to move from location to location and go on an adventure.
After reading the details below, you can either start a project from scratch, or you can remix this project as a way to get started: https://scratch.mit.edu/projects/217890043/#editor.
Start by making a map on piece of paper. For instance, here is a sample map with several locations and ways of going between locations.
You move among locations on the map by clicking parts of the screen. For instance, if you are at the Enchanted Forest and you click near the top of the screen, you go to the Castle. If you are at the Castle, and you click near the bottom of the screen, you go back to the Enchanted Forest.
There are two methods you could take to checking if the user clicked a certain place on the screen. Method 1 is to let the Stage script handle moving around. (This makes sense since the stage will also change its backdrop as you move from one location to another.) So you'd use the "when Stage clicked" block, and then, depending on what location the player is at and the x, y location of the click, you'd figure out where to move (or not to move, if they didn't click on meaningful area). Method 2 is to use sprites that the player has to click on. For instance, when you're at the Enchated Forest a sign shows up at the top of the screen that says "To the Castle" and when you click on that sprite. You will probably find that the screen-coordinate method works out better.
Once you have the it working so that you can navigate among all of the places on your map, it's time to make the "puzzles" of your adventure game. In adventure games, there are usually various items in the world that the player can find, pick up, and use. For instance, there might be a treasure chest at the "beach" location, but the player can't open it without the key, which is found in the dungeon of the castle. So the player has to go to the dungeon, pick up the key, go to the beach, and then open the chest.
Here is one way you might handle the location of objects like the key and the treasure chest in your game.
  • There is a variable called "player location" which stores the current location the player is at. This variable gets values like "beach" or "dungeon" or whatever the places are in your game.
  • Each object is a sprite.
  • For each object, there is a variable that stores its location. For instance, for the key object there is a variable called "key location" that stores the current location of the key. At the start of the game, you could set "key location" to "dungeon", meaning the key is in the dungeon. When the player picks up the key, "key location" changes to "inventory". (You can think of "inventory" as a special location meaning that the player is carrying the object.)
  • Have each object receive a message called "show or hide". In "when I receive 'show or hide'" the object checks if it's location variable is the same as "player location" (the location that is currently being displayed). If so it shows itself. If not it hides itself.
  • You can have a button on the screen that says "inventory", when you click this button you can go to a special "inventory" location, and simply by doing that, all the objects the player is carrying should show on the screen.
There are various ways you can handle interacting with the objects.
  • A simple way is that when you click on something, it just does a default action. For instance, when you click on the key in the dungeon, it knows you want to pick it up, so it goes into your inventory. When you click on the treasure chest it knows you want to open it, so it either opens (if the key is in your inventory) or it says a message that it's locked so you can't open it. When you go to your inventory and click an item the default action can be to drop the item in your current location.
  • The simple plan described above can get you pretty far, and you could make a whole adventure game using just that mechanism for interacting with objects.
  • A fancier way of interacting with objects is to introduce the idea of "verbs".
  • You could have several "verb" buttons on the screen, such as "take", "drop", "eat", "examine", "use on", and perhaps more.
  • In this case, the way the player does things with objects is to first click a verb button and then click the object. For instance, to pick up the key they would click "take" and then it would ask them to click an object, and if they clicked the key it would put the key in the inventory. On the other hand, if they clicked "examine" and then clicked the key, they might see a message that says "It is a small gold skeleton key, the kind a pirate might use.
  • The "use on verb would be a bit different, and would ask the player to click two objects, meaning to use the first object on the second. For instance, if the player clicked the key and then clicked the treature chest, the treasure chest would open. But if the player clicked the apple and then clicked the duck, it might say "The apple does nothing to the duck."
Flappy Bat
This classic game uses realistic physics. The goal is to flap the wings of a bat to help it avoid obstacles that poke up from the bottom of the screen and poke down from the top of the screen. The bat just moves up and down and is always positioned near the left side of the screen. The obstacles move from right to left giving the feeling that the world is "scolling by" as the bat flies through it.
You can simulate physics by thinking in terms of y velocity: each time through the main "forever" loop you move the bat up or down by its y velocity. You increase the y velocity by flapping the bat's wings, but also gravity is constantly operating, making the bat's y velocity more negative.
So in your main "forever" loop, you'll have the lines show in the picture below. The line on the left changes the bat's y position by its y velocity. The lines on the right change the y velocity by -0.4 to simulate gravity (you can try different values to make gravity stronger or weaker). Note that there is also a check to keep the y velocity from going too far negative. (Why is this check needed?)
Not shown in the picture above is the "if key ___ pressed" block you'll need to check if the playing is holding down the space bar. If so, you increase the y velocity by a certain amount. Again, you'll want an "if" block to make sure the y velocity doesn't get too large. (Again, why is this needed?)
For the black bars, make two sprites named "bar 1" and "bar 2". You can make it look like these sprites keep coming forever by sliding them across the screen and when they reach the left side start them sliding from right again.
Although it says in the rules of thumb to try not to use "if touching", you will probably find it convenient to use "if touching" to see if the bat is touching one of the obstacles. However, you can also do this by checking coordinates instead of using "if touching". You will find as you do more and more advanced Scratch projects that checking coordinates is almost always better than using "if touching".
Here are some additional challenges for this game:
  • Keep score. Every time the bat passes an obstacle it gets a point.
  • Make it so that each time the bat touches an obstacle it says "ouch" and you lose five points.
  • Make it so the obstacles aren't all the same length. Some poke in farther than others.
  • Make power pellets that scroll by like the obstacles scroll by. The bat can try to touch the power pellets for bonus points.
  • Make an airplane fly across the middle of the screen once in a while. The bat has to avoid the airplane just like it avoids the line obstacles.
Lunar Lander
This is a classic arcade game and a good example of a game that uses realistic physics. The goal of the game is to land a space craft on a landing pad on the moon. The landing must be accurate and gentle -- the space craft is destroyed if you hit part of the moon that is not a landing pad, or if you land with too much downward velocity or when the ship is tipped at too much of an angle.
Draw the moon surface on the Stage's backdrop using one color for the terrain (brown in the picture above) and one color for the landing pads (pink in the picture above). Normally it's best to draw things in vector mode, but in this particular case it might be easier to stick with bitmap mode.
You can simulate physics by thinking in terms of velocity: each time through the main "forever" loop you move the ship by its velocity. You can change the velocity by using the ships thruster, and also gravity is constantly operating, making the ship's downward velocity more negative.
You can think of the velocity in terms of two variables -- "y velocity" and "x velocity". "y velocity" tells you how fast the ship is rising (if "y velocity" is positive) or falling (if "y velocity" is negative). "x velocity" tells you how fast the ship is moving to the right (if "x velocity" is positive) or to the left (if "x velocity" is negative). Gravity is constantly affect "y velocity".
So in your main "forever" loop, you'll have the three lines shown on the left side of the picture below. The first two lines move the ship at it's current x and y velocities, and the third line applies gravity to the y velocity. (You can play with other values that -0.04 to affect how strongly gravity pulls the ship downward.)
You'll want to use a some "if key ___ pressed" blocks to check if the player is holding down the left arrow, the right arrow, or the space bar. If the left or right arrow is pressed, the ship rotates. If the space bar is pressed, the ship thrusts. Remember that the thrusting does not "move" the ship directly, but rather affects the ship's x velocity and y velocity.
The two lines on the right side of the picture above show how you can change the two velocity values based on the angle the ship is facing. For instance, if the ship is facing straight upright, when you thrust all the "thrust power" increases the ship's y velocity upward, but does not affect the ship's side-to-side x velocity. However, when the ship is turned at a 45 degree angle to the right, half of the "thrust power" pushes the ship upward (increases the y velocity) and half of the "thrust power" pushes the ship to the right (increases the x velocity). At other angles (for instance, when the ship is turns just slightly to the right), different distributions of the "thrust power" between the y velocity and x velocity are needed. The way to figure out this distribution is to use the sin() and cos() functions as shown in the code above. Normally you don't learn about sine and cosine until you study trigonometry in about 10th grade. But you can look up sine and cosine on Wikipedia and/or talk to a mentor to understand how these two lines of code work.
In the "rules of thumb" above, it says to try not to use "if touching color". However, in this particular game, it is especially convenient to use "if touching color" to see if the ship is touching a landing pad (perhaps pink, as in the picture above), or the moon surface (brown in the picture above). In general, it is best to check coordinates instead of using "if touching" or "if touching color", but sometimes, as in this game, it just makes so much sense to use them that it's smart to break this "rule".
The picture above shows that when the ship is thrusting (when the player is holding down the space bar), some fire is seen coming out of the bottom of the ship. One problem with using "if touching color" is that if the fire is poking out of the bottom of the ship as it's landing, and if the fire is part of the ship's costume, the fire might be touching brown, and you'll think the ship as crashed, but really it should only crash if the main part of the ship is touching brown. One idea is to use "if color touching color", but unfortunately we have found that "if color touching color" doesn't always work because of a bug in Scratch. A way around this is to make the fire it's own sprite and to have the fire "follow" the ship and show itself when the player is thrusting.
If the ship touches the moon surface or doesn't land gently, make it crash. Remember that landing gently means not falling too fast or being at too much of an angle when you hit the landing pad.
Here are some additional challenges for this game:
  • Start the ship with a certain amount of fuel. As the ship thrusts it uses up fuel. If you are out of fuel you can't thrust anymore.
  • Make a "fuel refilling station" somewhere. If the ship touches the fuel refilling station it disappears and sets the ship's feul back up to the starting value.
  • Make it so that you get more points for landing on a landing pad that is more difficult to reach. To do this, you'll have to do more than just check "is touching color" pink. You'll need to use coordinate comparisons to figure out which landing pad the player landed on.
  • Make an alien ship fly around so that in addition to having to land you also have to avoid crashing into the alien.
  • Make multiple levels. When you complete a level, go do the next level by changing the Stage's backdrop.

Advanced
Rules of Thumb for Intermediate and Advanced Scratch Programming
Q-Bert
Open this guide document: qbert.pdf
Use this starter project (remix it): https://scratch.mit.edu/projects/168349535/#editor
Here is a project where the board is complete (remix it): https://scratch.mit.edu/projects/168349535/#editor
If you start with the starter project, follow the guide to make the board. To do this, edit the variables, then make the scripts for the "box" sprite. After you get the board working, try the challenges to make the board look different ways. This will help you understand the "Compute Coordinates" function.
If you start with the project where the board is complete, add code to make Q-Bert and the snake jump around. Ask for help to get started.
Zombie Shootout
Rabbit Runner
This game is no so different from the "Flappy Bat" project above, but has more going on. The player controls a rabbit that stays in the center of the screen, and the world scrolls by to make it look like the rabbit is running through the world.
When the rabbit is on the ground, it runs. (You can do this by having one costume with the legs together and one with the legs sticking out.) The player can make the rabbit jump by pressing the space bar. If you want, you can make allow the player to make a second jump when the rabbit is in the air. (This is not very realistic physically but a lot of games let you do a double jump like this.)
Several different kinds of objects scroll by: trees, bushes, grass, carrots, and poison onions. You can handle all of these different objects as one sprite with different costumes. The idea is to generate clones of the object using a random time delay. Once cloned, the object moves across the screen from the right side to the left, and when it reaches the left edge the clone is deleted. By starting the object's position a bit off the screen to the right you can make it scroll in from the right instead of just "popping" in.
Nothing happens when the rabbit touches a tree, a bush, or some grass. When it touches a carrot the carrot is deleted and the player gets a point. When it touches a poison onion the game is over.
Here are some challenge ideas:
  • Make it so the number of jumps is limited. You need to get carrots to earn more jumps.
  • Make other dangers besides just the onions.
  • Make it so the rabbit can shoot a missile as a way to knock out the onions and other threats, both as a defense mechanism and a way to get more points. When a missile hits an onion, a nice effect is to make the onion fall to the ground instead of just disappearing.
  • Harder: Make it so the terrain goes up and down. The picture below shows two ways you might do this. On the left, the terrain "jumps" up and down suddenly. On the right is a version where the terrain rises and falls smoothly -- this is much harder; talk with a mentor if you want help thinking about how you would do this.
Hangperson
Create a list of words to choose from. Alternatively, you can make it so that one player types in the secret word while the other player looks away.
Use a variable to keep track of the number of guesses the player has made. Depending on the number of guesses, draw the "hangperson" in different states of completness.
To keep track of what letters the player has guessed, use a list. When displaying the secret word, any letter that is in the list is displayed, and any letter that is not in the list is shown as a blank.
Typing Blaster
Make a game that's a bit like the Apple Catcher game (see the Beginner section) except instead of Apples, random letters are dropping from the top of the screen.
You can "blast" these letters by typing them on the keyboard. When a letter is blasted, it disappears. Bonus: You can also make a nice little "blast" animation showing the letter get destroyed.
The player gets a point for each letter blasted. If a letter reaches the bottom of the screen without being blasted the player loses a point. If the player types a letter that is not currently on the screen, a "buzzer" sound plays and the player loses a point.
Some hints on how to make this program:
  • Make a single sprite that has all the letters of the alphabet (use one of the letter sets from Scratch's sprite library).
  • As in the Apple Catcher game, use cloning to generate each falling letter.
  • Unfortunately, the simplest way to check for each letter being pressed is to use a "when ___ key pressed" block for each of the 26 letters. That's a lot of blocks, but at least be sure to only use one line in each of these blocks to keep the code as short as possible. This one line of code calls a function with a number representing the letter: A is 1, B is 2, etc.
  • Advanced Bonus: See this program for an idea on how to check for any key being pressed without using 26 "when ___ key pressed" blocks: https://scratch.mit.edu/projects/10750787/#editor
  • It's actuallly not so easy to check that a letter pressed does not match any of the letters on the screen. One way to make this work is to use a list to keep track of which letters are on the screen. You can use a list that has 26 items, and each item is the number of the given letter on the screen.
  • Advaned Bonus: If there is more than one of the same letter on the screen, the easiest thing is to have all of them blast when the letter is pressed. As an advanced challenge, try to make it so that only one of them blasts for each key press.
15 Puzzle
Look up "15 puzzle" on Wikipedia if you need to be reminded of how this game works.
One way to keep track of the state of the board is with a list. You can use a list of 16 elements. The first four elements are the first row of the board. The next four elements are the second row of the board, and so on. Each element holds either a number from 1 to 15, or the number 0, which represents the "blank" tile.
When the player presses one of the four direction arrows, slide the tile if they can move in the given direction. For instance, if the game state is like in the picture above with the "blank" block in the lower-right corner of the board, the only choices for a move are right-arrow or down-arrow. From the point of view of the player, right-arrow means to move the 15 tile to the right and down-arrow means to move the 12 tile down. From the point of view of the code, you can think of things in terms of moving the "blank" tile in the opposite direction: for instance right-arrow means you want to move the "blank" tile to the left (and move the tile it's replacing to the right), and down-arrow means you want to move the "blank" tile up (and move the tile it's replacing down).
At the start of the game, you need to "shuffle" the board. If you think about it and read about it, you'll realize that not all arrangements of tiles are "solvable". So if you just place the tiles 0 through 15 on the board, it might not be a solvable configuration. One way to get around this is to do the shuffling by starting with a solved board (as in the image above), and then making a large number random tile slide moves on the board to mix it up.
Galaxy Explorer
This game is kind of like Lunar Lander, but there is no gravity. Instead, the ship's velocity only changes when you thrust. When you thrust, the sin() and cos() functions are used as shown below.
The interesting part of this game is that the ship is always in the middle of the screen and the rest of the galaxy moves around it. There are two kinds of things in the galaxy besides the ship, stars and planets.
There are two key variables: "ship x" and "ship y". As the ship moves, "ship x" and "ship y" change, but instead of moving the ship to a different part of the screen, the stars and planets move in the opposite direction of the ship. For instance, if "ship x" increases by 10 (meaning the ship is moving to the right), all of the stars and the planets move 10 pixels to the left.
The stars are very important because there are always a lot of them on the screen, and they give an idea of the speed and direction of the ship. Here is a plan for handling the stars:
  • Make variables called "star x" and "star y". When making these variables, it's important to check the "for this sprite only" box. This is because, in Scratch, "for this sprite only" means that each clone of the sprite gets its own copies of these variables.
  • Clone 50 stars at the start of the program. These 50 stars last for the whole program. Before making each clone, set "star x" and "star y" to random screen coordinates. Again, remember that because these variables are "for this sprite only", each clone will get it's own copies of these variables.
  • In the clone's "forever" loop, use the following line:
  • Think about what that code line does. It positions the star at "star x"/"star y" (those are the random screen coordinates chosen when the star clone was made) but subtracts from that position "ship x"/"ship y" (the location the ship has moved to). As dicussed above, by subtracting the ship's position from the positions of the stars and planets, we make it look like the ship is moving in the given direction.
  • The rest of the code in the star clone's "forever" loop is about keeping the stars on the screen by "recycling" them. That is, when a star goes off the screen, it can pop back on the other side of the screen. For instance, if the ship's position has changed such that the star has gone off the left side of the screen, we can change "star x" by adding 480 (the width of the screen), to make it come back in the right side of the screen as if it's a new star (but really it's same sprite clone being "recycled" as a new star). In this way, we can make it feel like there's an infinite universe of stars when really there are only 50 clones.
The planets are like the stars, but a bit simpler because they don't "recycle". You can make a single sprite called "planet" which has two or three different costumes (a red planet, a blue planet, maybe a green planet).
  • Again, make two variables "for this sprite only" called "planet x" and "planet y".
  • When the game starts, generate a few planet clones. Before creating each clone, set the "planet x" and "planet y" variables to where you want the planet to be in the galaxy. These starting locations might be big numbers that put the planents off screen so the ship has to move to them to see them.
  • In the clone's "forever" loop, use the same code shown above for the stars to position the planets taking into account "planet x" and "planet y" (where the planet is in the universe) and "ship x" / "ship y" (where the ship is in the universe).
  • The planets don't "recycle" the way the stars do when they go off the screen. However, Scratch keeps all sprites at least partly visible on the screen. That is, even if you set a sprites x,y position to 10000,10000 Scratch will still show the sprite on the side of the screen. (Scratch does this because they think it might be confusing if your sprites go off the screen.) To counter this "feature" of Scratch, you'll need to show or hide the planet sprite based on whether it should be visible on the screen. That is, if the planet is in a position that makes it at least partly shown on the screen, show it. But if the planet's position is off the screen, you need to hide it.
Here are some additional ideas for this game:
  • The goal of the game could be that you have to find and visit all the planets. Show a display on the screen indicating which planets you've visited.
  • Create an alien ship that flies around randomly, but that tries to stay near to where the player's ship is. You can make the alien ship hostile. You could in fact make the ships shoot at each other. Alternatively, you could make the ships more like space fruit, and the goal of the game is to chase them all down and collect them all.
  • One problem is that the game allows the player to fly off as far as they want in any direction. This can make it very easy to "get lost" in the universe. Try to think of some way to help the player with this. You might create a kind of "boundary" to the universe to keep the player from going too far off. Another idea is to notice when the player is far away from where the planets are and to show an arrow on the screen to guide the player back.
Tic-Tac-Toe Artificial Intelligence
Write a program where the computer plays tic-tac-toe against you.
Start by making a program where the computer let's two people play tic-tac-toe against each other.
  • It shows a board and says whose turn it is (X or O).
  • The player clicks in a space on the board and the right shape (X or O) is shown in that space.
  • Then it's the other player's turn.
  • When one player makes three in a row, the computer says that player wins.
  • If the board fills without either player winning, the computer says it's a tie.
Here are some some hints for how you might get this working:
  • Use a list to store what's on the board. The list has 9 items. You'll need little formula to pick the right item for a given x, y grid space on your board.
  • Draw the Xs and Os by clearing the pen drawing and then using "stamp" to draw the Xs and Os.
  • Write a function to check if there are three in a row in a given direction.
Now make a version where the computer plays against you. Start by making a list of "rules" that explain how you play tic-tac-toe. For instance, one rule you probably use is that, if you can win by making a play, you make that play. Another rule is that if your opponent can win on the next turn, you make a play to block that. List some of the other rules you play by, and when you think you have a complete description try writing it as a program.
Game of Life
Look at the Wikipedia page for Conway's Game of Life.
Make a Scratch program to play this game. Here is a plan:
  • Use a list to keep track of the board state, where each list is string, and the letters of the string indicate whether a cell is alive or dead. For instance, if your board is 20x20, you'd have a list of 20 items representing the 20 rows of the board. Each item is a string of 20 letters. For instance, the first item might be "01000000000000000011". This means that on the first row all of the cells are dead except the second cell and the last two cells.
  • You'll actually want to have two of these lists, one for the current state of the board, and one for the state of the board at the next generation. To compute the next generation, set the next generation board to all 0s, and then walk through the current generation board, apply the rules of the game, and set the surviving cells on the next generation board. When you are done, copy the rows of the next generation board to the current generation board.
  • Draw the current generation board on the screen by clearing the drawing and using "stamp" to draw the live cells.
  • To make the program run quickly enough, you'll definitely want to use a "run without screen refresh" function to do the board computation and the drawing.
Pac-Man
Make a Pac-Man game.
Use a list to represent the board. Each item in the list is a "row" of the board. Each item is a string representing a "cell" in that row. (You have to think of the board as a grid with "wall" spaces and "blank" spaces.)
Use a list to represent the board. Each item in the list is a "row" of the board. Each item is a string representing a "cell" in that row. (Think of the board as a grid with "wall" spaces and "blank" spaces.) You can use "stamp" to draw the board on the screen from the data in the list.
The players and ghosts move within the "blank" spaces of the board. It's important to decide exactly how you want to think of the player and ghost movement. Suppose the player (or a ghost) is "on" a particular blank cell of the grid, and then decides to move to an adjacent blank cell. You could use a "glide" block for the motion, but that means that once a player (or ghost) decides to move from one cell to another, there is no way changing direction until it has fully "arrived" at the destination cell. Another way of thinking about things is that the player (or ghost) moves one pixel at a time (or maybe two pixels at a time, if one is too slow), and can change direction at any point. Talk this decision over with a mentor.