2020年3月26日 星期四

想睡的心與肥胖跟球球一起無限膨脹

Bubble [] b=new Bubble[1000];//set-->int []x=new int[1000]
int n=0;
void setup(){

  size(400,400);
}

void draw(){
  int i;
    background(255);
    for(i=0;i<n;i++)
    {
      b[i].drawAndUpdate();
    }
    if(mousePressed)
    {
      b[n-1].r++;
    }

 }

 void mousePressed(){
   b[n]= new Bubble(mouseX,mouseY,10);
   n++;


 }

上面是主程式啦
下面結構放到New Tab

class Bubble{//Struct(C)-->in JAVA turn into class
  int x,y,r;
  color c;

  Bubble(int _x, int _y, int _r){
 
    x=_x; y=_y; r=_r;
    c=color(random(255),random(255),random(255));
}


void drawAndUpdate(){

     fill(c);
     circle(x,y,r);
     y--;
  }
}


然後你就可以得到球球
跟我沒救的體重和絕望的心一直膨脹嗷嗷嗷嗷

沒有留言:

張貼留言