Return to site

Build a Grow a Plant! 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.

 

Hi! I’m Joskaris, and I’m a high school senior working with CodeSpeak Labs through the Abretech program for first-generation immigrant students. Welcome to my Scratch tutorial for the game I created! I’m excited to share my love of coding with all of you– I believe anyone can learn to code.

Scratch offers an excellent platform for creating interactive games, and this flower game celebrates the beauty of nature. Flowers have always held a special place in human culture, representing beauty, love, and peace. They also play a vital role in our ecosystem, providing food, shelter, and habitat for countless insects and animals. Taking care of flowers is crucial for their growth, just as it is for the well-being of our planet. This game is an engaging and educational way to explore the wonders of nature and the importance of nurturing it.

This game uses event blocks and a point system to simulate the growth of a tiny seed to a fully grown flower! You might even want to get creative and design your flower with your own special flair.

Here’s an example of what your final project could look like. After you click the green flag, drag the little seed to the soil. It will pixelate and disappear, and a watering can and a bag of flower food will appear. Click on the watering can and flower food, which will make those items move to the soil and accumulate “growth” points. As you reach different growth point levels, the plant will grow!

Ok, let’s get coding!

Watch the videos below to follow along with me to build your own Grow a Plant! Game. I recommend pausing the video after each step to check that you have all the code.

Part 1: Make your custom sprites

You’ll need to go to https://scratch.mit.edu/ to 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 to create a log-in with your grown-up’s permission.)

In this video, you’re going to learn to use art tools to make “sprites”. A sprite is an object that can be programmed to move, interact with other objects, and respond to user input, like button presses or mouse clicks.

You’ll be drawing these sprites with the built-in art editor:

1. Dirt: This sprite is the most complicated. It will grow into the full plant with “costumes”, different versions of the sprite design. You’ll have a costume for the initial soil, then the seedling, then the growing plant, and then finally the plant with a flower. It will have 4 costumes total, while the other sprites only have 1 each.

2. Seed

3. Watering can

4. Flower Food

You can design your sprites any way that you like! The most important thing is that your “dirt” sprite has costumes that show the phases of growth of your plant.

Part 2: Code the Game

Now we’re going to add code to all of our sprites.

You’ll be using event blocks. An event script is a coding block that checks for specific events which trigger more code to run. This means that it will wait until a specific event happens before it runs the code.

You’ll also be using a variable; in coding, variables are containers that holds a value, like how a flower pot holds a flower! In our game, we will call our variable “growth” because we’ll use it to tell the computer when the plant should grow.

(Pro-tip: After you code your Watering Can, you’ll copy your code to the Flower Food. There’s more than one way to do this; the way I do it in the video is by using the keyboard short-cut Ctrl + C to copy, and then Ctrl + V to paste.)

Make sure you test your code, and feel free to rewind the videos to any point if you need help finding a bug– or mistake– in your code. Finding and fixing bugs is one of the best ways to learn!

Congratulations on successfully completing your very own plant growing game.

As a bonus challenge, add another way to nurture your plant. We currently have plant food and water. You could add a Sun sprite, or anything else that could stimulate the plant growth.

Further learning

The videos below will help improve your knowledge on plants and how they grow:

Want to go beyond Hour of Code? Learn to build another Scratch project about the environment: Build a Composting Game.

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