Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

circle c = new circle(100,75,5,5,30); void setup() {size(400, 400); frameRate(30

ID: 3644937 • Letter: C

Question

circle c = new circle(100,75,5,5,30);

void setup() {size(400, 400);
frameRate(30);
smooth();
}

void draw(){ background(204);
c.mover();
c.display();
fill(35,40,232);
rect(115,90,195,220); }

class circle {
float x,xs,y,ys,r;

circle (float xpos, float ypos,float xspeed,float yspeed,float radi) {
x=xpos;
y=ypos;
xs=xspeed;
ys=yspeed;
r=radi;

}

void mover() {if(key == 'a'){

x+=xs;
if(x == 325)
{xs=0; ys=5; y+=ys;}
if(y == 325)
{ys=0; xs=-5;}
if(x == 100)
{xs = 0; ys = -5; y+=ys;}
if(y == 75)
{ys=0; xs=5;}}}

void display(){

fill(250,0,205);
ellipse(x,y,r,r);
}
}



Here is my code and there is a circle moving around a rectangle. I want to initiate it with using 'a' key and stop it with using 'b' key.I can start it with pressing 'a'. However if I press any other keys(like 'd' or 'i') circle stops moving around the rectangle. I just want to stop my circle with using 'b' key. Can someone help me? Thanks.

Explanation / Answer

use another function " stopper " if the key is b ..and reset all the variables moving along the circle..