Day 5: Improve Your Shop!
We are on the fifth day of fEmpower! You got this!
As you're working on your store or shop, let’s try to make it more complicated.
Add items with different values! To get an idea, this could mean cookies that cost $1 and cakes that cost $10, or a dog that costs $40 with chickens that cost $15. Repay yourself! Every few seconds, have your character, or you, gain some money back after spending a certain amount or when you reach $0.
Another important question to consider this time is… what happens when you run out of money? You can’t physically have a negative amount of money, so how can you show that in your game? Use a control block, or a condition, so that when your money variable hits $0, the game screen changes backdrops to tell you that you ran out of money.
Hint: You may need to “hide” some items when the backdrop changes. So, find a block that does that along with setting the appropriate condition!
Here are some new blocks to pay attention to for this project:
Good luck! And as always, challenge yourself and have fun!
Here is an example of a more complicated store: A more complicated pet shop
Finding the total amount of money spent or gained in the program requires the use of operators in your code. Operators can add, subtract, multiply, divide, compare values, and many more. They help you do the “math” part of your code.
Instructions & Notes
Click the green flag to see how to interact with this example wizard shop. You begin with $15 in the money variable and this value changes as you attempt to buy items.
Click here to see inside at the code. There are conditional statements controlling when to show the "descriptions" for items as you hover over them. Other conditionals are also checking to see if you have enough money whenever you try to buy something. Note also how some conditionals use variables (for your money and item prices), and a few different operators.
A side note: there's an extra "list" feature -- it's like a variable, but ... a list of values! it's able to hold some text values.