The classic Ping Pong made in Python and totally object oriented the project was just to put my learning about the Object Oriented Programming paradigm in, practice It was a great challenge, mainly in the area of calculations with axes, but it was very satisfactory.
The game was divided into 3 classes: Player, Bot and Game:
A class player has the role of managing as rackets, she controls the height and the movement limit. Through very simple methods it receives events that are triggered through the keyboard and from these events it defines which key was typed and moves a racket according to it, always checking if the position of the racket with this movement will exceed the limits of the edge. This new position is passed through a method as well. Before starting the game two classes of player are instantiated and if the user wishes playing multiplayer, the two instances are passed to the Game class.
The Bot would be an "Artificial Intelligence", but with the minimum amount of intelligence possible. It is a subclass of Player and overrides it dispensing with the need to receive a specific key as a parameter for the racket movement, its operation is very simple if the ball is close to the Bot, it moves the racket towards the ball, otherwise it seems stopped
This is the most important class of the code, being responsible for creating a screen and managing a Pygame library, receiving as parameters two instances for the drawing of the racket on the screen, using methods of the classes above to request the new coordinate of the same. In addition to being responsible for drawing the ball, calculating its collisions with the edge and the rackets *** With each collision the ball gets a little faster ***, it also passes to the racquet classes in which the event was triggered.