# How can I play this?

**URL:** <https://discourse.processing.org/t/how-can-i-play-this/5286>\
**Category:** Coding Questions\
**Created:** [November 7, 2018, 2:27am UTC](https://discourse.processing.org/t/how-can-i-play-this/5286 "2018-11-07T02:27:26Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![alk5603](https://avatars.discourse-cdn.com/v4/letter/a/f14d63/32.png) [@alk5603](https://discourse.processing.org/u/alk5603)\
**Post date:** [November 7, 2018, 2:27am UTC](https://discourse.processing.org/t/how-can-i-play-this/5286/1 "2018-11-07T02:27:26Z")

</div>

![%E6%9C%AA%E5%91%BD%E5%90%8D](https://canada1.discourse-cdn.com/flex036/uploads/processingfoundation1/original/2X/8/86a9d032c749060058beba2c767df2ba4dfb0e5a.png)

How can I play this?

---

<div class="post-metadata">

**Author:** ![PascalAudet](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/pascalaudet/32/1903_2.png) [@PascalAudet](https://discourse.processing.org/u/PascalAudet)\
**Post date:** [November 7, 2018, 2:47am UTC](https://discourse.processing.org/t/how-can-i-play-this/5286/2 "2018-11-07T02:47:12Z")

</div>

Something like this

```auto

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

```

---

<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:** [November 7, 2018, 2:47am UTC](https://discourse.processing.org/t/how-can-i-play-this/5286/3 "2018-11-07T02:47:31Z")

</div>

You should have tried to do it yourself first!

---

<div class="post-metadata">

**Author:** ![alk5603](https://avatars.discourse-cdn.com/v4/letter/a/f14d63/32.png) [@alk5603](https://discourse.processing.org/u/alk5603)\
**Post date:** [November 7, 2018, 3:45am UTC](https://discourse.processing.org/t/how-can-i-play-this/5286/4 "2018-11-07T03:45:28Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![PascalAudet](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/pascalaudet/32/1903_2.png) [@PascalAudet](https://discourse.processing.org/u/PascalAudet)\
**Post date:** [November 7, 2018, 1:50pm UTC](https://discourse.processing.org/t/how-can-i-play-this/5286/5 "2018-11-07T13:50:08Z")

</div>

> [@alk5603](#):
>
> 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?

---

<div class="post-metadata">

**Author:** ![josephh](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/josephh/32/210_2.png) [@josephh](https://discourse.processing.org/u/josephh)\
**Post date:** [November 7, 2018, 5:03pm UTC](https://discourse.processing.org/t/how-can-i-play-this/5286/6 "2018-11-07T17:03:13Z")

</div>

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 😅)

A simpler/faster/more efficient way to do this is to use for loops ([https://processing.org/reference/for.html](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)

---

<div class="post-metadata">

**Author:** ![alk5603](https://avatars.discourse-cdn.com/v4/letter/a/f14d63/32.png) [@alk5603](https://discourse.processing.org/u/alk5603)\
**Post date:** [November 10, 2018, 9:39pm UTC](https://discourse.processing.org/t/how-can-i-play-this/5286/7 "2018-11-10T21:39:06Z")

</div>

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

@josephh Ok, I see
