# Building a tower out of squares in Processing

**URL:** <https://discourse.processing.org/t/building-a-tower-out-of-squares-in-processing/29863>\
**Category:** Processing\
**Created:** [May 4, 2021, 11:38pm UTC](https://discourse.processing.org/t/building-a-tower-out-of-squares-in-processing/29863 "2021-05-04T23:38:07Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![jakob.timo](https://avatars.discourse-cdn.com/v4/letter/j/a3d4f5/32.png) [@jakob.timo](https://discourse.processing.org/u/jakob.timo)\
**Post date:** [May 4, 2021, 11:38pm UTC](https://discourse.processing.org/t/building-a-tower-out-of-squares-in-processing/29863/1 "2021-05-04T23:38:07Z")

</div>

Hello there!  
I need some help.  
I want to build a tower made out of squares. The should be made out of 10 squares and they should alternate between red and blue sqares. I have no plan where I even should start.  
Already thanks for ur help : )

---

<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:** [May 4, 2021, 11:57pm UTC](https://discourse.processing.org/t/building-a-tower-out-of-squares-in-processing/29863/2 "2021-05-04T23:57:00Z")

</div>

Start simply.

Can you write code that draws a square?

Once you have that, change it so it draws TWO squares.

Then color the squares. Make one red, and the other blue.

Now draw TEN squares. Are they in the right places?

And then you’re done!

* * *

You MUST show the code of your attempt before anyone will help you more. If you have no code, ATTEMPT TO WRITE SOME. Even if you can only write code that draws one square, that is a MILLION times better than the NO-CODE post you have made so far.

---

<div class="post-metadata">

**Author:** ![jakob.timo](https://avatars.discourse-cdn.com/v4/letter/j/a3d4f5/32.png) [@jakob.timo](https://discourse.processing.org/u/jakob.timo)\
**Post date:** [May 5, 2021, 12:00am UTC](https://discourse.processing.org/t/building-a-tower-out-of-squares-in-processing/29863/3 "2021-05-05T00:00:07Z")

</div>

hey there,  
I´m totally new here but thank u very much for u help. I´m going try writing that code and next time I will have a code !!

---

<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:** [May 5, 2021, 12:01am UTC](https://discourse.processing.org/t/building-a-tower-out-of-squares-in-processing/29863/4 "2021-05-05T00:01:16Z")

</div>

Alright! Some handy functions you might need include `setup() draw() background() rect()` and `fill()`.

---

<div class="post-metadata">

**Author:** ![glv](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/glv/32/18785_2.png) [@glv](https://discourse.processing.org/u/glv)\
**Post date:** [May 5, 2021, 12:25am UTC](https://discourse.processing.org/t/building-a-tower-out-of-squares-in-processing/29863/5 "2021-05-05T00:25:37Z")

</div>

Hello,

You have to start somewhere…

I encourage you to review the resources available here:

- The Processing website has references, examples, tutorials, etc.  
[https://processing.org/](https://processing.org/)

- Processing has lots to offer!  
An exploration of the tabs will reveal what is available; libraries, tools, _ **examples** _ and more.  
 ![image](https://canada1.discourse-cdn.com/flex036/uploads/processingfoundation1/original/2X/1/1d6a45100f4930df324acb8966086c8eaa28eee4.png)

- The Coding Train  
[https://www.youtube.com/channel/UCvjgXvBlbQiydffZU7m1\_aw](https://www.youtube.com/channel/UCvjgXvBlbQiydffZU7m1_aw)  
[https://thecodingtrain.com/](https://thecodingtrain.com/)

- Happy Coding  
[Processing Tutorials - Happy Coding](https://happycoding.io/tutorials/processing/)

`:)`

---

<div class="post-metadata">

**Author:** ![jakob.timo](https://avatars.discourse-cdn.com/v4/letter/j/a3d4f5/32.png) [@jakob.timo](https://discourse.processing.org/u/jakob.timo)\
**Post date:** [May 5, 2021, 12:27am UTC](https://discourse.processing.org/t/building-a-tower-out-of-squares-in-processing/29863/6 "2021-05-05T00:27:01Z")

</div>

```auto
  size(600,800);
  background(255,255,255);
  
  fill(255, 0, 0);
  rect(10,10,50,50);
  fill(0,0,255);
  rect(10,60,50,50);
  fill(255,0,0);
  rect(10,110,50,50);
  fill(0,0,255);
  rect(10,160,50,50);
   fill(255,0,0);
  rect(10,210,50,50);
  fill(0,0,255);
 rect(10,260,50,50);
  fill(255,0,0);
  rect(10,310,50,50);
   fill(0,0,255);
  rect(10,360,50,50);
  fill(255,0,0);
  rect(10,410,50,50);
   fill(0,0,255);
  rect(10,460,50,50);
  }

This is the code I came up so far
```

---

<div class="post-metadata">

**Author:** ![jakob.timo](https://avatars.discourse-cdn.com/v4/letter/j/a3d4f5/32.png) [@jakob.timo](https://discourse.processing.org/u/jakob.timo)\
**Post date:** [May 5, 2021, 12:30am UTC](https://discourse.processing.org/t/building-a-tower-out-of-squares-in-processing/29863/7 "2021-05-05T00:30:15Z")

</div>

Hey,  
I really did not know that there is a website like that and I will look into it. Really appreciating ur effort !! Thank u very much

---

<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:** [May 5, 2021, 1:17am UTC](https://discourse.processing.org/t/building-a-tower-out-of-squares-in-processing/29863/8 "2021-05-05T01:17:38Z")

</div>

That looks like a tower or squares to me! Good job!

---

<div class="post-metadata">

**Author:** ![glv](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/glv/32/18785_2.png) [@glv](https://discourse.processing.org/u/glv)\
**Post date:** [May 5, 2021, 2:04am UTC](https://discourse.processing.org/t/building-a-tower-out-of-squares-in-processing/29863/9 "2021-05-05T02:04:14Z")

</div>

Hello,

I see a pattern in your data!

Consider using a for() loop:

```auto
for(int y = 10; y<= 460; y+= 50)
  {
  println(y);
  // code here that uses y
 }

```

Reference:  
_[for \ Language (API) \ Processing 3+](https://processing.org/reference/for.html)_

`:)`

---

<div class="post-metadata">

**Author:** ![jakob.timo](https://avatars.discourse-cdn.com/v4/letter/j/a3d4f5/32.png) [@jakob.timo](https://discourse.processing.org/u/jakob.timo)\
**Post date:** [May 5, 2021, 2:18am UTC](https://discourse.processing.org/t/building-a-tower-out-of-squares-in-processing/29863/10 "2021-05-05T02:18:50Z")

</div>

Hey,  
My code is going to look a lot more cleaner and simpler with that. Literally thank u very much
