ICC
< back to sketch

//float i=0.0; float a=0.1;
float x,y;
int x_dir, y_dir;
float x_speed, y_speed;
float fraction;

void setup(){
  size(300,300);
  x=0;
  y=0;
  x_dir=1;
  y_dir=1;
  x_speed=1.5;
  y_speed=1.5;
  fraction=0.1;
}
void loop(){
  println(x_speed);
  background(255,255,255);
  noStroke();
  fill(0);

  x+=(x_dir*x_speed);
  y+=(y_dir*y_speed);
  ellipse(x,y,10,10);
  if(x>290||x<=0){
    x_dir*=-1;
  }
  if(y>290||y<=0){
    y_dir*=-1;
  }
  if(x_speed>3.0||x_speed<=0.0){
    fraction*=-1;
  }
  x_speed+=fraction;

  /*
  i+=a;
  fill(i*10,0,0);
  rect(sin(i)*100+150,cos(i)*100+150,10,10);
  fill(0,i*10,0);
  rect(i*15,sin(i)*100+150,10,10);
  //rect(-sin(i)*100+150,-cos(i)*100+150,10,10);
  //rect(i*10,cos(i)*50+100,10,10);
  //ellipse(270-(i*10),random(i)+100,30,30);
  //ellipse(270-i*10,200,30,30);
  if(i>27){
    a=-0.1;
  }
  else if(i<=0){
    a=0.1;
  }
  */
}

< back to sketch