Subprograms
A Simple Comet
The purpose of this exercise is to animate the planets using subprograms.
Question 1
Implement Compute_X
and Compute_Y
functions and use them in the main loop to
update X
and Y
coordinates of every object.
Question 2
Implement the Move
subprogram and use it to move the objects instead of doing all
computations in the main loop.
Move
should also update the angle.
Question 3
Implement a procedure Draw_Body
which is a wrapper to call Draw_Sphere
.
From the main loop call Draw_Body
instead of directly drawing Draw_Sphere
.
Draw_Body
should only take 2 parameters.
Question 4
Add a tail to the comet that rotates around the Sun
.
Hint: Try adding a Has_Tail
component to Body_T
, then modifying Draw
to display the tail properly.
Hint #2: An object that has a tail can be seen as being “followed” by small circles that are moved in the opposite direction from the body being drawn.