วันศุกร์ที่ 11 กันยายน พ.ศ. 2558
LAB 4 Balloon
Lab 4 Balloon
color col1 = color(190,145,242);color col2 = color(113,81,27);
void setup(){
size(400,400);
}
void draw(){
background(#FEFFC9);
int posX = mouseX;int posY = mouseY;int balloonSize = 50;int string_lenght = 100;
draw_balloon(posX,posY,balloonSize,string_lenght);
}
void draw_balloon(int posX,int posY,int balloonSize,int string_lenght){
int count = 0;
while( posX+(count*(balloonSize+5)) < width ){
stroke(col2);
fill(col1);
line(posX+(count*(balloonSize+5)),posY+25,posX+(count*(balloonSize+5)),posY+string_lenght+25);
strokeWeight(2);
ellipse(posX+(count*(balloonSize+5)),posY,balloonSize,balloonSize);
strokeWeight(3);
count++;
}
}
void mouseClicked(){
if(col1 == color(190,145,242) || col2 == color(113,81,27)){
col1 = color(255,129,148);
col2 = color(56,157,149);
}else{
col1 = color(190,145,242);
col2 = color(113,81,27);
}
}
ปัญหาที่พบและวิธีแก้ :
1) เครื่องหมาย } หลังฟังก์ชั่นหายไป (เติมเครื่องหมาย } หลังฟังก์ชั่น)
2) ไม่สามารถออกจาก loop while ได้ เพราะเงื่อนไขเป็นจริงทุกครั้ง (กำหนดตัวแปร count แล้วสั่งให้ตัวแปรเพิ่มค่าขึ้นทีละ 1 เมื่อทำงานในแต่ละรอบ และใส่ตัวแปร count ลงในเงื่อนไขของ while )
สมัครสมาชิก:
ส่งความคิดเห็น (Atom)
ไม่มีความคิดเห็น:
แสดงความคิดเห็น