float bird_y;
int size_draw = 40;
boolean wing_up;
boolean wing_down;
int max_bird = 3;
void setup() {
size(600, 600);
background(255);
mouseX=width/2;
mouseY=height/2;
wing_up = true;
}
void draw() {
int present_bird = 1;
int X = 0;
int Y = 0;
background(255);
if (mouseY<size_draw*2) {
mouseY=size_draw*2;
}
if (mouseX<size_draw) {
mouseX = size_draw;
}
while (present_bird <= max_bird) {
draw_bird(mouseX+X, mouseY+Y, size_draw, bird_y);
X += size_draw*3;
if (present_bird%4==0) {
X=0;
Y-=size_draw*1.1;
}
present_bird++;
}
if (wing_up == true) {
wing_y-= size_draw*0.15;
bird_y-= size_draw*0.01;
if (wing_y <= -(size_draw*0.7)) {
wing_up = false;
wing_down = true;
}
}
if (wing_down == true) {
wing_y+= size_draw*0.15;
bird_y+= size_draw*0.01;
if (wing_y >= (size_draw*0.7)) {
wing_up = true;
wing_down = false;
}
}
}
void draw_bird(float mouse_x, float mouse_y, float s_draw, float bird_y) {
fill(#D30327);
strokeWeight(s_draw*0.2);
line(mouse_x, mouse_y-(s_draw*0.5), mouse_x-(s_draw*1.3), mouse_y+wing_y-(s_draw*0.5));//left wing
line(mouse_x, mouse_y-(s_draw*0.5), mouse_x+(s_draw*1.3), mouse_y+wing_y-(s_draw*0.5));//right wing
strokeWeight(s_draw*0.05);
ellipse(mouse_x, mouse_y-(s_draw*0.5)+bird_y, s_draw, s_draw);//body
strokeWeight(1);
fill(255);
ellipse(mouse_x-(s_draw*0.22), mouse_y-(s_draw*0.6)+bird_y, s_draw*0.3, s_draw*0.35);//left white eye
ellipse(mouse_x+(s_draw*0.22), mouse_y-(s_draw*0.6)+bird_y, s_draw*0.3, s_draw*0.35);//right white eye
fill(0);
ellipse(mouse_x-(s_draw*0.22), mouse_y-(s_draw*0.6)+bird_y, s_draw*0.1, s_draw*0.1);//left black eye
ellipse(mouse_x+(s_draw*0.22), mouse_y-(s_draw*0.6)+bird_y, s_draw*0.1, s_draw*0.1);//right black eye
fill(#F9BC09);
triangle(mouse_x-(s_draw*0.17), mouse_y-(s_draw*0.35)+bird_y, mouse_x+(s_draw*0.17), mouse_y-(s_draw*0.35)+bird_y, mouse_x, mouse_y-(s_draw*0.05)+bird_y); //mounth
}
void keyPressed() {
if (keyCode==UP) {
size_draw++;
if (size_draw>=90)size_draw=90;
}
if (keyCode==DOWN) {
size_draw--;
if (size_draw<=20)size_draw=20;
}
}
void mousePressed() {
if (mouseButton == LEFT) {
max_bird++;
} else if (mouseButton == RIGHT) {
max_bird--;
{
if (max_bird<=1)max_bird=1;
}
}
}
ไม่มีความคิดเห็น:
แสดงความคิดเห็น