int value =1;
int cenywing=250;
int ceny=250;
int cenx=250;
void setup() {
size(500, 500);
}
void draw() {
int n=5;
int count=1;
int posX=50;
int posY=-100;
background(255);
frameRate(40);
background(255);
if (value==1) {
background(#DD0000);
} else {
background(#00DD00);
}
while (count<n) {
draw_bird(posX, posY);
count=count+1;
posX=posX+50;
posY=posY+100;
}
ceny=ceny+value;
cenywing=cenywing+(value*2);
if (ceny>280&&cenywing>290) {
value--;
} else if (ceny<200&&cenywing<220) {
value++;
}
if (cenx>500) {
cenx=cenx%500;
}
if (keyPressed) {
if (key=='d'||key=='D') {
cenx+=3;
}
}
}
void draw_bird(int posX, int posY) {
int wing_L=100;
int radius_head=50;
strokeWeight(10);
//right wing
line(cenx+posX, ceny+posY, cenx+wing_L+posX, cenywing+posY);
//left wing
line(cenx+posX, ceny+posY, cenx-wing_L+posX, cenywing+posY);
ellipse(cenx+posX, ceny+posY, radius_head, radius_head);
}
ไม่มีความคิดเห็น:
แสดงความคิดเห็น