int x=0;
int y=0;
int dx=1;
int dy=1;
void setup()
{
size(400,400);
}
void draw()
{
background(random(87),random(25),random(0));
fill(random(255),random(255),random(255));
rect(x,y,width/10,height/10);
x+=dx;
y+=dy;
if((x>=width||y>=height)||(x<=0||y<=0))
{
dx=(-1)*dx;
dy=(-1)*dy;
}
}
No comments:
Post a Comment