Ping pong in python with source code

Ping pong in python with source code

Introduction

Ping pong is a game based python project made using turtle library. It is the famous ping pong multiplayer game played between two players.

Turtle is an inbuilt module in python that is mostly useful for creating graphics. In this project, we are creating a ping pong game project. The ping pong game has a simple screen with dark background where two sliders are placed at each side. A ball moves from left to right and the slider must touch the ball in order to move the ball towards the another slide.

The slider can be controlled using keyboard keys. The left slider is controlled using w and s keys and right slider uses up and down arrow key. If the player misses to touch the ball using slider another player will gain a score. The score is displayed on the top if the screen. The ball is thrown randomly when the game starts. See the screenshot below.

ping pong

Building the ping pong project

Python programming is used in building this project. We are using turtle library for using graphics. Random library for randomly generated cars on the screen. We must import time to slow down or control the screen. This project has more than three files that are imported in main file. The program can detect the collision with the slider and wall.

We are using object oriented programming in this project. Such as creating classes, and inheriting the sub class from the super class. You can understand about OOP in this project. We further work with functions, control statements, loops and many more. It is an intermediate level project. Download the project and get experienced by yourself.


How to use this project?

  • Download the project and extract the folder.
  • Open the project folder in editor or IDE. (pycharm, anaconda)  
  • Execute the project.
  • Play the game and get a high score.
  • Enjoy and share

Click the download button below to get the so/urce code for this project.