Building a screen saver
We will start by building a screen saver for our desktop. The screen saver will consist of several random-colored and random-sized balls bouncing all over the screen at random velocity, as shown in the following screenshot:
Carry out the following steps to create the screen saver:
- Let's create a class to generate balls with random attributes. Accordingly, we define a new class named
RandomBallto achieve this (refer to the
7.01 screensaver.pyPython file, available in the code bundle):
from random import randint class RandomBall: def __init__(self, canvas, scrnwidth, scrnheight): self.canvas = canvas self.xpos ...