This is a simple Ping Pong game created using Python and Turtle graphics library.
- Make sure you have Python installed on your system. You can download it from here.
- Clone this repository to your local machine or download the ZIP file and extract it.
- Open a terminal or command prompt.
- Navigate to the directory where the game files are located.
- Run the following command to start the game:
python main.py
- Use the following controls to play the game:
- Right Paddle: Up and Down arrow keys
- Left Paddle: W (up) and S (down) keys
- Try to hit the ball with your paddle to keep the game going. If the ball passes your paddle, your opponent gets a point.
- Python 3.x
- Turtle graphics library (usually comes pre-installed with Python)
This document provides an overview of the methods available in the Python files ball.py
, scoreboard.py
, and paddle.py
, which are used in the Ping Pong game.
- Initializes a new instance of the
Ball
class. - Sets up the attributes of the ball such as color, shape, initial movement speed, and direction.
- Moves the ball by updating its position based on its current x and y coordinates and the movement increments (
x_move
andy_move
).
- Inverts the direction of the ball's vertical movement (
y_move
) when it hits the top or bottom border of the screen.
- Inverts the direction of the ball's horizontal movement (
x_move
) when it collides with a paddle. - Also decreases the movement speed of the ball.
- Resets the position of the ball to the center of the screen.
- Resets the movement speed and adjusts the direction of the ball horizontally.
- Initializes a new instance of the
Scoreboard
class. - Sets up attributes such as color, position, and initial scores for both players.
- Clears the current scoreboard display.
- Writes the updated scores for both players on the screen.
- Increases the left player's score by 1.
- Updates the scoreboard display accordingly.
- Increases the right player's score by 1.
- Updates the scoreboard display accordingly.
- Initializes a new instance of the
Paddle
class. - Sets up attributes such as shape, color, size, and position of the paddle.
- Moves the paddle upwards by adjusting its y-coordinate upwards.
- Moves the paddle downwards by adjusting its y-coordinate downwards.