I'm working on breakout, and trying to set my initial x and y velocities. My goal is to keep the speed constant while changing the direction. To do this, I'm trying to send the y velocity equal to the square root of ( (constant)^2 - (x velocity)^2 ). I tried using this formula:
// initial velocities double velocityx = drand48() + 3; double velocityy = sqrt(pow(2, 2) - pow(velocityx, 2));
It compiles, but I get a "segmentation fault (core dumped)" error upon running. I was thinking it may have to do with squaring a double?
Any ideas? Thank you!