For this question, you will draw an animated planet and moons using p5js. Set the background colour
Question:
For this question, you will draw an animated planet and moons using p5js.
- Set the background colour to black. Draw the planet as 2 half circles, one bright, one dark.
Draw two smaller circles to represent the moons, one yellow and one white. The size of each moon should be half the size of the planet. Position the moons using the angular arithmetic used in the last slide of 3.4 Math functions.
Animate the angle of the two moons at different speeds so that the moons will orbit the planet on an elliptic track, one faster than the other. Draw the track of each moon in a similar colour to its respective moon. (4 marks)
Add an additional smaller moon that orbits one of the other moons. (This will mean you should have 3 moons total now). (2 marks)
Have which half of the planet is dark or light change based on the position of one of the larger moons (either yellow or white). This means the planet will spin such that its bright half will always face the selected moon. (2 marks)
Add a small circle in the centre of the planet. Colour this circle based on which moon is closest, i.e. white if the white moon is closest, yellow if the yellow is closest. (2 marks)
Important Notes!
For all parts of this question, it must be easy to change the size and position of the planet in the code. The moon's size and position should be automatically updated accordingly. (2 marks)
Intermediate Accounting
ISBN: 978-1260481952
10th edition
Authors: J. David Spiceland, James Sepe, Mark Nelson, Wayne Thomas