In this assignment you must use list comprehensions to generate sprites that show the behavior of certain mathematical functions: sine and cosine. See the references at the end for a tutorial that introduces this technique.
Fork this repository and create your program in the sinecosine.py
file.
The sine and cosine functions are provided in the Python math
library. These functions are used
to relate angles to rectangular (x,y) coordinate systems and can be very useful in computer
game design.
Unlike the last assignment using ggame
, this one will not provide any "skeleton" code to fill
in. You should use your submission for the Picture assignment
as a reference for starting this assignment.
Your program must:
- Import the necessary names (e.g. CircleAsset, App, etc.) from the
ggame
library. - Import
sin
,cos
, andradians
names from themath
library. - Using the technique in the last tutorial, generate a series of blue circles, a series of red circles, and a series of purple circles, such that:
- The x-coordinates of the blue and red circles will vary between 0 and 360, in steps of 10.
- The y-coordinates of the blue circles will be calculated using:
100+100*sin(radians(x)))
, where x values come from the x-coordinates in step 4. - The y-coordinates of the red circles will be calculated using:
100+100*cos(radians(x)))
, where x values come from the x-coordinates in step 4. - The x-coordinates of the purple circles will be calculated using:
100+100*cos(radians(x))
, where x values come from the x-coordinates in step 4. - The y-coordinates of the purple circles will be calculated using:
400+100*sin(radians(x))
, where x values come from the x-coordinates in step 4.
The final result should look like sine and cosine curves in blue and red, and a circle of circles in purple.
Submit your work in the usual way.