float x1 = random(50, 450);
float y1 = random(50, 450);
int size1 = 100;
float inc1X = 3;
float inc1Y = 3;
float x2 =x1;
float y2 = x1;
int size2 = 50;
float inc2X = 3;
float inc2Y = 3;
boolean place1 = true;
void setup () {
size(500, 500);
}
void draw () {
if (place1 = true) { //supposed to only work once
float x2 =x1;
float y2 = y1;
place1 = false;
}
background(255);
rectMode(CENTER);
fill(120);
rect(x1, y1, size1, size1);
x1+=inc1X;
y1+=inc1Y
if (x1>width-size1/2) {
inc1X = inc1X * -1;
}
if (x1<size1/2) {
inc1X = inc1X * -1;
}
if (y1>height-size1/2) {
inc1Y= inc1Y * -1;
}
if (y1<size1/2) {
inc1Y = inc1Y * -1;
}
fill(255);
rect(x2, y2, size2, size2);
x2+=inc2X;
y2+=inc2Y
}
My code is supposed to set the little square’s position only once to the big square at the beginning, but does it every frame. Can someone help me?