In this project we are supposed to learn how to use graphics objects to draw pictures and make animations. Also, we understand how to write more effective codes.
The first required picture is each complex object we build in complex_shape.
My first object is a stoplight. When it is animated, it can shift color from green to yellow and red.
The second object is a marine. It is a character from Starcraft. When it is animated it can fall from the sky.
The third thing is a plane which can fly through the window when animated.
The fourth thing is a building. When animated the windows on the building can shift color from yellow to black randomly.
my code to make it is shown below.
for i in range (50):
for item in m:
(m is a list of those windows)
Next object is a monster. When it is animated it can grow larger. I show my code below.
for i in range (40):
for i in range (40):
(size is the origin size of the monster. I undraw the old monster and redraw a new larger monster at same location for every loop)
Here is the movie with all of my work in it. Specially I used thread module to create subprocess for each function so that they can process at same time.
Here is one example:
for i in range(6):
In this way I can air drop another marine when the first marine haven't reach the ground.
I write all my codes and make the gif on my pc so the picture may looks messy. I used a online gif tool to make this gif.
1. I draw 5 things totally so it is 3 more than required.
2. Set up a system that creates a scene out of complex objects based on a list that gives the name, location, and scale of each complex object in the scene.
I still want to call my functions one by one so that I can set up some arguments. However, if I wish I can also use list to store name location etc. of objects.
and then if my functions have same number of arguments I can use
for i in clist:
to draw these pictures. This way can save some times. But my functions have different arguments so this time I can't use it in my main function.
In this object, I learned how to use graphics module to make animations. The use of time.sleep function in loops is new and interesting.
Including shapes in a list to process a whole picture as a unit is also an efficient way. Another thing is the use to thread module.
I wanted to run two function at the same time so I learned thread module online by myself. Sub-processing is very useful in the future study.