My code works well except when I insert the following code to detect if a brick is hit, I get a segmentation fault. Does anyone know why ?

This is the short code inserted :

 // bounces if hits brick, increment point and remove brick from screen and from total number of bricks
if (strcmp(getType(object), "GRect") == 0)
    // do something

You have to check whether object is equal to NULL before passing it to getType().

detectCollision() might return NULL in case there's no collision happened.

  • Thanks again Kareem ;-) – Loic Jun 26 '14 at 19:37

You must log in to answer this question.

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