BIRD
int value =1;
int cenywing=250;
int ceny=250;
int cenx=250;
void setup() {
size(500, 500);
}
void draw() {
frameRate(40);
background(255);
if (value==1) {
background(#DD0000);
}else {
background(#00DD00);
}
draw_bird();
//make the bird fly
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 wing_L=100;
int radius_head=50;
strokeWeight(10);
//right wing
line(cenx, ceny, cenx+wing_L, cenywing);
//left wing
line(cenx, ceny, cenx-wing_L, cenywing);
ellipse(cenx, ceny, radius_head, radius_head);
}
int cenywing=250;
int ceny=250;
int cenx=250;
void setup() {
size(500, 500);
}
void draw() {
frameRate(40);
background(255);
if (value==1) {
background(#DD0000);
}else {
background(#00DD00);
}
draw_bird();
//make the bird fly
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 wing_L=100;
int radius_head=50;
strokeWeight(10);
//right wing
line(cenx, ceny, cenx+wing_L, cenywing);
//left wing
line(cenx, ceny, cenx-wing_L, cenywing);
ellipse(cenx, ceny, radius_head, radius_head);
}
ไม่มีความคิดเห็น:
แสดงความคิดเห็น