class ColorSquare { float xpos, ypos, squareSize; float xspeed, yspeed; color c; ColorSquare(float xpos_, float ypos_, float squareSize_, color c_) { xpos = xpos_; ypos = ypos_; c = c_; xspeed = random(-2, 2); yspeed = random(-2, 2); squareSize = squareSize_; } void render() { noStroke(); fill(c); rectMode(CENTER); rect(xpos, ypos, squareSize, squareSize); } void update() { xpos += xspeed; ypos += yspeed; if (xpos > width || xpos < 0) { xspeed *= -1; } if (ypos > height || ypos < 0) { yspeed *= -1; } } }