12. Ball Animation

Ball Animation Lab

In this lab we are going to create 3 different ball animations.


[0] Set up

๐Ÿ’ป Go to your cs9/unit00_drawing folder.

cd ~/desktop/making_with_code/cs9/unit00_drawing/
๐Ÿ’ป Clone your repo. This will copy it onto your computer.
git clone https://github.com/the-isf-academy/lab_ball_animation_yourGithubUsername

Below you’ll see that the git clone command has a yourGithubUsername.

You need to replace this with your username

e.g. https://github.com/the-isf-academy/lab_ball_animation_emmaqbrown

๐Ÿ’ป In the Terminal, type the following command to open the lab folder.
cd lab_ball_animation_yourGithubUsername

๐Ÿ’ป Enter the Poetry Shell to start the lab. As a reminder, we will run this command at the start of each lab, but only when we are inside a lab folder.

poetry shell
๐Ÿ‘พ ๐Ÿ’ฌ Exiting the poetry shell
When you want to exit the shell, you can type exit or ^D

๐Ÿ’ป Take a look at the files inside with: ls

  • breathing_animation.py
  • movement_animation.py
  • color_animation.py
  • basic_shapes.py
  • helpers.py
  • settings.py
  • extension_animation.py

[1] Ball Animations

[Breathing]

๐Ÿ’ป Open the file: breathing_animation.py

๐Ÿ’ป Try running the file: python breathing_animation.py. Currently, there is no animation. A purple ball just appears on the screen.

๐Ÿ’ป Change the code so the ball grows and shrinks. It should look like it’s “breathing”.


[Movement]

๐Ÿ’ป Open the file: movement_animation.py

๐Ÿ’ป Try running the file: python movement_animation.py. Currently, there is no animation. A light blue ball just appears on the screen.

๐Ÿ’ป Change the code so the ball moves around the screen. It up to you to decide how it moves. It could:

  • move up or down
  • move up and down
  • move diagonally
  • move randomly

[Color]

๐Ÿ’ป Open the file: color_animation.py

๐Ÿ’ป Try running the file: python color_animation.py. Currently, there is no animation. A green ball just appears against a yellow background on the screen.

๐Ÿ’ป Change the code so the ball changes in color. It up to you to decide how the color changes.

Note, the color is decided with RGB values as opposed to names of colors.

  • line 39: changes the color mode to accept RGB values

[3] Deliverables

โšกโœจ For this lab, you should:

Once you’ve successfully completed the sequence be sure to fill out this Google form.

๐Ÿ’ป Push your work to Github:

  • git status
  • git add file_name.py file_name2.py
  • git status
  • git commit -m “describe your drawing and your process here”

    be sure to customize this message, do not copy and paste this line

  • git push

[4] Extension

๐Ÿ’ป Open the file: extension_animation.py in Atom. It is just an empty file.

๐Ÿ’ป Code a custom animation of your choosing! Here is an example of what you could create: