How To Make A Lives Variable On Scratch

How to make a cloud variable on scratch

Creating a Multiplayer Game This article or section may not have content matching Scratch Wiki editing standards. Please improve it according to Scratch Wiki:Guidelines and Scratch Wiki:Editing Conventions. Apr 04, 2014  How to create lives in Scratch for a simple Platformer. (These videos are silent to avoid noise in the classroom.).

Scratch
Home‎ > ‎Middle School‎ > ‎

Variables and Expressions in Scratch

Learning Targets:

I will be able to describe how variables work in a computer program and how they are different from variables in other situations.
I will create a useful computer program that does multi-step calculations using variables.
I will be able to describe other computer programs that probably use variables.

Common Core Standards:
CCSS.MATH.CONTENT.6.EE.A.2
CCSS.MATH.CONTENT.7.RP.A.3

What is a variable? Describe some situations in which you've used variables.
Variables in computer science are a named location where you can store information. In Scratch and many other programming languages, there are two ways to use a variable. You can store information in it, or you can read what's already there.
Read through the warm up script with a small group or a partner. Determine the purpose of the script and what the cat will say. Identify where you see the script is storing information in a variable, and where it's retrieving what's already there.

The 'set' block stores a value in a variable. The ellipse-shaped blocks read what is already there. Some steps do both. In this case (for example: Set weight on earth to weight on earth + answer), the block reads what's already in the variable, evaluates the operation, then stores the new value in 'Weight on Earth'. The old value in 'Weight on Earth' is gone at this point, replaced by a new value. Run the program step by step to see this happen.
In Scratch, you can go to the 'Data' drawer to create a variable. After you've created one, you see the 'set' and 'change' blocks, as well as the ellipse you use to read the value of a variable. You can choose to show the variable on the screen to see how its value changes as you run your program.

Work Time:
This is a partial script that will solve an age-related math problem. It should look similar to some problems you've seen before in math class. It's not done, however.
If Ben is 10, how old is Dana? (14, because three years ago, Ben was 7. Dana is twice as old as that)
If Ben is 15, Dana is 24. (three years ago, Ben was 12. Double that to get 24)
With a partner or small group, use Scratch to complete this program. Use the 'Data' drawer to create variables and use the 'Operators' drawer to get access to the math and text operations you need.
Summary:
Have students share their solutions. Some students may have solved for Dana's age in two steps, as these students did.
Other students may have written one expression composed of other expressions. This is similar to using parentheses in an 'order of operations' expression. The nesting of the expressions really matters. Students that nest the operations in a different way may find their answers don't make sense.


If you choose to do one of the optional projects with students, consider using pair programming. This video explains how pair programming makes coding better for you and for the computer.


Students should create their own program that asks for the cost of an item, then adds tax (find the rate for your city) and tells you the total cost of the item with tax. For an advanced task, the character should ask for the cost of two items, add tax to both, and report the grand total.
The video below is an example program that asks for the cost of an item and subtracts a percent discount. You can use some of the same ideas in your program.
Grading rubric for project:
4: Program correctly calculates tax and total for two items added together, using variables.
3: Program correctly calculates tax and total for one item using variables.
2: Program shows understanding of variables or tax, but does not produce correct output.
1: Program shows little understanding of variables.

Optional Project 2:
This project is less scripted and may involve more creativity. Students should pick a word problem challenge from the document below.


Students should work with a partner to design a Scratch program that addresses the word problem. It should use variables so you can enter different values every time, solving an infinite number of math problems.

When experimenting in Scratch on your Raspberry Pi, maybe you want to make the sprite do something like jump when you press one key, hide behind another sprite when you press a different key, or bounce before it hits the edge.

How To Make A Lives Variable On Scratch 1

To do that, you need to know where it is. And you have to be able to change where it is. You can do this in Scratch using variable blocks.

A variable is like a box that holds a number. The box has a name, so you can tell it from other boxes. And it has space for a number.

Variables can remember letters, words, and sentences, too.

Using variables in Scratch

Scratch can do three clever things with variables. The first is make them. Variables have special blocks, and when you make one variable, you get some special blocks to help you use it. You can set the variable to a number or add a number to it.

When you make a variable, it appears on the stage. You don’t always want this, so you can use a hide variable block to make it go away. And you can use a show variable block to make it come back. Realguitar classic.

The second clever thing is math. You can add, subtract, multiply, and divide variables by some number. You can even add, subtract, multiply, and divide one variable by another!

The final clever thing is best of all. You can use a variable wherever you see a number. For example, you can tell a go to block to use a variable you make. When you click the go to block or when Scratch reaches it in a script, the block moves the sprite to the number stored in the variable.

This gives you way more options than moving a sprite to the same place all the time. You can change the numbers by hand. Or with math. Or by making them follow other numbers, like the position of some other sprite.

How To Make A Lives Variable On Scratch 2

Making a variable in Scratch

To make a variable, click the darker orange Variables button at the bottom right of the block types in the block list area. Three buttons appear. You can click them to

How To Make A Variable On Scratch 2

  • Make a variable

  • Delete a variable

  • Make a list

A list is a special kind of a variable that holds other variables. It’s like a big box with lots of smaller boxes inside it. They’re numbered so that you can tell them apart and do things like get the third box and change what’s inside it. You can ignore lists for now.

To make a new variable

  1. Click the make a variable pattern.

    You see a window like the one in the following figure.

    Mar 19, 2017  Question: Q: How do you recover deleted GarageBand songs on iPad? One of my GarageBand songs got deleted and I'm wondering if there is any way to get it back. I have the most recent version of garage band, and I put it on iCloud but then took it off before it got deleted. https://lednin.netlify.app/how-to-recover-deleted-garageband-projects-on-ipad.html.

  2. Typesprite1_xinto the Variable Name? box.

  3. Leave the For All Sprites option checked and click OK.

    Whoa! Stuff happens! Scratch makes some new blocks. And if you look at the stage, you’ll see a box appears, with the name of your variable sprite1_x and a number.

How To Make A Speed Variable On Scratch

When you make a new variable, the number is always 0 because you haven’t changed it yet. The following figure shows what you get.

How To Make A Lives Variable On Scratch Youtube

Can you use variables to replace any number? You totally can! You can use a set block to set a variable to the value of another variable. In a change block, you can make the by value a variable. You can make scripts that are really smart, with variables passing values to other variables between sprites all over the stage. There are almost no limits to what you can do.