# How can i make walls that are solid

**URL:** <https://discourse.processing.org/t/how-can-i-make-walls-that-are-solid/16347>\
**Category:** Coding Questions\
**Created:** [December 12, 2019, 3:13pm UTC](https://discourse.processing.org/t/how-can-i-make-walls-that-are-solid/16347 "2019-12-12T15:13:49Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Original](https://avatars.discourse-cdn.com/v4/letter/o/a698b9/32.png) [@Original](https://discourse.processing.org/u/Original)\
**Post date:** [December 12, 2019, 3:13pm UTC](https://discourse.processing.org/t/how-can-i-make-walls-that-are-solid/16347/1 "2019-12-12T15:13:49Z")

</div>

I am new to processing  
I am making a maze where you have to press the mouse to see it and i dnt know how to make walls that have collision is there anyone that can help

```auto
float x = 5; 
float y = 55;
PImage img;

void setup() {
  size(600, 597);
  
  img = loadImage( "Maze.jpg" );
  }

void draw() {
  background(0);
  fill(255);
  rect(x, y, 10, 10);
  fill(0);
   rect(0,0,600,47);
   rect(0,75,138,27);
   rect(0,75,27,597);
   rect(0,580,600,27);
   rect(560,74,600,597);
   rect(505,75,600,30);
  }

void keyPressed(){
  if (key == CODED) {
    if (keyCode == UP) {
      y = y - 5;
    }
    if (keyCode == DOWN) {
      y = y + 5;
    }
    if (keyCode == LEFT) {
      x = x - 5;
    }
    if (keyCode == RIGHT) {
      x = x + 5;
    }
   
    
  }
 if (key == 'r')
 {
   x = 5;
   y = 55;
 }
}
void mousePressed(){
 image(img,0,0);
     fill(57,56,56);
}

```

---

<div class="post-metadata">

**Author:** ![Chrisir](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/chrisir/32/45_2.png) [@Chrisir](https://discourse.processing.org/u/Chrisir)\
**Post date:** [December 12, 2019, 10:31pm UTC](https://discourse.processing.org/t/how-can-i-make-walls-that-are-solid/16347/2 "2019-12-12T22:31:20Z")

</div>

I think instead of hard coding the rectangles, it’s better:

See the labyrinth as a grid

See tutorials, two dimensional arrays.

Store for each cell in the grid/labyrinth if it’s way or wall.

To check for a collision, check whether the cell in front of you (or in front of the direction you move to) is way or wall.

I know it’s not too easy

---

<div class="post-metadata">

**Author:** ![Original](https://avatars.discourse-cdn.com/v4/letter/o/a698b9/32.png) [@Original](https://discourse.processing.org/u/Original)\
**Post date:** [December 13, 2019, 2:35pm UTC](https://discourse.processing.org/t/how-can-i-make-walls-that-are-solid/16347/3 "2019-12-13T14:35:03Z")

</div>

Do you have any links to other projects that would help me with doing this.

---

<div class="post-metadata">

**Author:** ![Tiemen](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/tiemen/32/5477_2.png) [@Tiemen](https://discourse.processing.org/u/Tiemen)\
**Post date:** [December 13, 2019, 4:09pm UTC](https://discourse.processing.org/t/how-can-i-make-walls-that-are-solid/16347/4 "2019-12-13T16:09:21Z")

</div>

Chris meant this tutorial: [https://processing.org/tutorials/2darray/](https://processing.org/tutorials/2darray/)

You’ll probably find more topics on this forum if you look for terms such as ‘collision’.
