Question: 3. Drawing with Lists This problem extends the animation we created in part 2 to include lists of birds and trees Modify the BouncingRectangle animation

3. Drawing with Lists

This problem extends the animation we created in part 2 to include lists of birds and trees

Modify the BouncingRectangle animation code to do the following:

Add a variable self.birds = [] for a list of bird objects

Add a variable self.trees = [] for a list of tree objects

Add code in .setup to create a list of 5 birds placing them in random locations on the top half of the screen

it will help if you set the speed using B.set_speed(4,0) so they fly horizontally

Add code to create a list of 100 trees placing them in random locations on the bottom half of the screen

Add code to the on_draw function to call B.update(WIDTH,HEIGHT) for each bird B in the list of birds

Add code to the on_draw function to call T.draw() for each tree T in the list of trees

If you have done this correctly, you should have a forest of trees at the bottom and a few birds flying (moving) on the top

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!