Wednesday, October 6, 2010

Quiz 2 - Moving Ball ( Programming for Artists )

int mouseW = 80;     // interger varible name = starting value
int mouseH = 80;
int Ypos= 1;
int flag=0;
void setup() { //function that is called one when the program starts
  size(480, 480);
  smooth();
  //noStroke();\
  background(100);
}


void draw() {     //function that is continually called ==loops
  //if statement if true executes code between {}
  //   fill(random(255), random(255), random(255));//sets fill color


  if   (flag==0) {
    if (Ypos>=480) flag=1;
    Ypos+=10;
    background(100);
  }
  else {
    if (Ypos<10) flag=0;
    Ypos-=10;
  }
  //changes the height of the ellipse


  ellipse(200, Ypos, 80, 80);
}

No comments:

Post a Comment