Friday, 4 March 2011

_03_Variables

//Same as before...
void setup() {
  size( 480, 800 );
  background( 0 );
}

//This time the draw function is a little different.
//The position of the rectangle isn't a fixed number.
//Instead the built in values 'mouseX' and 'mouseY'
//are used.  These two values store the left-to-right
//position of the mouse cursor (mouseX) and the top-to-bottom
//position of the mouse (mouseY).  The values of 'mouseX' and
//'mouseY' change as the mouse moves about so they are called
//"variables".  You can create your own variables to store
//any information your program needs.
void draw() {
  fill( 255 );
  rect( mouseX, mouseY, 80, 80 );
}

No comments:

Post a Comment

Note: only a member of this blog may post a comment.