I can't make the rectangle move to another location. The if statement won't work but this time I don't use animation. Link: https://www.khanacademy.org/computer-programming/video2cut2/5517447191543808. Code:
noStroke();
var x = 0;
var y = 0;
var s = 35;
var r1 = random(25, 375);
var r2 = random(25, 375);
if (mouseX > -25 && mouseX < 25 && mouseY > -25 && mouseY < 25) {
r1 = random(25, 375);
r2 = random(25, 375);
}
background(0, 0, 0);
translate(r1, r2);
rectMode(CENTER);
rect(x, y, s, s);
Aucun commentaire:
Enregistrer un commentaire