Hey guys,
So can someone give a paragraph explaining what the variables (the orange blocks) are.
I don't quite understand what they are
Thanks.
Last edited by joletole (2012-03-06 16:19:57)
Offline
joletole wrote:
Hey guys,
So can someone give a paragraph explaining what the variables (the orange blocks) are.
I don't quite understand what they are
Thanks.
Explaining really won't help, but I'll try.
In essence, they are anything.
Offline
Variables are a way to store numbers or words. When you create a variable and give it a name, you have created a place in the computer that can remember things for you. You use the name to get at the contents of it (kind of like your home address gets you to your mailbox). You can change the contents using the "Set Variable to" block.
So what do we use variables for? Well, lots of things, but these are the typical uses:
1) To remember something that happened in one part of the program for use later in the program.
2) To communicate between different sprites (usually by making the variables "For all sprites" meaning all sprites can see their values and change them)
3) To make it so that you can set a value one place...and then use it in many places, like the speed of a sprite.
Make a few and play around...you'll figure it out pretty quickly
Oh, and here's a gallery with a couple of projects on variables and lists that you might find helpful.
Offline
Paddle2See wrote:
Variables are a way to store numbers or words. When you create a variable and give it a name, you have created a place in the computer that can remember things for you. You use the name to get at the contents of it (kind of like your home address gets you to your mailbox). You can change the contents using the "Set Variable to" block.
So what do we use variables for? Well, lots of things, but these are the typical uses:
1) To remember something that happened in one part of the program for use later in the program.
2) To communicate between different sprites (usually by making the variables "For all sprites" meaning all sprites can see their values and change them)
3) To make it so that you can set a value one place...and then use it in many places, like the speed of a sprite.
Make a few and play around...you'll figure it out pretty quickly
Oh, and here's a gallery with a couple of projects on variables and lists that you might find helpful.
Perfect description.
Offline
Paddle2See wrote:
Variables are a way to store numbers or words. When you create a variable and give it a name, you have created a place in the computer that can remember things for you. You use the name to get at the contents of it (kind of like your home address gets you to your mailbox). You can change the contents using the "Set Variable to" block.
So what do we use variables for? Well, lots of things, but these are the typical uses:
1) To remember something that happened in one part of the program for use later in the program.
2) To communicate between different sprites (usually by making the variables "For all sprites" meaning all sprites can see their values and change them)
3) To make it so that you can set a value one place...and then use it in many places, like the speed of a sprite.
Make a few and play around...you'll figure it out pretty quickly
Thanks! (and did you see that comment I left on one of your projects)
Offline
To put it simply, a variable is something which can store a value (whether it be the score, number of lives, or the player's name), and is used within the project (for calculations, or on the stage by having a variable display with the checkbox next to the variable).
In math, you may have learned (or will probably learn soon) about variables. Let's say we have a variable named "x". It can be any number we want. We don't know it's value. However, let's also say we are given this equation: x + 2 = 5. When we add 2 to x, we have to get 5. What could x be? It has to be 3! 3 + 2 = 5 (So it's sort of like a puzzle!) In Scratch, it has a similar role, but we don't have to do any puzzle solving - we just use them to hold values, like scores.
As a brief example for how to use variables, let's look at this example, with the variable "score".
when gf clicked set [score v] to [0] //The score goes back to 0 each time you play. forever if <touching [coin v]?> change [score v] by [1] //The score increases when you get a coin! when I receive [game over v] //This tells you your score. say (join [Your score was ] (join (score) [. Good job!]))This is just the beginning. Variables can be used together and in a wide variety of ways. Play around yourself by experimenting, and looking at sample projects! For an in-depth explanation about variables, read this article on the Scratch Wiki.
Last edited by Lucario621 (2012-03-06 16:44:28)
Offline
Lucario621 wrote:
To put it simply, a variable is something which can store a value (whether it be the score, number of lives, or the player's name), and is used within the project (for calculations, or on the stage by having a variable display with the checkbox next to the variable).
In math, you may have learned (or will probably learn soon) about variables. Let's say we have a variable named "x". It can be any number we want. We don't know it's value. However, let's also say we are given this equation: x + 2 = 5. When we add 2 to x, we have to get 5. What could x be? It has to be 3! 3 + 2 = 5 (So it's sort of like a puzzle!) In Scratch, it has a similar role, but we don't have to do any puzzle solving - we just use them to hold values, like scores.
As a brief example for how to use variables, let's look at this example, with the variable "score".when gf clicked set [score v] to [0] //The score goes back to 0 each time you play. forever if <touching [coin v]?> change [score v] by [1] //The score increases when you get a coin! when I receive [game over v] //This tells you your score. say (join [Your score was ] (join (score) [. Good job!]))This is just the beginning. Variables can be used together and in a wide variety of ways. Play around yourself by experimenting, and looking at sample projects! For an in-depth explanation about variables, read this article on the Scratch Wiki.
Nice examples!
Offline