Codekids Lesson 4Variables & Hacking |
In the last lesson, you learned how to make circles using the ellipse() command. Your Seventh ProgramStart up Processing and copy this code into the program:
You should see something like the bullseye pattern above. This sketch uses two new and very powerful things:
The VariableThe variable is called circleSize. It is like special envelope that can hold any number you want to put into it. We start by putting the number 400 into it: int circleSize = 400; Here is how to say this command. Repeat after me: "the int variable circleSize gets 400" Yup, that's right, the equals sign is pronounced "GETS" in computer-speak. That's because == is used for "equals." The word "int" is short for INTEGER, which is a fancy computer word for "regular counting number." The While loopThe while loop is the part that says this:
What does it mean? Here's a translation for you: As long as (the number in the variable circleSize is greater than 50) {
} Keep doing this until you subtract circleSize down below 50
It starts with while followed by (circleSize > 50). Then, everything inside the curly braces, { } is the stuff inside the while loop.
We're going to act this out in class so you can start to understand how it works. Hack your ProgramNow that you've got your seventh program running, do these things:
If you create something cool, copy it out of Processing and email it to me! |
|
|
|
|