topical media & game development
graphic-processing-learning-06-example-6-7-example-6-7.pde / pde
// Learning Processing
// Daniel Shiffman
// http://www.learningprocessing.com
// Example 6-7: Local variables
void setup() {
size(200,200);
// x is not available! It is local to the draw() block of code.
}
void draw() {
background(0);
int x = 0;
// x is available! Since it is declared within the draw() block of code, it is available here.
// Notice, however, that it is not available inside draw() above where it is declared.
// Also, it is available inside the while block of code because while is inside of draw().
while (x < width) {
stroke(255);
line(x,0,x,height);
x += 5;
}
}
void mousePressed() {
// x is not available! It is local to the draw( ) block of code.
println( " The mouse was pressed! " );
}
(C) Æliens
20/2/2008
You may not copy or print any of this material without explicit permission of the author or the publisher.
In case of other copyright issues, contact the author.