class diagram
Name: UFO
Attribute: x:int
y:int
r:int
Method: UFO(e:int,f:int,t:int)
display()
click()
int count=0;
int r =0;
void setup () {
size(400, 400);
}
Draw a = new Draw (50, 50, 0);
void draw() {
background(0, 0, 255);
a.display();
}
class Draw {
int x;
int y;
int r;
Draw(int e, int f, int t) {
this.x=e;
this.y=f;
this.r=t;
}
void display() {
if (r<120) {
if (count==0) {
x=x+5;
}
if (x==250) {
count=1;
}
if (count==1) {
y=y+5;
}
if (y==250) {
count=2;
}
if (count==2) {
x=x-5;
}
if (x==50) {
count=3;
}
if (count==3) {
y=y-5;
}
if (y==50) {
count=0;
r=r+1;
}
noStroke();
fill(0, 255, 0);
ellipse(x, y, 100, 130);
fill(255, 255, 0);
ellipse(x, y+4, 150, 90);
}
}
}
ไม่มีความคิดเห็น:
แสดงความคิดเห็น