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
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)
Step by Step Solution
3.56 Rating (163 Votes )
There are 3 Steps involved in it
Step: 1
Animated Planet and Moons with Elliptic Orbits in p5js Heres the p5js code for the animated planet and moons javascript let canvasWidth canvasHeight l...Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started