Question: For this question, you will write a program where the user can move a Pok Ball left and right, and the Pok Ball must

For this question, you will write a program where the user can

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.

Step by Step Solution

3.44 Rating (151 Votes )

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!