程式碼:
PVector[] cup = new PVector[3]; PVector[] cupV= new PVector[3]; int guess; void setup() { size(400, 300); for(int i =0;i<3;i++) { cup[i] =new PVector(100+i*100, 100); cupV[i] =new PVector(random(4), random(3)); } guess = int(random(3)); println(guess); } void draw() { background(255); for(int i=0;i<3;i++) { cup[i].add(cupV[i]); if(cup[i].x<0 || cup[i].x>400) cupV[i].x*=-1; if(cup[i].y<0 || cup[i].y>300) cupV[i].y*=-1; fill(255); ellipse(cup[i].x, cup[i].y, 90, 60); } }
沒有留言:
張貼留言