4 votes
Accepted

Ball bounces just above paddle

detectCollision assumes that the width of your ball is RADIUS*2. You have initialized your ball with a width of RADIUS. So detectCollision will return a collision before the ball hits the paddle.
user avatar
  • 18.4k
2 votes

Cannot get both paddle moving and ball bouncing at the same time (pset4)

Solved! Defining the velocity outside of the while loop, instead of inside, has fixed the problem. When it was inside the loop, the velocity was reset to a positive number every time the while loop ...
user avatar
  • 31
1 vote

pset4 velocity & ball's angle

I think you may need a separate velocity variable for each dimension (e.g., Vx and Vy). I think this will clear up the angle problem.
user avatar
1 vote

pset4-breakout ball bouncing

It's not too bad on the math side. In summary, you just reverse the values of the x and y velocity when it contacts the object. For instance, if the ball hits the right edge of the window. the x-...
user avatar
  • 1,317
1 vote

detect collision paddle Pset4

One thing that had me for a bit was my functions for instantiating the paddle and the ball. since we have to program movement inside of main we want ball and paddle exist inside of that function. ...
user avatar
1 vote

detect collision paddle Pset4

Try to change the == in the object detection section with either >= or <=
user avatar
  • 1,156
1 vote
Accepted

calling srand48 rand vrs srand

Add the following line before your #include statements: #define _XOPEN_SOURCE
user avatar
  • 185

Only top scored, non community-wiki answers of a minimum length are eligible