Transcript
Fast and Furious Objects
Variables and Movement
Do this
Write the program in the video (below) and test it.
Change the value that is added to the variable. Test a negative value as well. There are two examples below.
ballX = ballX + 5;
ballX = ballX - 1;
What does "int" mean in the expression int ballX = 0;
The more the variable increases, the...
Educator notes
Variables make it possible to store information. In a way, variables are a tool to make the shapes and objects intelligent because they’re now able to “remember” their previous locations and can act based on that information.
Variables may be hard to understand. You can use different metaphors and techniques when you explain them. Variables can be described as boxes that have a name and contain a value inside them. The computer just opens a certain box and uses the value in the program.
Activity: You can also have a playful activity where students are given roles to act as ballX or ballY. You can then perform some calculations while the students keep track of the value of their variables. You can take the role of the main program yourself. When you want to use a variable, you have to call for a student to come by and tell the current value.
A Meteor, Pipe or a Raindrop?
Do this
Write the raindrop-program in the video (below) and test it. Choose your own filling color.
Also try putting the variable “meteor” inside the fill command to change the color-values!
What happens when you use the variable "meteor" as a parameter of fill-command?
Educator notes
Usually a variable is used to perform only one specific task with a name given accordingly, such as xLocation
or speedY
(or e.g. scoreCount
, if you are programming games.) But if you consider the visual expression, it’s sometimes fun and fruitful to just play with variables and use them creatively without knowing the exact result beforehand. It may lead to surprising results and new ideas!
Nevertheless, it’s good to add comments to the program after experimenting and explain what the different variables and parts are meant for.
Practicing Variables
Do this
Complete the five multiple-choice -questions below and continue
forward!
What does the program above draw?
What does the program above draw?
What happens in the program animated above?
What happens in the program animated above?
Educator notes
This part contains several multiple choice questions. First, students are asked to think of what kind of a visual result would a certain program produce. Then they are asked the opposite - what is a possible program behind a given visual result. It’s a handy tool to see the logical patterns behind visual phenomena while on the other hand, learning to see code in a visual form. These kind of thinking processes are important for an visual art programmer!