//Declare the following variables to record the current location of the box float x_pos; float y_pos; //Declare the following variables to record the velocity of the box float x_vel; float y_vel; void setup() { //Set the canvas size size(800, 800); //Set the background color of the canvas background(192, 64, 0); //Set the stroke color as white stroke(255, 255, 255); x_pos = 20; // Center of screen y_pos = 20; x_vel = 8; y_vel = 2; } void draw() { //************************************************************************** //Clear the canvas and Draw a ball in new position centered at (x_pos, y_pos): //Set the fill color to the red color, and then draw a circle with radius 20. //************************************************************************** background(192, 64, 0); fill(255, 0, 255); ellipse(x_pos, y_pos, 20, 20); // Update to the new position x_pos += x_vel; y_pos += y_vel; // Update the speed to show gravity y_vel += 0.1; // Bounce off left & right wall if ((x_pos<20) || (x_pos> 800 -20)) { x_vel = x_vel* -1; } // Bounce off floor & ceiling if ((y_pos<20) || (y_pos> 800 -20)) { y_vel = y_vel * -1; } //************************************************************************** // Draw a vertical wall with x coordinate = mouseX //************************************************************************** fill(0, 255, 0); rect(mouseX, 0, 20, 800); }