p5 js stop moving object on mouse click code example Example: how to make an object stop at the end of your canvas p5js y = constrain(y, 0, 570);