Building Software Systems I & II
&
Computer Fundamentals
By Thakdanai Khunsaen
OS : Ubuntu GNOME 17.04 64-bit
วันอาทิตย์ที่ 6 กันยายน พ.ศ. 2558
Lab3-Bird
int wingFly;
int x= 30;
int birdSize = 150;
void setup() {
size(700, 500);
}
void draw() {
background(255);
wingFly = mouseY;
if (frameCount%x > x/2) {
wingFly += birdSize/3;
} else {
wingFly -= birdSize/3;
}
flybird(mouseX, mouseY, birdSize);
}
void keyPressed() {
if (key == 'z' || key == 'Z') {
birdSize -= 10;
if (birdSize <= 0) {
birdSize = 0;
}
}
if (key == 'x' || key == 'X') {
birdSize += 10;
if (birdSize >= height) {
birdSize = height;
}
}
}
void mouseClicked() {
if (mouseButton == LEFT) {
x -= 8;
if (x <= 0) {
x =4;
}
} else if (mouseButton == RIGHT) {
x += 8;
if (x >= 60) {
x = 60;
}
}
}
void flybird(int x, int y, int birdSize) {
strokeWeight(3);
fill(#FF00FF);
ellipse(x, y, birdSize, birdSize);
fill(0);
ellipse(x-(birdSize/5), y, birdSize/4, birdSize/3);
ellipse(x+(birdSize/5), y, birdSize/4, birdSize/3);
fill(255);
ellipse(x-(birdSize/5), y, birdSize/6, birdSize/5);
ellipse(x+(birdSize/5), y, birdSize/6, birdSize/5);
fill(#FFFF00);
triangle(x-(birdSize/4), y+(birdSize/4), x+(birdSize/4), y+(birdSize/4), x, y+birdSize/1.5);
line(x-(birdSize/2), y, x-birdSize, wingFly);
line(x+(birdSize/2), y, x+birdSize, wingFly);
}
สมัครสมาชิก:
ส่งความคิดเห็น (Atom)
ไม่มีความคิดเห็น:
แสดงความคิดเห็น