# Thread: Need a loop for rows and columns

1. Member
Join Date
Oct 2009
Posts
10
Rep Power
0

## Need a loop for rows and columns

hey guys i need help making a loop to create bricks in my breakout game.

here is the code to make one brick:

//creates a brick in breakoutWourld.
brick = new Brick(1,"red");

any ideas on how i can loop it to make 2 rows that have 11 bricks.

2. Senior Member
Join Date
Jul 2009
Posts
1,215
Rep Power
6
Read your text book. I'm sure it covers how to do "for loops".

If you don't have your text book handy then you can always use the Sun tutorial. You can start with Language Basics.

3. Member
Join Date
Oct 2009
Posts
10
Rep Power
0
If i used the code to make all the bricks of the game how can i change the colours between them?

for (int i = 0; i < 8; i++)
{
for (int j = 0; j < 11; j++)
{
brick = new Brick(1,"red");
}
}

at the moment its making all the bricks red.

i have four colors red, blue, green, yellow. and after every second row i need the color to change.
Edit/Delete Message

4. look at the Random class. You can set it up to give you a random value from 1-4 and then based on that number have a case statement that determines the color.

#### Posting Permissions

• You may not post new threads
• You may not post replies
• You may not post attachments
• You may not edit your posts
•