//K. Thanapat
int s =250; //ขนาด
int x =-100; //แกนx
void setup(){
size(500 ,500);
frameRate(50);
}
void draw(){
background(90 ,100 ,90);
draw_battery(); //ประกาศฟังก์ชัน
draw_Sign(); //ประกาศฟังก์ชัน
x = (x+8)%500; //ทำให้ภาพเคลื่อนไหว
}
//เรียกใช้ฟังก์ชัน
void draw_battery(){
fill(203 ,155 ,108);
stroke(255);
strokeWeight(3);
rect(120+x ,170 ,s ,s/2);
fill(0);
rect(100+x ,170 ,s/5 ,s/2);
}
//เรียกใช้ฟังก์ชัน
void draw_Sign(){
noStroke();
fill(255 ,0 ,0);
rect(120+x ,210 ,s/20 ,s/7);
rect(108+x ,223 ,s/7 ,s/20);
rect(310+x ,223 ,s/7 ,s/20);
}
ไม่มีความคิดเห็น:
แสดงความคิดเห็น