I don't think
drawRect() will work in this situation. You should create a brick like that
GRect brick = newGRect(x, y, width, height);
height are declared and initialized correctly. For detecting collisions, the function
detectCollision() that's already defined and ready to use by you takes in the
GObject that you wanna check whether it collides with something as an argument, calls another function from the SPL namely
getGObjectAt() which returns a pointer to a
GObject if there's already a
GObject (e.g., a
GRect) at the specified x and y.
In short, you shouldn't care about the implementation of detectCollision() or getGObjectAt() (unless you're really curious), but rather, you should create your bricks (as
GRects), initialize them and add them to the window. You should also know that if you passed the ball to detectCollision(), it will return a
GObject (e.g., a
GRect) in case there's a collision or
NULL in case there's not.
You should then handle that by removing the brick (if the
GObject returned by
detectCollision() is a brick), increasing the score by 1, bouncing the ball off and so on.
For the bricks not all of them being shown, I assume either you forgot to add them to the window or the formula for placing them is not correct. If that's the case, remember that if you're creating them from left to right top to bottom then the x position of each brick should be > the x position of the previous brick by the width of the brick + the gap.
Similarly, the y position of each brick should be > the y position of the upper brick by the height of a brick + the gap. You should make sure that this formula applies correctly.