Return to site

Build a Composting Game in Scratch

Educators & parents: You can do this Hour of Code Activity as a class or students can work on it independently. If you have any questions or need help, email info@codespeaklabs.com.

Composting your food scraps is a great way for everyday people to protect the Earth and fight against climate change. Even if your city or town doesn't yet pick up food scraps or green waste for composting, you still compost at home or help start a community composting program!

One cool way to do this is through worm composting. The official word for this is vermicomposting, and it's a lot easier than it may sound. Here's a 4 minute video from TEDEd on "Vermicomposting: How worms can reduce our waste" where you can get the basics on how worms compost our food.

"But what does this have to do with coding?" you might be thinking.

Coding can help bring to life things that might seem complicated, or dry ("vermi... what?") and turn it into a fun game that people want to play! We can "gameify" learning about topics, like how math apps can turn multiplication problem into epic battles of your avatar against monsters.

In today’s project, we are going to build a game about worm composting. Your final project might end up looking something like this:

 

 

Press the green flag to play, and use the arrow keys to control the worm and eat the food scraps.

Ok, let’s get coding! 

Watch the videos below to get started, and follow along with me to build your own Worm Composting Game.

Part 1: Getting the art together

In the example version of the game, we use a composting symbol that was created by the community organization WeCompost2 (learn more about them below); it appears when the player wins the game. You can end the game with a composting symbol/image/message of your own creation!

Go to https://scratch.mit.edu/ and create a new project. No log-in required to code, but if you want to do remixes or save your project for later, you'll need a log-in.

Part 2: Coding our worm, apple and the win

Congratulations on completing your vermicomposting game and spreading the word about the super powers of the mighty worm!

Bonus Challenges: If you want to do even more to your game, can you design and add different kinds of food scraps (like banana peels) that are worth different amounts of points? You could even add items that are NOT compostable by worms (like plastics) that give the player negative points and need to be removed.

Do you want to know what worm composting looks like in real life? Watch the video below to visit the farm with WeCompost2, an incredible organization that we work with (one of our students is making their website!)

Want to go beyond Hour of Code? Learn to build a Road Game in Scratch.

If you had fun, check out our YouTube channel for more free coding projects like these! Go to youtube.com/codespeaklabs