If you really don’t want to use classes (which is the way to go in an object oriented language) you might use this aswell:
void setup()
{
size (400, 400);
smooth();
}
int diam = 20;
int[] x = {10, 50, 90};
int[] y = {10, 50, 90};
int[] xDir = {1, 1, 1};
int[] yDir = {1, 1, 1};
int r, g, b;
void draw()
{
background(r, g, b);
for (int i = 0; i < 3; i++) {
fill(255 - (x[i] + y[i]) * .6375 / 2);
ellipse(x[i], y[i], diam, diam);
if (x[i] > width - diam / 2 || x[i] < diam / 2)
{
xDir[i] = -xDir[i];
}
if (y[i] > height - diam / 2 || y[i] < diam / 2)
{
yDir[i] = -yDir[i];
}
x[i] = x[i] + xDir[i];
y[i] = y[i] + yDir[i];
}
}
void keyPressed()
{
if (key == ENTER || key == RETURN)
{
r = (int) random(255);
g = (int) random(255);
b = (int) random(255);
}
}
But you won’t be able to do it without arrays.