Day 4: Open Your Own Shop!
Day 4 of coding! You are doing fantastic!
Today you are going to make a store or shop of any kind. Scratch provides many backdrops that allows you to make projects like a pet shop or a bakery. You can also create your own backdrop using the paint and draw functions on the “backdrop” tab of your project.
Instead of making a remix, you will be creating your own project this time!
The goal of this lesson is to have you learn how to use variables. Variables are at the bottom of the list of Scratch blocks on the left column. Money, for example, is a variable that you have to create and will be using. A variable is something that changes. In our case, your money variable would start at a certain value and decrease every time something is purchased.
Ex: The player starts with $100, and every time he or she buys an apple, the total amount of money falls by $1. The change in money is -1.
Find the section in the list of blocks for variables. Make sure you make a new variable before you can use it!
(Check out the slideshow at the bottom of the page for a more thorough explanation of variables and a brief summary of how to use variables on Scratch.)
These are a few main blocks to keep note of:
Here is an example Refrigerator Shop that our team has made. Feel free to play around with it until you get a feel for what's going on. Watch the variables as they change!
Welcome to Dhwani's fridge! For now we're only stocked with apples and bananas...¯\_(ツ)_/¯ click on them to add them to your purchase in any combination.
You always start with $10. Click the green dollar sign to gain more money if you need some. How much money do you make by each click? (Watch closely... possibly a trick question!)
How are variables used in this shop program? Here, we have one keeping track of money you have left to spend, one for the number of apples you've bought, and one for how many bananas you've bought. As these variables change, and reach certain values, see what may happen as a result. What conditions had to be met for different events to happen?
Also, be sure to check out the code behind the project, here. It's a bit complex, so don't feel pressured to get this far so quickly. But perhaps get some ideas from the way we've set up our shop!
We call the new, really important tool that all of you would use to count money a variable. As mentioned earlier, variables can be measured, counted, changed, and labeled. They are essential in computer science, math, and science, and help us understand how our world is always changing.