Help on loops (I'm a beginner)

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.


1 Like


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 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.

1 Like

Okay thankyou very much!!