CSC 111: Introduction to Computer Science
HW 4: The Growing Fantasy Flower
Due Wednesday Feb 23 Midnight, via Moodle
SUBMIT as HW4.py
Office Hours Monday 2-3; Tuesday 1:30-2:30
Growing Fantasy Flower
For the homework, create a very simple animation of a flower, or something that could be interpreted as a flower, growing. Your fantasy flower should have a
stem, a center part of the flower, some petals and two leaves. It can have more elements if you want to add them.
Many of you were dissatisified with the simple jumping animation suggested for the lab, and you
made much more sophisticated animation - which is great! For this flower though, you can
certainly have it grow in jumps, rather than a visually gradual growth. One possible solution program
is Flower.py
- Your plant will start very small, with only a tiny stem and a small bud (which can be a circle or an oval).
- Then as the stem grows taller and gets a bit thicker, the flower center moves up with the top of the stem, and grows larger. This growing
phase should occur over at least four or so stages (which should bring the 'for' loop to mind). You will need a growth rate for the stem, and
perhaps a different one for the flower center.
- Once the plant has reached its mature height and size, add some petals around the flower center. These can be simple shapes, replicated
with the .clone() method if that is useful. You DO NOT need to rotate these shapes to make the flower petals all perfectly radiating out from the
flower center - just draw little shapes that could be interpreted as being petals, that are nicely spaced around your flower center. This will give
you a good workout with your coordinate system.
- Finally add two leaves to the stem - which can be any shape.
In addition to those elements
- Use interesting colors - calming, or exciting, or any other theme (a good color list is linked on the main syllabus page)
- Use names for variables and constants, as much as makes sense (especially if you find yourself
using the same value more than once).
- For placing the petals, you will probably want to use the trig (sine and cosine) operations
in the math library. Don't forget to keep track of whether you are operating in degrees
or in radians.
- Note that the graphics library is a bit simple, and so you may need to try more than one approach to getting this to work out the way you want.
- Use the .sleep() method again so the user can observe your flower growing.