Ping Pong - Bonus
This solution is too big to print directly in the book, so can be found over on the github repository. Here is a short link to it: https://rb.gy/p951y
This solution introduces some additional features compared to the previous code. Here's how it works:
- The code starts by importing the necessary modules: pygame, sys, math, and random. The pygame.init() function is called to initialise the pygame library.
- The code defines two classes: StaticColour and ChangingColour. These classes represent different types of colours that can be used in the game. StaticColour stores a fixed colour value, while ChangingColour can cycle through a list of colours. The ChangingColour class uses the pygame.time.set_timer() function to trigger a custom ...