Building Software Systems I & II
&
Computer Fundamentals
By Thakdanai Khunsaen
OS : Ubuntu GNOME 17.04 64-bit
วันอาทิตย์ที่ 13 กันยายน พ.ศ. 2558
Lab4 - balloons
float x =25;
int y = 400;
int num = 8;
void setup() {
size(750, 400);
}
void draw() {
background(255);
int count = 0;
int space = 0;
while (count < num) {
draw_balloon(x+space, y, 50, 50);
count += 1;
space += 50;
}
y -= 4;
if (y == -100) {
y = 400;
x = random(25, width-(count*50-25));
}
}
void draw_balloon(float x, int y, int balloonSize, int string) {
fill(#FF0000);
ellipse(x, y, balloonSize, balloonSize);
line(x, y+balloonSize/2, x, (y+balloonSize/2)+string);
}
void mousePressed() {
if (mouseButton == LEFT) {
num +=1;
if (num>15) {
num = 15;
}
}
if (mouseButton == RIGHT) {
num -=1;
if (num < 1) {
num = 1;
}
}
}
สมัครสมาชิก:
ส่งความคิดเห็น (Atom)
ไม่มีความคิดเห็น:
แสดงความคิดเห็น