float [] x,y,d;
float [] vx,vy;
float [] x1,y1,d1;
float [] vx1,vy1;
void setup(){
size(800,800);
x = new float[5];
y = new float[5];
d = new float[5];
vx = new float[5];
vy = new float[5];
x1 = new float[5];
y1 = new float[5];
d1 = new float[5];
vx1 = new float[5];
vy1 = new float[5];
for(int i=0; i<5; i++){
x[i] = random(width);
y[i] = random(height);
d[i] = random(4);
x1[i] = random(width);
y1[i] = random(height);
d1[i] = random(4);
vx[i] = random(-10,10);
vy[i] = random(-10,10);
vx1[i] = random(-10,10);
vy1[i] = random(-10,10);
}
}
void draw() {
background(#0799E5);
for(int i=0; i<5; i++){
vichea(x[i], y[i], 5);
vichea1(x1[i], y1[i], d1);
x[i] += vx[i];
y[i] += vy[i];
x1[i] += vx1[i];
y1[i] += vy1[i];
if(x[i]>width x[i]<0) {vx[i] = -vx[i]; }
if(y[i]>width y[i]<0) {vy[i] = -vy[i]; }
if(x1[i]>width x1[i]<0) {vx1[i] = -vx1[i]; }
if(y1[i]>width y1[i]<0) {vy1[i] = -vy1[i]; }
} else if(i == 3) {
x[i] = mouseX;
y[i] = mouseY;
}
if (i<5) vichea(x[i], y[i], d[i]);
else vichea1 (x1[i], y1[i], d1);
}
}
void keyPressed() {
for(int i=0; i<5; i++){
if (key == a ) x[i] -= 8;
else if (key == d ) x[i] += 8;
else if (key == w ) y[i] -= 8;
else if (key == s ) y[i] += 8;
else {
x1[i] = mouseX;
y1[i] = mouseY;
}
}
}
我不知道这有什么错误。