~ ยานบินหลายๆคัน? โดยใช้ loop ~
void setup(){ //function ที่จะเรียกใช้เอง ไม่ต้องเขียนเรียกใช้
size(700,200);
}
void draw(){ //function เรียกใช้อัตโนมัติหลัง setup
background(0);
noStroke();
int x = 90;
int y = 100;
int p = 24;
int r = 12;
int space = 170;
int n=4;
int count = 0;
//loop
while(count<n //จะวนกลับมาวาดอีก 4 ครั้ง คือ count 0,1,2,3 ){
fill(22,198,245);
ellipse(x,y-10,70,70);
fill(60,24,183);
ellipse(x,y,150,50);
fill(255);
ellipse(x,y,r,r);
ellipse(x-p,y,r,r);
ellipse(x-2*p,y,r,r);
ellipse(x+p,y,r,r);
ellipse(x+2*p,y,r,r);
x=x+space; //กำหนดค่า x = x+space
count = count+1; //วนกลับไปวาดใหม่
}
}
ไม่มีความคิดเห็น:
แสดงความคิดเห็น