|
float x,y;
int x_direction;
int y_direction;
float x_speed;
float y_speed;
void setup(){
size(300,300);
x_direction=1;
y_direction=1;
x_speed=1.2;
y_speed=1;
}
void loop(){
background(255,255,255);
x=x+(x_speed*x_direction);
y=y+(y_speed*y_direction);
ellipse(x,y,20,20);
if(x > 300 || x < 0){
x_direction *=-1;
}
if(y > 300 || y < 0){
y_direction *=-1;
}
x=x+x_direction;
y=y+y_direction;
}
|
|