In this challenge, you will use your knowledge of classes to create a Turtle animation.
 Set up💻 Go to your CS10 folder
git clone https://github.com/the-isf-academy/lab_ballpit.git
cd lab_ballpit poetry shell
This repository contains the following files:
 Exploring Ball Pit
The Ballpit is a little animation made with Turtle. You can watch it by running the following command in your terminal:
In the Ballpit, notice that each ball has a different behavior. One stays the same size the whole time and bounce off the walls. One doesn’t bounce at all. Instead, it warps around to the opposite side of the screen. And the last ball grows and shrinks as it moves. It looks like it’s breathing in and out.
For your reference, the BallPit has the following classes and functions. The
ball.py file contains the architecture of each
Ball object. The
ballpit.py file initializes the Turtle and instances of the
 Increase the chaos
At the moment, each
Ball object is the same shade of green. Wouldn’t it be nice if we could distinguish them? Your goal is to add more color into the pit!
💻 Add a unique color to the WarpBall and the BreathingBall.
BreathingBall simply call the parent
Ball method for
set_color(). Overide this method with the colors of your choosing.
In this lab we’ve included test files where you can experiment with changes to the
BreathingBallseparate from the ballpit. Run the following files to check if you’ve successfully changed the color of each object.
Let’s try running
ballpit.py again. You should see each
Ball appear with a distinct color.
Now that we’ve got the colors sorted, let’s add to the chaos and add more balls to the pit. At the moment, there is only one of each type of
Ball object displayed in the Turtle window.
*Hint! Consider the following…
- What data strucutre currently holds the instances of
- What is the most code efficent solution?
Check-in with a teacher by demonstrating your improved
 Extension: Randomizing the chaos
If time allows, ramp up the chaos even further by introducing the idea of cycling through colors. For example, every time a
Ball object is created, it selected a different shade of green.
*Hint! Consider how the color is currently chosen in the
Be sure to push any customization you’ve made to your ballpit!