love

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

Lab2-Positive

//K. Thanapat
//กำหนดตัวแปร Global
int x =0;
int y = 0;
int s = 250;
void setup(){
    size(500 ,500);
    frameRate(50);
}
void draw(){
    background(0);
    noStroke();
    draw_RectX(); //ประกาศฟังก์ชัน
    draw_RectY(); //ประกาศฟังก์ชัน
    fill(255 ,0 ,0);
//กำหนดการเคลื่อนไหว
    x = (x+7)%width;
    y = (y+7)%width;
    s = (s-0.5)%width;
}
//เรียกใช้ฟังก์ชัน
void draw_RectY(){
    rect(s/3+x ,y ,s/3 ,s);
}
//เรียกใช้ฟังก์ชัน
void draw_RectX(){
    rect(x ,s/3+y ,s ,s/3);
}

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

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