For this question, you will write a program where the user can move a Pok Ball...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
For this question, you will write a program where the user can move a Poké Ball left and right, and the Poké Ball must also rotate accordingly. Your program should behave as follows: When the program starts: Display a blank, grey canvas with a Poké Ball drawn in the middle of the canvas. When the user presses the right arrow key: The Poké Ball should move to the right while rotating clock- wise. When the user presses the left arrow key: The Poké Ball should move to the left while rotating counter- clockwise. When the user releases an arrow key: The Poké Ball should stop moving and rotating. You will need to use variables in this program to keep track of the horizontal (x) position of the Poké Ball, as well as how much it has been rotated. pokeball X Figure 3: Canvas after the Poké Ball has been drawn. You should follow the model-view-controller design pattern. The Poké Ball should be drawn inside of its own function (draw_pokeball ()) which takes two parameters: the x-coordinate, and the angle of rotation. These values should change depending upon the user pressing the left or right arrow keys. The movement speed and rotation speed should be defined as variables in the model, rather than as literals in the code, although those values should not change (choose any speed you like). Hint: Drawing much of the Poké Ball and handling its rotation can be done by passing the correct argu- ments into Processing's arc () function. Hint: Checking that the arrow keys are pressed can be done by checking keyCode rather than key. For this question, you will write a program where the user can move a Poké Ball left and right, and the Poké Ball must also rotate accordingly. Your program should behave as follows: When the program starts: Display a blank, grey canvas with a Poké Ball drawn in the middle of the canvas. When the user presses the right arrow key: The Poké Ball should move to the right while rotating clock- wise. When the user presses the left arrow key: The Poké Ball should move to the left while rotating counter- clockwise. When the user releases an arrow key: The Poké Ball should stop moving and rotating. You will need to use variables in this program to keep track of the horizontal (x) position of the Poké Ball, as well as how much it has been rotated. pokeball X Figure 3: Canvas after the Poké Ball has been drawn. You should follow the model-view-controller design pattern. The Poké Ball should be drawn inside of its own function (draw_pokeball ()) which takes two parameters: the x-coordinate, and the angle of rotation. These values should change depending upon the user pressing the left or right arrow keys. The movement speed and rotation speed should be defined as variables in the model, rather than as literals in the code, although those values should not change (choose any speed you like). Hint: Drawing much of the Poké Ball and handling its rotation can be done by passing the correct argu- ments into Processing's arc () function. Hint: Checking that the arrow keys are pressed can be done by checking keyCode rather than key. For this question, you will write a program where the user can move a Poké Ball left and right, and the Poké Ball must also rotate accordingly. Your program should behave as follows: When the program starts: Display a blank, grey canvas with a Poké Ball drawn in the middle of the canvas. When the user presses the right arrow key: The Poké Ball should move to the right while rotating clock- wise. When the user presses the left arrow key: The Poké Ball should move to the left while rotating counter- clockwise. When the user releases an arrow key: The Poké Ball should stop moving and rotating. You will need to use variables in this program to keep track of the horizontal (x) position of the Poké Ball, as well as how much it has been rotated. pokeball X Figure 3: Canvas after the Poké Ball has been drawn. You should follow the model-view-controller design pattern. The Poké Ball should be drawn inside of its own function (draw_pokeball ()) which takes two parameters: the x-coordinate, and the angle of rotation. These values should change depending upon the user pressing the left or right arrow keys. The movement speed and rotation speed should be defined as variables in the model, rather than as literals in the code, although those values should not change (choose any speed you like). Hint: Drawing much of the Poké Ball and handling its rotation can be done by passing the correct argu- ments into Processing's arc () function. Hint: Checking that the arrow keys are pressed can be done by checking keyCode rather than key. For this question, you will write a program where the user can move a Poké Ball left and right, and the Poké Ball must also rotate accordingly. Your program should behave as follows: When the program starts: Display a blank, grey canvas with a Poké Ball drawn in the middle of the canvas. When the user presses the right arrow key: The Poké Ball should move to the right while rotating clock- wise. When the user presses the left arrow key: The Poké Ball should move to the left while rotating counter- clockwise. When the user releases an arrow key: The Poké Ball should stop moving and rotating. You will need to use variables in this program to keep track of the horizontal (x) position of the Poké Ball, as well as how much it has been rotated. pokeball X Figure 3: Canvas after the Poké Ball has been drawn. You should follow the model-view-controller design pattern. The Poké Ball should be drawn inside of its own function (draw_pokeball ()) which takes two parameters: the x-coordinate, and the angle of rotation. These values should change depending upon the user pressing the left or right arrow keys. The movement speed and rotation speed should be defined as variables in the model, rather than as literals in the code, although those values should not change (choose any speed you like). Hint: Drawing much of the Poké Ball and handling its rotation can be done by passing the correct argu- ments into Processing's arc () function. Hint: Checking that the arrow keys are pressed can be done by checking keyCode rather than key.
Expert Answer:
Related Book For
Java An Introduction To Problem Solving And Programming
ISBN: 9780134462035
8th Edition
Authors: Walter Savitch
Posted Date:
Students also viewed these programming questions
-
What is the structural composition of lysosomes and how does it contribute to their functionality within the cell's intracellular environment?
-
Planning is one of the most important management functions in any business. A front office managers first step in planning should involve determine the departments goals. Planning also includes...
-
You need to write a paper about six types of Wounds
-
Process compliance can be affected by: Multiple select question. organizational structure. maverick purchasing. organizational culture. information systems
-
Show that the total energy E of an earth satellite of mass m describing an elliptic orbit is E= ?? GMm/(rA + rP), where M is the mass of the earth, and rA and rP represent, respectively, the maximum...
-
Consider the single replicate of the 2 4 design in Example 6-2. Suppose that we ran five points at the center (0, 0, 0, 0) and observed the following responses: 73, 75, 71, 69, and 76. Test for...
-
Refer to Figure 8, the sequence diagram for the Make Appointment use case. Three spaces are identified in this diagram. Explain the significance of each.
-
In another version of the "Giant Swing" (see Exercise 5.52), the seat is connected to two cables as shown in Fig. 5.58, one of which is horizontal. The seat swings in a h0ri2ontal circle at a rate of...
-
(a) Table 1 shows a truth table. Table 1 A 0 BO C X 0 0 1 0 0 1 1 0 1 0 1 0 1 1 1 1 0 0 1 1 0 1 0 1 1 0 1 1 1 1 0 (i) Produce a Boolean expression for X in terms of A, B and C based on the truth...
-
Dry Supply is a wholesaler of dry cleaning equipment, cleaning supplies, and laundry soap. This company is located in Kansas, it has been in business for over 50 years. Anne Schippel, is a business...
-
One of our products is a public-facing web and mobile application which allows publishers to set up their own video ad campaigns. The following outlines a new feature thats been added after the...
-
Modify the following for loop into a while loop. int t=0; for (int i=1; i
-
Find a closed-form expression for the following optimization problems. 1. min ||x||2 ax = b, : X 2. 3. where a ER and b = R are given. max ax ||x||p 1, where a = Rn is given and p = {1, 2, 0}. max...
-
What is the output of the following code? void Foo(ints y) ( y-10; void Function(int& x) { Foo(x); x+2; } int main() { int value 5; Function(value); cout < < value; return 0;
-
What is the output of the following code? void Function(int& x) int main( A int value- 12; Function(value); cout < < value; return 0;
-
What will the following code print out? int x-7; int one &x; x-14; int two-&x; two 3; cout < < "one < < *two;
-
Calculate the enthalpy change for the decomposition reaction in kilojoules per mole of N H 4 C l O 4 in kJ/mol? Substance H 2 O ( g ) H C l ( g ) N H 4 C l O 4 ( s ) delta H ( k J / m o l ) -241.82...
-
Sue Deliveau opened a software consulting firm that immediately paid $2,000 for a computer. Was this event a transaction for the business?
-
Draw a hierarchy for the components you might find in a graphical user interface. Note that some components can trigger actions. Some components may have graphics associated with them. Some...
-
Suppose that you have a binary file that contains numbers whose type is either int or double. You dont know the order of the numbers in the file, but their order is recorded in a string at the...
-
Repeat the previous exercise, but change next to nextLine in the statement that assigns a value to b. Previous exercise What does the Java code Scanner keyboard = new Scanner(System.in);...
-
Explain the building blocks of accounting: ethics, principles, and assumptions.
-
On May 1, 2025, Park Flying School Ltd., a company that provides flying lessons, was started with an investment of 45,000 cash in the business. Following are the assets and liabilities of the company...
-
The historical cost basis results in: a. initially recording assets at cost and adjusting when the current value changes. b. keeping activities of an entity separate and distinct from its owner. c....
Study smarter with the SolutionInn App