# Idk where is the error

**URL:** <https://discourse.processing.org/t/idk-where-is-the-error/26952>\
**Category:** Coding Questions\
**Created:** [January 10, 2021, 3:07pm UTC](https://discourse.processing.org/t/idk-where-is-the-error/26952 "2021-01-10T15:07:14Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![deiwy](https://avatars.discourse-cdn.com/v4/letter/d/a9a28c/32.png) [@deiwy](https://discourse.processing.org/u/deiwy)\
**Post date:** [January 10, 2021, 3:07pm UTC](https://discourse.processing.org/t/idk-where-is-the-error/26952/1 "2021-01-10T15:07:14Z")

</div>

so, I recently started programming on processing 3, the first game I want to do has to be a platformer, but I made a mistake and I don’t know what it is

```auto
block[] b;

int Map[][] = {
  {1,0,0,0,0,0,0,0},
  {0,1,0,0,0,1,0,0},
  {0,0,1,0,0,1,0,0},
  {0,0,0,0,0,1,0,0}
};

void setup(){
  
  b = new block[16];
  size(400, 400);
 
  for(int i = 0; i < 8; i++){
    for(int j = 0; j < 4; j++){
      for(int a = 0; a < 16; a++){
        if(Map[i][j] == 1){
          b[a] = new block(i*50, j*100, 50, 50, 100, 50, 50);
        } 
      }
    }
  }
  print(b[2]);
  
}
void draw(){
  background(158);
  for(int i = 0; i < b.length; i++){
    b[i].show();
  }
}

```

class block code:

```auto
class block{
  float x, y, xSize, ySize, c1, c2, c3;
  
  block(float X, float Y, float xsize, float ysize, float C1, float C2, float C3){
    x = X;
    y = Y;
    ySize = ysize;
    xSize = xsize;
    c1 = C1;
    c2 = C2;
    c3 = C3;
  }
  
  void show(){
    fill(c1, c2, c3);
    rect(x, y, xSize, ySize);
    noFill();
  }
  
}

```

---

<div class="post-metadata">

**Author:** ![MiguelSanches](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/miguelsanches/32/11172_2.png) [@MiguelSanches](https://discourse.processing.org/u/MiguelSanches)\
**Post date:** [January 10, 2021, 3:20pm UTC](https://discourse.processing.org/t/idk-where-is-the-error/26952/2 "2021-01-10T15:20:32Z")

</div>

Hi @deiwy

Welcome to the community! 🙂

The error that you have is due to index array

```auto
if(Map[i][j] == 1){

```

Notice that this condition fails because the Map Array is 4x8, but you are trying to access a 8x4 array 😉  
Just switch j and i and you are good to go!

```auto
if(Map[j][i] == 1){

```

Best regards!

---

<div class="post-metadata">

**Author:** ![deiwy](https://avatars.discourse-cdn.com/v4/letter/d/a9a28c/32.png) [@deiwy](https://discourse.processing.org/u/deiwy)\
**Post date:** [January 10, 2021, 3:30pm UTC](https://discourse.processing.org/t/idk-where-is-the-error/26952/3 "2021-01-10T15:30:05Z")

</div>

@MiguelSanches  
ok, thank you
