# Help on loops (I'm a beginner)

**URL:** <https://discourse.processing.org/t/help-on-loops-im-a-beginner/21155>\
**Category:** Coding Questions\
**Tags:** homework\
**Created:** [May 22, 2020, 2:21am UTC](https://discourse.processing.org/t/help-on-loops-im-a-beginner/21155 "2020-05-22T02:21:52Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![lexy897](https://avatars.discourse-cdn.com/v4/letter/l/51bf81/32.png) [@lexy897](https://discourse.processing.org/u/lexy897)\
**Post date:** [May 22, 2020, 2:21am UTC](https://discourse.processing.org/t/help-on-loops-im-a-beginner/21155/1 "2020-05-22T02:21:52Z")

</div>

Hi there!

I’m new to processing and this forum so please be patient haha. I need to make a processing code that moves 4 squares that touch each other down the screen in unison. I’ve figured out the speed and moving one square, but how do I turn this into a loop where all of the squares move at the same speed so I don’t have to repeat my code four times?

hopefully this makes sense.

Thanks!!

---

<div class="post-metadata">

**Author:** ![SomeOne](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/someone/32/8639_2.png) [@SomeOne](https://discourse.processing.org/u/SomeOne)\
**Post date:** [May 22, 2020, 4:10am UTC](https://discourse.processing.org/t/help-on-loops-im-a-beginner/21155/2 "2020-05-22T04:10:43Z")

</div>

Hi,

Welcome to the forum.

It’s a bit hard to help you to right direction without your code. Please have a look at [Guidelines—Asking Questions](https://discourse.processing.org/t/guidelines-asking-questions/2147) and include your code.

in general term you need a data structure to store information of your rectangles and a loop where you go though all those rectangles and move them. Data structure like array helps to construct a loop without repetitive code.

---

<div class="post-metadata">

**Author:** ![lexy897](https://avatars.discourse-cdn.com/v4/letter/l/51bf81/32.png) [@lexy897](https://discourse.processing.org/u/lexy897)\
**Post date:** [May 22, 2020, 4:23am UTC](https://discourse.processing.org/t/help-on-loops-im-a-beginner/21155/3 "2020-05-22T04:23:03Z")

</div>

Okay thankyou very much!!
