# Question regarding beginShape() and endShape()

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.

You said it yourself: translate().

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();

}

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!

1 Like