1

could I get a little help with pset3 Breakout please? I want to get the ball to move and bounce - I modified bounce.c to do this beautifully but when I put the code into breakout.c, it compiles ok but am getting a Segmentation Fault at the statement "move(ball, velocityX, velocityY);". This line is in main and all 3 arguments are defined already so I don't think it's a scope error.

In the attached screenshot, ball is instantiated in line 64, velocityX & velocityY in lines 82/84. And yet GDB is saying that the Seg fault is occurring in line 109. Anyone any ideas? Thanks.

Screenshot

1
  • I'm getting this as well, but ONLY when i instantiate my ball via a function. If I instantiate it line by line within main() it works fine. Do you find the same? May 12 '15 at 17:05
4

I think i figured it out. You have to make sure your functions actually return the ball or the paddle. The way the model is set up, those functions return "NULL". This is what's causing the error. So initBall should return a GOval called ball.

3
  • Thanks much Brian - that's perfect - problem solved!
    – Phil M
    May 13 '15 at 7:48
  • Absolutely my fault actually - step 5 on the pset has that instruction stated clearly. Derr - thanks again for the clarity.
    – Phil M
    May 13 '15 at 8:12
  • DOES it??? Derr, i missed that too. Loooootta info in this pset. :) May 13 '15 at 13:19

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .