How can I play this?

%E6%9C%AA%E5%91%BD%E5%90%8D

How can I play this?

Something like this


void setup()
{
  size(560, 420);
}

void draw()
{
  background(0);
  strokeWeight(3);
  stroke(255);
  fill(0);
  for (int j =0; j<7; j++)
  {
    for (int i =0; i<10; i++)
    {
      rect(i*50+30, j*50+30, 45, 45);
    }
  }
}

You should have tried to do it yourself first!

void setup() {
size(800,800);
stroke(#459BF5);

}

void draw() {
background(0);

rectMode(CENTER);
rect(100, 100,200, 40);

rectMode(RADIUS);
rect(150, 100, 50, 20);

rectMode(CENTER);
rect(150, 100,200, 40);

rectMode(RADIUS);
rect(200, 100, 50, 20);

rectMode(CENTER);
rect(200, 100,200, 40);

rectMode(RADIUS);
rect(250, 100, 50, 20);

rectMode(CENTER);
rect(250, 100,200, 40);

rectMode(RADIUS);
rect(300, 100, 50, 20);

rectMode(CENTER);
rect(300, 100,200, 40);

rectMode(RADIUS);
rect(350, 100, 50, 20);

rectMode(CENTER);
rect(350, 100,200, 40);

rectMode(RADIUS);
rect(400, 100, 100, 20);

rectMode(CENTER);
rect(400, 100,200, 40);

rectMode(RADIUS);
rect(450, 100, 100, 20);

rectMode(CENTER);
rect(450, 100,200, 40);

rectMode(RADIUS);
rect(500, 100, 100, 20);

rectMode(CENTER);
rect(500, 100,200, 40);

rectMode(RADIUS);
rect(550, 100, 100, 20);

}

But how do you fix it on the last side?

I do not understand your question.
This code do not give the image you want . Why not use the code I have posted?

This is not the most efficient way to do this.
Here, you are writing all of the code for every squares you need to draw (that’s very tedious :sweat_smile:)

A simpler/faster/more efficient way to do this is to use for loops (https://processing.org/reference/for.html) because it will repeat the same piece of code every time you want by incrementing parameters.

(look at @PascalAudet 's code)

@PascalAudet Well, I didn’t see it at first, thank you for your big reply.

@josephh Ok, I see

1 Like