Versions Compared


  • This line was added.
  • This line was removed.
  • Formatting was changed.

The purpose of this project was to use lists to streamline code, especially in places where a single function is used several times on a set of objects. Using for loops and lists makes it possible to do a single operation on many objects with just a few lines of code. This type of algorithm was useful for this project where we drew pictures with moving elements. The elements move on a given set track, so making several elements move at once was just a matter of putting this those elements in a list and using a loop on that list.

I decided to make my moving image a simple simpler version of a ball factory like this more complex one:


Mine would have to be much simpler. I started by making a function, ramp_init, that draws a pair of ramps: one going up and one going down. I used the Zelle graphics library's Polygon function to draw a pair of triangles. Then I added those triangles, which are technically objects, to a list I called shapes. Then when want to draw the triangles I can simply use Zelle's draw function on that list. I essentially turned two drawing functions into one, which would save more time had I more shapes to draw.