Teach Phil to eat bacteria

You've now made two projects, one where Phil can crawl around, and another with a bacteria that can move by itself. One of the most important jobs of a neutrophil like Phil is to find bacteria in your body and "eat" them.

Watch this video of a real neutrophil chasing and eating bacteria:

In this project, we'll combine your "Teach Phil to crawl" and "Moving bacteria" projects to make a game where Phil can eat bacteria. So make sure you've completed those projects first. This project will be a bit more challenging and require you to figure out certain parts on your own.

Putting Phil and the bacteria in the same project

  1. Go to your "Moving bacteria" project and select "See inside".
  2. Select the "Backpack" at the bottom of the screen. This is a container that lets you move Sprites or other parts between projects.
  3. Drag the bacteria from the Sprites window to the Backpack window. This will make a copy of the bacteria inside the Backpack.
  4. Open your "Teach Phil to crawl" project.
  5. Let's save this as a different project. In the File menu, select "Save as a copy". Select the name of the project at the top, "Teach Phil to crawl copy", and change the project name to "Teach Phil to eat".
  6. Select the Backpack, then drag the bacteria from the Backpack to the Sprites window. You should now have two sprites in the Sprite window- Phil and bacteria.
  7. Start the project by clicking the green flag. Now, you should be able to use the arrow keys to move Phil, while the bacteria moves by itself.

Teaching Phil to eat

Now we want to make the bacteria disappear if it touches Phil.

  1. Select the bacteria in the Sprites window, so that we can see the blocks for that sprite.
  2. Drag out the below blocks from the Sensing, Control, and Looks categories.
  3. Snap the "if then" block inside the bacteria's "forever" block.
  4. Snap the "touching" block into the "if then" block, and change the "mouse-pointer" to "Neutrophil".
  5. Snap "hide" inside "if then".
  6. Snap "show" underneath "when flag clicked".
  7. Start the project again. Now, when Phil touches the bacteria it should disappear! Save your project.

Adding some extra features (optional)

  • Let's have Phil make a chomping noise when he eats bacteria. Drag out a "start sound" block from the Sound category. Snap it underneath the hide block. Go to the Sounds tab. Select the small speaker icon at the bottom left, and search for the sound called "chomp". Go back to the Code tab. Change the "start sound" block from "pop" to "chomp".
  • Let's add more bacteria. In the Sprites area, right click on the bacteria Sprite and select "duplicate". Repeat this several times to make more bacteria.
  • Think of a new feature that you would like in your program. Write down the individual steps that you would need to explain to someone how that feature works. Explore the Scratch blocks to add this feature to your program. For more ideas, click the "Tutorials" at the top.

Some more ideas:

  • Track where the bacteria move (Hint: read about the Pen Extension here).
  • Add a timer that counts up until the bacteria are eaten (Hint: try out for variables and broadcast).
  • Make Phil move on his own. See how fast you can make Phil eat all the bacteria on his own.
  • Have the bacteria make new bacteria (proliferate) (Hint: read about cloning).

Need more help? Check out an example completed project here: Example projects.

What should we change to improve this Project? What did you like best? What should we add to Programming Cells? Please let us know here: feedback form.

Congratulations! You've completed all 3 Projects! Now you're ready to make your own projects inspired by your science or biology classes.

Please share your projects in the Programming Cells - student projects studio for everyone to see. From the studio page, click 'Add projects' and then either select your project at the bottom or paste in the link to your project.