In: Computer Science
programming with processing
Draw a circle in the top left corner of the screen. make your circle go around a square path continuously.the cycle should
-in a straight line go to the far-right side of the window
-in a straight line go to the bottom of the window
-in a straight line go to the far-left corner of the window
in a straight line go to the top left of the window
-keep repeating the above steps
This process should be repeated until program is terminated
drawing should not go out of the bounds of the window .
i have this so far can't get it to got to the left:
int x = 40, y = 40;
void setup()
{
size(600, 600);
}
void draw()
{
background (200);
ellipse (x, y, 80, 80);
if ((x<560))
{
x=x+xdir;
}
else if(y<560)
{y=y+ydir;
}
else if(x<560)
{
}
}
int x = 40, y = 40; void setup() { size(600, 600); } void draw() { background (200); ellipse (x, y, 80, 80); // Move Up if (x == 40) { if(y == 40) { x = x + xdir; // Start going right } else { y = y - ydir; // Keep coming up. } } // Move down. else if (x == 560) { if(y == 560) { x = x - xdir; // Start going right } else { y = y + ydir; // Keep coming up. } } // Move Right. else if (y == 40) { if(x == 560) { y = y + ydir; // Keep coming down. } else { x = x + xdir; // Start going right } } // Move Right. else if (y == 560) { if(x == 40) { y = y - ydir; // Keep coming Up. } else { x = x - xdir; // Start going left } } }
************************************************** Thanks for your question. We try our best to help you with detailed answers, But in any case, if you need any modification or have a query/issue with respect to above answer, Please ask that in the comment section. We will surely try to address your query ASAP and resolve the issue.
Please consider providing a thumbs up to this question if it helps you. by Doing that, You will help other students, who are facing similar issue.