2020年3月12日 星期四

第2週程式設計

int x=0,y=0;
void setup(){
  size(400,600);
}
void draw(){
  background(255);
  circle(x,y,10);
  y++;
  if(mousePressed){
    x=mouseX;
    y=mouseY;
 
  }
}




void setup(){
  size(400,600);
}
void draw(){
  if(mousePressed){line(mouseX,mouseY,pmouseX,pmouseY);
  }
}



int []x={0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0};
int []y={0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0};
int n=0;
void setup(){
  size(400,500);
}
void draw(){
  background(255);
  for(int i=0;i<n;i++){
    circle(x[i],y[i],10);
    y[i]+=3;
    if(y[i]>=500-10) y[i]=500-10;
  }
}
void mousePressed(){
  if(n<20){
  x[n]=mouseX;
  y[n]=mouseY;
  n++;
}
}










沒有留言:

張貼留言