hello
i want the rectangles that are moving down to be in a loop moving downwards and i don’t know how to do that, so when it goes off screen it starts at the top and moves downwards and repeats that cycle over and over again. i am fairly new to this program so im sorry if i dont understand what to do.
take a look at my code:
//variables
float xmovement ;
float whereIsIt ;
float one = -60;
float two = -150 ;
float three = -110;
float four = -200 ;
float five = -130 ;
float six = -200 ;
float seven = -450;
float eight = -200;
float nine = -300;
int Xposition;
//setup
void setup() {
size (370, 500) ;
background (255) ;
xmovement = -20 ;
Xposition=250;
}
//rectangles
void draw () {
frameRate (100) ;
fill (0) ;
noStroke() ;
rectMode (CENTER) ;
rect (185, 250, 350, 480) ;
fill (255) ;
rect (mouseX, 460, 35, 10) ;
// falling obstackles
rect (150, xmovement, 9, 23) ;
rect (Xposition, one, 9, 23) ;
rect (250, two, 9, 23) ;
rect (100, three, 9, 23) ;
rect (270, four, 9, 23) ;
rect (300, five, 9, 23) ;
rect (90, six, 9, 23) ;
rect (40, seven, 9, 23) ;
rect (160, eight, 9, 23) ;
rect (230, nine, 9, 23) ;
// logic
xmovement = xmovement + random(1, 6) ;
one = one + 4 ;
two = two + 3 ;
three = three + 4.5;
four = four + 2;
five = five + 5 ;
six = six + 2;
seven = seven + 5;
eight = eight + 4;
nine = nine + 2.8;
}