int w=500,h=500,count=0;
float v=1,r=50;
class balloon
{
float r;
float px;
float py;
balloon(float r,float px,float py)
{
this.r=r;
this.px=px;
this.py=py;
}
void moveUp()
{
if(py!=height+999)
{
this.py=this.py-v;
}
if(this.py<0-r)
{
this.py=height+r;
}
}
void display()
{
line(this.px,this.py,this.px,this.py+100);
ellipse(this.px,this.py,r*2,r*2);
}
}
balloon[] a=new balloon[10];
void setup()
{
Table table = loadTable("C:/Users/Thanaphat/Desktop/table.csv", "header");
int i=0;
for(TableRow row:table.rows())
{
float px=row.getInt("X");
float py=row.getInt("Y");
a[i]=new balloon(50,px,py);
i++;
}
size(w,h);
}
void draw()
{
background(155);
for(int i=0;i<a.length;i++)
{
a[i].display();
a[i].moveUp();
}
}
ไม่มีความคิดเห็น:
แสดงความคิดเห็น