i have started making a small game, i have one ball that you control woth your mouse (the player), and one ball that is a ball (the volleyball)…
when the volleyball intersects with the player the volleyball should change direction, if it the volleyball hits the player in the middle (player_x - ball_x = 0) there’s no problem, i just change the y-movement value to a negative value. but if the ball hits a bit to the right or a bit to the left, the volleyball should change direction… how?
i tried to do like this:
ball_y_mov = Number(ball_speed * -1);
ball_x_mov = Number(ball_x - player_x);
but then the speed of the ball is VERY fast if it hits far to the left or right…