class Goal{ float x,y; //-------------- Goal(float x, float y){ this.x = x; this.y = y; } //-------------- void update(){ if(max( abs(ball.x-x), abs(ball.y-y) ) < 10 ) respawn(); } //-------------- void respawn(){ x = random(10,width-10); y = random(10,width-10); } //-------------- void visualize(){ stroke(255); strokeWeight(1); fill(128,128,255); rect(x-10,y-10,20,20); } }