# Help Assignment: Solar System Part II

Help Assignment: Solar System Part II
Overview
In this practical session we are going to extend the Solar System sketch that we created last time to include more planets and some interactive features !
Task 1
Update your program so that it includes not only the earth, but also the other four planets closest to the sun (Mercury, Venus, Earth and Mars)
In order to do this, you will have to convert the name, image, radius, distance and speed variables (from the last practical) into Arrays
(so that they can hold values for all planets and not just the Earth)
In the setup function, fill these arrays with appropriate values
Use the following values for speed of orbit: Mercury 0.0455, Venus 0.0178, Earth 0.0109, Mars 0.0058
Search the internet and find out the correct radii and distances from the Sun of all the planets
Enter these values into your arrays when your program starts up (in the setup function)
(you might like to scale down the sun – it’s a bit big !!!)
Task 2
Add code to the draw function so that it shows animated (orbiting) versions of all planets (including their name labels !)
You MUST use a loop to transverse the arrays – don’t go manually accessing the sun, then mercury, then venus line-by-line
Don’t forget to reset the “graph paper” after you draw each planet – otherwise your planets won’t appear where they should !
(Hint: you will have to “undo” each rotation and translation you make for a particular planet before moving on to the next)
Task 3
Add some code to your program to make it respond to key presses…
When the user presses the + key, make the solar system zoom in (planets get bigger and distances from the planet to the centre of the solar system get larger)
When the user presses the – key, make the solar system zoom out (planets get smaller and distances from the planet to the centre of the solar system get smaller)
One way to do this is to add a new variable to hold the scaling factor and use this to adjust all drawing and translations
Task 4
Add some code to your program to make it respond to mouse movement…
When the user drags the mouse to the right, make the animation speed up (the further they drag, the faster the speed-up)
When the user drags the mouse to the left, make the animation slow down (the further they drag, the bigger the slow-down)
Hint: You might want to include mousePressed, mouseMoved and mouseDragged functions
Task 5 – Optional
Think about how you would add a moon orbiting the earth
Give it a go if you think you can handle it !!!
Task 6 – Optional
Add the remaining planets in our solar system to your program
Make sure you use appropriate radii, distances and orbit speeds

This site uses Akismet to reduce spam. Learn how your comment data is processed.