Water Use Calculator

Draw a Chart

Let’s draw a chart to help the user understand the quantities of water more easily than if you just told them all the numbers.

Make two new sprites called Tap and Toilet. Select this costume for both:

The grey rectangular button costume

Rename a sprite in Scratch

To rename a sprite in Scratch, click on the sprite:

screenshot

The information about the sprite will be displayed above:

screenshot

Edit the name of the sprite.

Draw on the costumes to add descriptive text to them. The Tap will be labelled with “Tap running for 1 minute” and the Toilet with “Flushing the toilet”. To add text to your costume you can click on the T icon:

The T icon for adding text to a picture

Place the two sprites one above the other on the left hand side of the stage:

The two button sprites placed at the left edge

Add another costume to your cat sprite, choosing the glass of water from the library.

The glass of water costume

Then add the following blocks to the end of your code:

sayHow about brushing your teeth?for2secondssayIt can be tempting to leave the tap running while you brush. But did you know...for4secondssay...a running tap loses 6 litres of water per minute?for3secondsswitchcostumetoglass water-asetsizeto35%

Click the green flag to test your program.

Do I have to wait for the old code to run all the time?

If, like me, you don’t want to go through the whole program every time you want to test a new bit of code, then you can move the parts you don’t need out of the way for the moment!

  • Detach all the code from the previous card from the green flag block and drag it off to one side — but don’t get rid of it entirely! Just leave it in a space on the current sprite panel.

The code moved to one side away from the green flag

  • Then attach your new code directly onto the green flag.
whenclickedsayHow about brushing your teeth?for2secondssayIt can be tempting to leave the tap running while you brush. But did you know...for4secondssay...a running tap loses 6 litres of water per minute?for3secondsswitchcostumetoglass water-asetsizeto35%
  • When you’re ready, you can put everything back together again.
whenclickedsettotalWaterto0setsizeto80%switchcostumetomonkey-aaskHow many times do you flush the toilet each week?andwaitsetflushestoanswerchangetotalWaterbyflushes*6askHow many minutes do you usually spend in the shower?andwaitsetshowerMinutestoansweraskHow many showers do you have per week?andwaitsetshowerstoanswerchangetotalWaterbyshowers*showerMinutes*7sayYou use...for2secondssayjointotalWater litres of water per week!for5secondssayHow about brushing your teeth?for2secondssayIt can be tempting to leave the tap running while you brush. But did you know...for4secondssay...a running tap loses 6 litres of water per minute?for3secondsswitchcostumetoglass water-asetsizeto35%

Note: you should be careful when doing this, as sometimes there might be blocks that you need to run in the code you’re moving aside — you’ll need to keep them in your script to avoid problems!

To use the Pen blocks in Scratch, you need add the Pen extension.

  • Click on the Add extension button in the bottom left-hand corner.

add extension button highlighted

  • Click on the Pen extension to add it.

pen extension highlighted

  • The Pen section then appears at the bottom of the blocks menu.

pen extension blocks

Add the following blocks to the end of your script. You’ll find the stamp block in the Pen category.

gotoTapmove45stepsrepeat6move20stepsstampwait0.5seconds

Click the green flag to watch your new animation!

Note: You might need to change the move 45 steps to another number depending on the size of your Tap sprite. The purpose of this block is to place the glass beside the text so you can see it.

How does it work?

The stamp block makes a sprite stamp an image of itself onto the stage.

It draws the image straight onto the background, so no new sprites are created.

You can double-click the clear block to remove everything that was added with Pen blocks.

When you run your code again, you’ll see that the stamped glasses are still there at the start. To clear them away, add the clear block to the top of your script, right after the green flag. You can reset the position of the sprite to the centre as well using a go to block.

whenclickederaseallgotox:0y:0

Add similar code to make the sprite illustrate the amount of water that’s used by flushing the toilet (remember, one flush uses 6 litres).

I need a hint

  • Use the go to mouse-pointer block to move the sprite to the correct sprite, and select the sprite by clicking on the little triangle in the block.

  • Repeat the stamp code 6 times, which is the number of litres of water used per flush.

  • Here is the code you need to add:
gotoToiletmove45stepsrepeat6move20stepsstampwait0.5seconds