Question

In: Computer Science

programming with processing Draw a circle in the top left corner of the screen. make your...

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)
{
  

}
  
  
}

Solutions

Expert Solution

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.


Related Solutions

In the PhET simulation window, click the Two Atoms menu in the top left corner of...
In the PhET simulation window, click the Two Atoms menu in the top left corner of the screen. Click on the partial charges check box to see the partial charges of the atoms. Vary the electronegativity of atom A and atom B and observe the effects on the partial charge of each accordingly. Use the PhET to complete the sentences describing how electronegativity is related to bond dipole experienced by the molecule.
Part A In the PhET simulation window, click the Macro menu in the top left corner...
Part A In the PhET simulation window, click the Macro menu in the top left corner of the screen. This view gives a view of the beaker at a macroscopic level (as your naked eye would see it). The Micro menu shows what happens to sugars and salts at the molecular level when they dissolve in water (note that you can use the arrows to switch to other type of solutes). Use both the Macro and Micro menus in the...
The figure shows 3 point charges at the corners of a rectangle. The top left corner...
The figure shows 3 point charges at the corners of a rectangle. The top left corner is positive 10nC and the bottom left corner is 5 nC they are both positive. The top side is 3cm while the right side is 4cm the bottom and the left sides are also the same. The top right corner is -10 nC. A -15nC charge is placed at the emply corner that being the bottom right. A) find the electric potential at the...
Java Programming Question The problem is to count all the possible paths from top left to...
Java Programming Question The problem is to count all the possible paths from top left to bottom right of a MxN matrix with the constraints that from each cell you can either move to right or down.Input: The first line of input contains an integer T, denoting the number of test cases. The first line of each test case is M and N, M is number of rows and N is number of columns.Output: For each test case, print the...
1. One of your colleagues has left their screen open (logged into MUSE), you have a...
1. One of your colleagues has left their screen open (logged into MUSE), you have a huge workload and need to order entry/edit your requisition. Your colleague is nowhere to be found. What would you do? 2. You are about to do an ECG on a patient and are typing their information into the system when you notice that the date of birth is wrong, and the patient’s last name is misspelled. Your patient insists you get the ECG done...
* Make sure you turn in your code (take a screen shot of your code in...
* Make sure you turn in your code (take a screen shot of your code in R)and answers. Conduct the hypothesis and solve questions by using R. 2) A random sample of 12 graduates of a secretarial school averaged 73.2 words per minute with a standard deviation of 7.9 words per minute on a typing test. What can we conclude, at the .05 level, regarding the claim that secretaries at this school average less than 75 words per minute on...
Draw a circle and construct "a pie chart" that describes your identity as you see it...
Draw a circle and construct "a pie chart" that describes your identity as you see it in terms of groups with which you are associated and that you consider to be important. The degree of importance of each group is represented by the magnitude of each slice of the pie chart. Please describe each slice of your circle and how much it means to you. We all belong to different groups (be specific): Possible groups: family (you are a husband,...
Explain why the brain interprets top-down processing information the way that it does. Explain your OPINON...
Explain why the brain interprets top-down processing information the way that it does. Explain your OPINON as to why these differences exist. Also, Provide the definition of both sensation and perception, as well as stimuli, IN YOUR OWN WORDS. How do they differ? How are they related?
make a table of important vitamin facts. At the top of the document list your demographic...
make a table of important vitamin facts. At the top of the document list your demographic (age/sex) category. In the table, include the following information for all vitamins (there are 13 - see Chapter 9 & 10) RDA and UL for your demographic (age/sex) - and state what that is. Provide appropriate, accurate units On tests you will need to know RDAs and ULs for all groups - remember that you can refer to the tables inside the text if...
1) Standard MLA Heading. Top-left: Your name, professor's name, course number/section, and date. Double-space your paper...
1) Standard MLA Heading. Top-left: Your name, professor's name, course number/section, and date. Double-space your paper and use 12-pt. font with 1-inch margins all around. 2) Title. Create your own title for your essay. Don't call it "Final Exam" or the source essay title. 3) Opening Paragraph. Write 1 opening (introductory) paragraph. Make sure that this introductory paragraph includes your thesis statement, along with the source essay's title and author, properly formatted and spelled. Use transitional words or phrases to...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT