วันอาทิตย์ที่ 30 สิงหาคม พ.ศ. 2558

Lab 2 : Battery (use function + move)

int posX=100;
int posY=100;
int y=25;

void setup(){
 size(300,300);
 frameRate(50);
}

void draw(){
  background(#FF0000);
  draw_battery(posX,posY);
    posX = (posX+1)%width;
}

void draw_battery(int posX,int posY){

rect(posX+10,posY-25,40,15);

noStroke();
rect(posX-10,posY-10,80,140);

fill(0);
rect(posX-5,posY-5,70,130);
rect(posX-20,posY-30,20,5);
rect(posX+60,posY-30,20,5);
rect(posX+68,posY-37,5,20);

fill(255);
rect(posX,posY,60,20);
rect(posX,posY+y,60,20);
rect(posX,posY+2*y,60,20);
rect(posX,posY+3*y,60,20);
rect(posX,posY+4*y,60,20);

textSize(20);
text("100%",posX,posY+160);
}

ไม่มีความคิดเห็น:

แสดงความคิดเห็น