|
float x;
float y;
float m;
float n;
float s;
float t;
int y_direction;
int x_direction;
int m_direction;
int n_direction;
int s_direction;
int t_direction;
float x_speed;
float y_speed;
float m_speed;
float n_speed;
float s_speed;
float t_speed;
void setup(){
size(300,300);
x_direction = 1;
y_direction = 1;
x_speed = 1.2;
y_speed = 1.8;
m_direction = 1;
n_direction = 1;
m_speed = 1.6;
n_speed = 1.0;
s_direction = 1;
t_direction = 1;
s_speed = 0.8;
t_speed = 1.5;
}
void loop(){
// zoka
x = x + x_direction*x_speed;
y = y + y_direction*y_speed;
m = m + m_direction*m_speed;
n = n + n_direction*n_speed;
s = s + s_direction*s_speed;
t = t + t_direction*t_speed;
background(255,255,255);
line(x,y,m,n);
line(m,n,s,t);
line(s,t,x,y);
ellipseMode(CENTER_DIAMETER);
fill(255,255,255);
ellipse(x,y,30,30);
fill(0,0,0);
ellipse(m,n,50,50);
fill(255,0,0);
ellipse(s,t,10,10);
//bounce
if(x>300-30 || x<0){
x_direction = x_direction*-1;
}
if(m>300-30 || m<0){
m_direction = m_direction*-1;
}
if(s>300-30 || s<0){
s_direction = s_direction*-1;
}
if (y> 300-30 || y<0){
y_direction = y_direction* -1;
}
if (n> 300-30 || n<0){
n_direction = n_direction* -1;
}
if (t >300-30 || t<0){
t_direction = t_direction* -1;
}
}
|