# How do you create a wall?

**URL:** <https://discourse.processing.org/t/how-do-you-create-a-wall/873>\
**Category:** Beginners\
**Created:** [June 11, 2018, 2:38pm UTC](https://discourse.processing.org/t/how-do-you-create-a-wall/873 "2018-06-11T14:38:04Z")\
**Posts on this page:** 1\
**Showing post:** 3

<div class="post-metadata">

**Author:** ![colin](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/colin/32/230_2.png) [@colin](https://discourse.processing.org/u/colin)\
**Post date:** [June 11, 2018, 3:03pm UTC](https://discourse.processing.org/t/how-do-you-create-a-wall/873/3 "2018-06-11T15:03:45Z")

</div>

What do you mean by wall ? Would you like to draw like another rectangle in your scene with an hitbox ? If so, here is a suggestion.

```auto
int xPos = 25;
int yPos = 25;
int xPosN;
int yPosN;
int playerSize=15;

void setup() {
  fullScreen();
}

void draw() {
  background(75, 75, 75);
  xPosN=xPos;
  yPosN=yPos;
  if(keyPressed)control();
  fill(250, 0, 0);
  rect(xPos, yPos, playerSize, playerSize);
  if(!wall(50,50,50,50)) move();
}

void control() {
  if (keyCode == LEFT || key == 'a') xPosN = xPos-2;
  if (keyCode == RIGHT || key == 'd') xPosN = xPos+2;
  if (keyCode == UP || key == 'w') yPosN = yPos-2;
  if (keyCode == DOWN || key == 's') yPosN = yPos+2;
}

void move() {
  xPos=constrain(xPosN,0,width-playerSize);
  yPos=constrain(yPosN,0,height-playerSize);
}

boolean wall(int x, int y, int w, int h) {
  fill(0, 250, 0);
  rect(x, y, w, h);
  return (xPosN+playerSize>x && xPosN<x+w && yPosN+playerSize>y && yPosN<y+h);
}

```

---

_[View the full topic](https://discourse.processing.org/t/how-do-you-create-a-wall/873)._
