How to Initialize Bricks in breakout?

starting pset4 but can't understand how to initialize bricks. Thnx in advance!

Just take your time and read through the pset carefully, watching the videos and taking things one step at a time.

As they state in the pset you will use a couple of for loops to instantiate the bricks. You use the loops to display each brick in each row.

Read up on how to use the GRect type and newGRect function to create a brick.

To display the brick you have then created you need to add it to the window (add being another function).

You may want to use other functions to fill the brick and set the colour, I used a char* array to hold the five colours, and then used the counter on the outer for loop (the one for each row) to determine which colour the bricks on that row should be.

The bit that had me playing around for a while was the algorithm for spacing the bricks neatly based on the width of the window, width of the brick etc.

Start with making the paddle, as suggested in the spec. It will give you a quick practice session of creating a GRect and positioning it. After that, you just have to take the same steps and put them into nested loops.

The trickiest part is figuring out how to set the x and y dynamically. Just to give you a little head start; the x coordinate should be something like (meaning I'm not giving you the answer entirely) the block number for the row, times the width of each block, plus whatever the distance you want between blocks. Once you've got the x entered dynamically, use the same methodology to figure out the y axis.

When all is done you'll have y rows of x blocks positioned just how you'd like. Then you can use setColor() and setFilled() to color the blocks. If you'd like to color blocks based on row, there are a few ways to do it, stepping through an array of colors, or using a switch case as outlined here http://msdn.microsoft.com/en-us/library/66k51h7a.aspx