Question: This is the description about my programming ( This programming language is PROCESSING 3+ ) Here is my code and I want to make the

This is the description about my programming ( This programming language is PROCESSING 3+)
Here is my code and I want to make the code include this description I attached. Please help me.. I stuck in :/
(P.S If you explain the code you did, Can you explain that ? )
float xspeed; float yspeed; float xpos; float ypos;
void setup(){ size(600,400); noStroke(); fill(290,100,100,255);
xpos = width/2; ypos = height/2; xspeed=random((width/150),(width/100)); yspeed=random((height/100),(height/80)); } void draw(){ int r = (width/120); background(0); xpos = xpos + xspeed; if (xpos+r > width || xpos-r
ypos = ypos + yspeed; if (ypos+r > height || ypos-r
circle(xpos,ypos,r*r);
}
When the ball hits the left or right edge of the canvas, create a rectangular obstacle in the other side of the canvas. The size and the location of the obstacle are determined by generating a random coordinate (say ox and oy): a vertex of the obstacle has the coordinate (ox, oy), and the opposite vertex of the obstable is the canvas corner, closest from (ox, oy). For example, if the ball hits the right edge of the canvas, ox is 200, and oy is 350, the closest canvas corner is the left bottom (0,height). Use the following value range for (ox, oy) (r means the radius of the ball): Case oxmin Oxmax oymin oymax Hits Right Canvas Edger width/2 height - Hits Left Canvas Edge width/2 width- height- The obstacle will be drawn as a white rectangle, and the ball should bounce at the boundary of the obstacle as it bounce at the edge of the canvas. It is pretty obvious that the ball should not go out of the canvas or pass through the obstacle. 1 When the ball hits the left or right edge of the canvas, create a rectangular obstacle in the other side of the canvas. The size and the location of the obstacle are determined by generating a random coordinate (say ox and oy): a vertex of the obstacle has the coordinate (ox, oy), and the opposite vertex of the obstable is the canvas corner, closest from (ox, oy). For example, if the ball hits the right edge of the canvas, ox is 200, and oy is 350, the closest canvas corner is the left bottom (0,height). Use the following value range for (ox, oy) (r means the radius of the ball): Case oxmin Oxmax oymin oymax Hits Right Canvas Edger width/2 height - Hits Left Canvas Edge width/2 width- height- The obstacle will be drawn as a white rectangle, and the ball should bounce at the boundary of the obstacle as it bounce at the edge of the canvas. It is pretty obvious that the ball should not go out of the canvas or pass through the obstacle. 1
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
