Per the CS50's pset4 specs:
Odds are you’ll find removeGWindow
of interest, per http://cdn.cs50.net/2013/fall/lectures/5/m/src5m/spl/doc/gwindow.html. SPL’s documentation incorrectly refers to that function as remove
, but it’s indeed removeGWindow
you want, whose prototype, to be clear, is the below:
void removeGWindow(GWindow gw, GObject gobj);
So, your two problems are, luckily enough, the same: when you attempt to remove your "lost-live" ball, you're using the function remove
, which, apparently, doesn't work very well.
Try using removeGWindow()
and see what happens.
Also, as per the pset specs:
Next up are some constants, values that you don’t need to change, but because the code we’ve written (and that you’ll write) needs to know these values in a few places, we’ve factored them out as constants so that we or you could, theoretically, change them in one convenient location. By contrast, hard-coding the same number (pejoratively known as a "magic number") into your code in multiple places is considered bad practice, since you’d have to remember to change it, potentially, in all of those places.
Does that ring any bell? ;)
Jokes aside, you should start copying what's considered "good coding pratice" as soon as you recognize some patterns (or in this case, as soon as you're told by CS50's staff). In this case, perhaps you should consider changing:
if(getY(ball) > 555)
by
if(getY(ball) > (HEIGHT - 2 * RADIUS))