We are about to switch to a new forum software. Until then we have removed the registration on this forum.
float x [] = {10, 20, 30};
float xs [] = {2, 3, 5};
float y [] = {10, 20, 30};
float ys [] = {2, 3, 5};
void setup() {
size(500, 500);
}
void draw() {
background(0);
for (int i = 0; i< 3; i++) {
ellipse(x[i], y[i], 30, 30);
x[i]= x[i]+xs[i];
y[i]= y [i]+ys[i];
if ((x[i]>width-15)||(x[i]<15)) {
xs[i] = -xs[i];
}
if ((y[i]>height-15)||(y[i]<15)) {
ys[i] = -ys[i];
}
}
}
Answers
it stutters in the return zone because of
* -1
better to use
abs()
and-abs()
separately:https://forum.processing.org/two/discussion/17486/puzzle-ball-in-a-box-why-does-the-rebound-fail#latest
use ctrl-o to indent code when posting to the forum.
you wouldn't write a sentence without spaces, so why write codeallsquashedtogetherlikethis?
so much more readable