title: Breakout project painting all bricks on top of each other
body: <p>I am coding a breakout game in android studio. I have set up the bricks in an array and have them set up to be painted. However, all of the bricks are painted on top of each other.</p>
  
  <p>BreakoutView class extract:</p>
  
  <pre><code>private static final int rows = 5;
  private static final int columns = 10;
  private static final int brickHeight = 50;
  private static final int brickWidth = 100;
  int brickX = 0;
  int brickY = 0;
  int brickSpaces = 0;
  private Sprite[] bricks;
  
  public BreakoutView(Context context, AttributeSet attrs) {
      super(context, attrs);
      bricks = new Sprite[rows * columns];
      for (Sprite brick: bricks) {
          brick.setSize(brickWidth, brickHeight);
          brick.setLocation(brickX, brickY);
          brick.paint.setARGB(255,250,0,0);
      }
  }
  
  protected void onDraw(Canvas canvas) {
      super.onDraw(canvas);
  
      for (Sprite brick : bricks) {
          for (int r = 0; r &lt;= rows; r++) {
              brickY = brickHeight + brickSpaces;
              for (int c = 0; c &lt;= columns; c++) {
                  brickX = brickWidth + brickSpaces;
                  brickSpaces = 10;
              }
          }
      }
  }
  </code></pre>
  
  <p>Sprite class:</p>
  
  <pre><code>public class Sprite {
  
      public RectF rect = new RectF();
      public float dx = 0;
      public float dy = 0;
      public Paint paint = new Paint();
  
      public Sprite(float x, float y, float width, float height) {
          setLocation(x, y);
          setSize(width, height);
      }
  }
  </code></pre>