Hi! I recently made a bouncing ball program
float x = 300, y = 300, r = 30, xs = 10, ys = 8, friction = 0.9;
void setup() {
size(600,600);
}
void draw() {
background(0);
circle(x,y,r*2);
x+=xs;
y+=ys;
if(x + r > width || x - r < 0) {
xs *= -1;
}
if(y + r > height || y - r < 0) {
ys *= -1;
}
}
and want to create a program where you can create lines to add ways to reflect the ball
I can use the LINE / CIRCLE DETECTION to get the information if they bounce but I don’t know how to determine what to multiply the x speed and y speed with. Could it be
xs*=cos(reflect angle)
ys*=sin(reflect angle)
?