# Question regarding beginShape() and endShape()

**URL:** <https://discourse.processing.org/t/question-regarding-beginshape-and-endshape/1374>\
**Category:** p5.js\
**Created:** [June 30, 2018, 12:02am UTC](https://discourse.processing.org/t/question-regarding-beginshape-and-endshape/1374 "2018-06-30T00:02:01Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Doodle\_Noodle](https://avatars.discourse-cdn.com/v4/letter/d/9de0a6/32.png) [@Doodle\_Noodle](https://discourse.processing.org/u/Doodle_Noodle)\
**Post date:** [June 30, 2018, 12:02am UTC](https://discourse.processing.org/t/question-regarding-beginshape-and-endshape/1374/1 "2018-06-30T00:02:01Z")

</div>

So, this is kind of strange to ask, but I’m relatively new to programming in general, and I was curious how it would be possible to translate a shape created using the beginShape() and endShape() functions. I’m working on making a simple version of the game Tetris, just to kinda get my feet in the water. I’m sure there is some logic here that I’m missing, and the answer may be in front of my face, but I’m tearin’ my hair out here. Essentially, I’d like to easily assign a single position, velocity, and depending on if I need to an acceleration to each individual tetrino, rather than having to change the values of each vertex of the defined shape.

---

<div class="post-metadata">

**Author:** ![TfGuy44](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/tfguy44/32/41_2.png) [@TfGuy44](https://discourse.processing.org/u/TfGuy44)\
**Post date:** [June 30, 2018, 12:13am UTC](https://discourse.processing.org/t/question-regarding-beginshape-and-endshape/1374/2 "2018-06-30T00:13:49Z")

</div>

You said it yourself: `translate()`.

```auto
void setup(){
  size(600,600);
}

void draw(){
  background(0);
  
  pushMatrix();
  translate(mouseX, mouseY);
  // L block in red
  fill(200,0,0);
  rect(0,0,20,20);
  rect(20,0,20,20);
  rect(40,0,20,20);
  rect(40,20,20,20);
  popMatrix();

  pushMatrix();
  translate(300,300);
  // Z block in green
  fill(0,200,0);
  rect(0,0,20,20);
  rect(20,0,20,20);
  rect(20,20,20,20);
  rect(40,20,20,20);
  popMatrix();
  
}

```

---

<div class="post-metadata">

**Author:** ![Doodle\_Noodle](https://avatars.discourse-cdn.com/v4/letter/d/9de0a6/32.png) [@Doodle\_Noodle](https://discourse.processing.org/u/Doodle_Noodle)\
**Post date:** [June 30, 2018, 12:22am UTC](https://discourse.processing.org/t/question-regarding-beginshape-and-endshape/1374/3 "2018-06-30T00:22:01Z")

</div>

Oh my gosh, thank you! Jeez I knew it was simple, and I knew I would want to smack myself upside the head after learning the answer. You have no idea the stress this will save me. Thank you!
