@ -46,19 +47,25 @@ int main(int argc, char** argv) {
floatvelocity_1=0;// Vertical velocity of first paddle
floatvelocity_1=0;// Vertical velocity of first paddle
floatvelocity_2=0;// Vertical velocity of second paddle
floatvelocity_2=0;// Vertical velocity of second paddle
floatcirc_x=25;// Center coordinates of ball
floatcirc_x=60;// Center coordinates of ball
floatcirc_y=25;
floatcirc_y=25;
floatcirc_rad=15;// Radius of ball
floatcirc_rad=15;// Radius of ball
floatball_speed=sqrt(72);// Pythagorean distance travelled by ball in one main-loop iteration
floatball_speed=sqrt(72);// Pythagorean distance travelled by ball in one main-loop iteration
floatcirc_vel_x=(float)(rand())/(float)(RAND_MAX/3)+4.0;// Horizontal velocity of ball (Randomly generated, 4 to 7) - borrowed from https://stackoverflow.com/a/13409133
floatcirc_vel_x=(float)(rand())/(float)(RAND_MAX/3)+4.0;// Horizontal velocity of ball (Randomly generated, 4 to 7) - borrowed from https://stackoverflow.com/a/13409133
printf("%f\n",circ_vel_x);
floatcirc_vel_y=sqrt(pow(ball_speed,2)-pow(circ_vel_x,2));// Vertical velocity of ball - Subtract X velocity from hypotenuse / ball_speed
floatcirc_vel_y=sqrt(pow(ball_speed,2)-pow(circ_vel_x,2));// Vertical velocity of ball - Subtract X velocity from hypotenuse / ball_speed
printf("%f\n",circ_vel_y);
intscore_1=0;// Player 1 score
intscore_2=0;// Player 2 score
// I reset the ball position here, so that the ball starts from the same place after I press SPACE