int x1=0;
int x2=400;
int y1=0;
int y2=0;
int dx=1;
int dy=1;
void setup()
{
size(400,400);
}
void draw()
{
background(random(255),random(255),random(255));
fill(229,30,30);
ellipse(x1,y1,30,30);
x1+=dx;
y1+=dy;
if((x1>=width||y1>=height)||(x1<=0||y1<=0))
{
dx=(-1)*dx;
dy=(-1)*dy;
}
ellipse(x2,y2,30,30);
x2-=dx;
y2+=dy;
}
No comments:
Post a Comment