PING PoNG GAME
PING PoNG GAME
PING PoNG GAME
UNIVERSITY
Submitted date
Submitted to goppi red
Abstract
Ping pang game is one of the most famous arcade games, simulating table tennis. Each player
controls a paddle in the game by dragging it vertically across the screen’s left or right side.
Players use their paddles to strike back and forth on the ball. Turtle is an inbuilt graphic module
in Python. It uses a panel and pen to depict illustrations. We provide a more interesting and
convenient way for people to play ping-pong game on pc. In this paper, we propose an
Augmented Reality game system (ARPP) for two players on the same pc.
The ping pang game is normally created by using python programming language and a pycharm
to write all the codes. The experiment results show that the proposed game system can work
effectively and provide winner results on the computer devices.
from turtle import Turtle, Screen
# set up screen
screen = Screen()
screen.bgcolor("darkgreen")
screen.title("Pong")
# set up border
border_pen = Turtle(visible=False)
border_pen.speed('fastest')
border_pen.color('white')
border_pen.pensize(3)
border_pen.penup()
border_pen.setposition(-300, -300)
border_pen.pendown()
for _ in range(4):
border_pen.forward(600)
border_pen.left(90)
# set score to 0
score = 0
# Draw score
score_pen = Turtle(visible=False)
score_pen.color("white")
i
score_pen.penup()
score_pen.setposition(-290, 310)
# Draw timer
time_pen = Turtle(visible=False)
time_pen.color("white")
time_pen.penup()
time_pen.setposition(260, 310)
playerspeed = 15
AIplayerspeed = 15
pong.sety(265)
pong.showturtle()
pongspeed = 15
pong_dx, pong_dy = 5, -5
ii
y = player.ycor()
if y > 265:
y = 260
player.sety(y)
screen.update()
def move_down():
player.backward(playerspeed)
y = player.ycor()
if y < -265:
y = -260
player.sety(y)
screen.update()
# keyboard bindings
screen.onkey(move_up, "Up")
screen.onkey(move_down, "Down")
screen.listen()
iii
Declaration
We hereby declare that the work presented in this project is the outcome of the investigation
performed by us under the supervisor of DR.R.GOPI REDDY, Senior Lecturer, for Department
of Electrical & computer Engineering, in wachemo university. We clearly declare that no part
of this project has been submitted else-where for the award of any degree or diploma and is
solely edited to us.
Countersigned Signature
(Solomon) .………………..
(Ashenafi) .………………..
iv
Acknowledgment
First of all we would like to thanks our god for everything. Today we are successful in
completing our Project work with such ease because He gives us the ability, chance and co-
operating supervisor. We would like to thanks our supervisor DR.R.GOPI REDDY for his help
us to made this project successfully and for his valuable advice. Finally we are grateful to our
family who are always with us in every step of our life.
v
TABLE OF CONTENT
keywords25
1.4 Objective
1.5 Relevance
2.1.2
3. METHODOLOGY
CHAPTER FOUR
vi
4. MODELING DESIGN AND SIMULATION
6.1 conclusion
6.2 conclusion
References
Appendix25
vii
LIST OF FIGURES
viii
KEYWORDS
Cpu (The mother board of any electronic device)
osc (oscillator)
Txd()
Rxd
ix
CHAPTER - 1
INTRODUCTION
1.1 Background
Ping pang game is multiplayers game build on turtle module. Where two persons can play this
game. you can simply run the file to play the game by downloading all the files that are
necessary to the game. You need to download music effects also to get good experience with the
game. Ping-pong is a very popular game. People need to play it in some fixed physical locations
and by connecting it with wifi. We provide a more interesting and convenient way for people to
play ping-pong game on pc. In this paper, we propose an Augmented Reality game system
(ARPP) for two players on the same pc where two persons can play this game. you can simply
run the file to play the game by downloading all the files that are necessary to the game. You
need to download music effects also to get good experience with the game.
Pong is one of the most famous arcade games, simulating table tennis. Each player controls a
paddle in the game by dragging it vertically across the screen’s left or right side. Players use their
paddles to strike back and forth on the ball. Turtle is an inbuilt graphic module in Python. It uses
a panel and pen to depict illustrations.
1
1.4 Objective
1.4.1 Main objective
Design of ping pong game with turtle module where two players are played together.
1.4.2 Specific objective
To simulate the design results.
1.5 Relevance
1.6 IMPROVES CONCENTRATIONGoal of the project
Our goal is to minimize man power, to keep room security based on microcontroller, to
indicate the specific department (room) in which fire erupted, to decrease risk of fire,to
create safe working area.
2
CHAPTER - 2
LITERATURE REVIEW
Python was conceived in the late 1980s[40] by Guido van Rossum at Centrum Wiskunde &
Informatica (CWI) in the Netherlands as a successor to ABC programming language, which was
inspired by SETL,[41] capable of exception handling and interfacing with the Amoeba operating
system.[11] Its implementation began in December 1989.[42] Van Rossum shouldered sole
responsibility for the project, as the lead developer, until 12 July 2018, when he announced his
"permanent vacation" from his responsibilities as Python's Benevolent Dictator For Life, a title
the Python community bestowed upon him to reflect his long-term commitment as the project's
chief decision-maker.[43] In January 2019, active Python core developers elected a 5-member
"Steering Council" to lead the project.[44] As of 2021, the current members of this council are
Barry Warsaw, Brett Cannon, Carol Willing, Thomas Wouters, and Pablo Galindo Salgado.[45]
Python 2.0 was released on 16 October 2000, with many major new features, including a cycle-
detecting garbage collector and support for Unicode.[46]
Python 3.0 was released on 3 December 2008. It was a major revision of the language that is not
completely backward-compatible.[47] Many of its major features were backported to Python
2.6.x[48] and 2.7.x version series. Releases of Python 3 include the 2to3 utility, which automates
(at least partially) the translation of Python 2 code to Python 3.[49]
Python 2.7's end-of-life date was initially set at 2015 then postponed to 2020 out of concern that
a large body of existing code could not easily be forward-ported to Python 3.[50][51] No more
security patches or other improvements will be released for it.[52][53] With Python 2's end-of-
life, only Python 3.6.x[54] and later are supported.
Python 3.9.2 and 3.8.8 were expedited[55] as all versions of Python (including 2.7[56]) had
security issues, leading to possible remote code execution[57] and web cache poisoning.
3
2.2 Literature review on pycharm
PyCharm is an IDE developed by JetBrains since 2010. Yes, the same company that developed
IntelliJ, the de-facto default for Java. It costs $89 per year for private people which is pretty
expensive if you just get your feet wet with Python. It’s pretty cheap if you consider that the
editor/IDE is one of the most important tools of a professional software developer[2].
It is used by many Python developers as one can see in the number of StackOverflow questions
(12,455), in the 2019 Jetbrains Survey, and the 2019 StackOverflow survey.
The name "ping-pong" was in wide use before British manufacturer J. Jaques & Son Ltd
trademarked it in 1901. The name "ping-pong" then came to describe the game played using the
rather expensive Jaques's equipment, with other manufacturers calling it table tennis. A similar
situation arose in the United States, where Jaques sold the rights to the "ping-pong" name to
Parker Brothers. Parker Brothers then enforced its trademark for the term in the 1920s, making
the various associations change their names to "table tennis" instead of the more common, but
trademarked, term.[9]
The next major innovation was by James W. Gibb, a British enthusiast of table tennis, who
discovered novelty celluloid balls on a trip to the US in 1901 and found them to be ideal for the
game. This was followed by E.C. Goode who, in 1901, invented the modern version of the racket
by fixing a sheet of pimpled, or stippled, rubber to the wooden blade. Table tennis was growing
in popularity by 1901 to the extent that tournaments were being organized, books being written
on the subject,[7] and an unofficial world championship was held in 1902. In those early days,
the scoring system was the same as in lawn tennis.[10]
Although both a "Table Tennis Association" and a "Ping Pong Association" existed by 1910,[10]
a new Table Tennis Association was founded in 1921, and renamed the English Table Tennis
Association in 1926.[11] The International Table Tennis Federation (ITTF) followed in 1926.[1]
[12] London hosted the first official World Championships in 1926. In 1933, the United States
Table Tennis Association, now called USA Table Tennis, was formed.[1][13]
4
CHAPTER - 3
METHODOLOGY
We use python programming language for designing our game and pycharm in order to write all
the python codes.
For successful completion of this project some steps have been followed to carry out different
tasks. Different literatures were revised relating to this project and data has been collected from
nearby system. Based on the data collected system model have been designed. Finally using
appropriate software, the programming has been developed.
Generally, the steps are described by the following block diagram.
Problem
identification
Surveying
literatures
Data collection on
ping pang game
Design system
model in software
Simulation
5
3.2 SOFTWARE REQUIREMENTS
We have used python programming language for simulation of our project and
pycharm community for writing the code.
Applications of Python
Web development
Python can be used to make web-applications at a rapid rate. There is common-backend
logic that goes into making these frameworks and a number of libraries that can help
integrate protocols such as HTTPS, FTP, SSL etc. and even help in the processing of
JSON, XML, E-Mail and so much more.
Game Development
Python is also used in the development of interactive games. There are libraries such as
PySoy which is a 3D game engine supporting Python 3, PyGame which provides
functionality and a library for game development.
Machine Learning and Artificial Intelligence: are the talks of the town as they yield
the most promising careers for the future. We make the computer learn based on past
6
experiences through the data stored or better yet, create algorithms which makes the
computer learn by itself. The programming language that mostly everyone chooses? It’s
Python.
Desktop GUI: We use Python to program desktop applications. It provides the Tkinter
library that can be used to develop user interfaces. There are some other useful toolkits
such as the wxWidgets, Kivy, PYQT that can be used to create applications on several
platforms.
Web Scraping Applications: Python is a savior when it comes to pull a large amount of
data from websites which can then be helpful in various real-world processes such as
price comparison, job listings, research and development and much more.
Features in Python
Easy to code
Free and Open Source
Object-Oriented Language
GUI Programming Support
High-Level Language
Extensible feature
Python is Portable language
Python is Integrated language
Interpreted Language
Large Standard Library
Dynamically Typed Language
Modules of python
There are several modules in python we have discussed with some of them that we used in the
development of our game.
7
a) Pygame: is a cross-platform set of Python modules designed for writing video games. It
includes computer graphics and sound libraries designed to be used with the Python
programming language.
Pygame uses the Simple DirectMedia Layer (SDL) library, with the intention of allowing
real-time computer game development without the low-level mechanics of the C
programming language and its derivatives. This is based on the assumption that the most
expensive functions inside games can be abstracted from the game logic, making it
possible to use a high-level programming language, such as Python, to structure the
game.
Other features that SDL doesn't have include vector math, collision detection, 2D sprite
scene graph management, MIDI support, camera, pixel-array manipulation,
transformations, filtering, advanced freetype font support, and drawing.
Applications using Pygame can run on Android phones and tablets with the use of
Pygame Subset for Android (pgs4a). Sound, vibration, keyboard, and accelerometer are
supported on Android.
8
3.2.2 Pycharm Community
Features of PyCharm:
9
Pros and Cons of Using PyCharm
PyCharm is a wonderful IDE for Python programmers and application developers. However,
there are some pros and cons of using PyCharm. Let’s see.
Pros
Cons
10
CHAPTER - 4
SYSTEM DESIGN
In this Chapter we are going to Explain about the system Design regarding to how we use
the software to implement and got the final result of our project. In addition, the chapter
elaborates the software stage by stage.
The Python download requires about 25 Mb of disk space; keep it on your machine, in case you
need to re-install Python. When installed, Python requires about an additional 90 Mb of disk
space.
Installing python-3.9.6-amd64.exe.
and move the progress bar towards completion. Soon, a new Python 3.9.6 (64-bit)
Setup pop-up window will appear with a Setup was successfuly message.
11
2. Double-click the icon/file python.exe. A pop-up window with the
title C:\Users\Pattis\AppData\Local\Programs\Python\Python39\python.exe appears, and
inside the window; on the first line is the text Python 3.9.6
To verify the integrity of the installer, use the SHA checksum linked from the Download
page.
Run the installer and follow the wizard steps.
Mind the following options in the installation wizard
64-bit launcher: Adds a launching icon to the Desktop.
Open Folder as Project: Adds an option to the folder context menu that will allow
opening the selected directory as a PyCharm project.
.py: Establishes an association with Python files to open them in PyCharm.
Add launchers dir to the PATH: Allows running this PyCharm instance from the Console
without specifying the path to it.
To run PyCharm, find it in the Windows Start menu or use the desktop shortcut. You can
also run the launcher batch script or executable in the installation directory under bin.
There are very important module/package that are used to develop any game with python.
Pygame
Turtle
Finally After we have downloaded and install all the above softwares Below are the steps
used to design the game:
Step 1) Create two paddles A and B on the left and right side of the screen.
Step 3) Create an event to move the paddle vertically on pressing a certain key.
Step 4) Create the function to update the score after each player misses a collision.
12
4.3 System Architecture
13
CHAPTER - 5
The aim of the project was to implement the design of the ping pang game with python turtle
module.
Case 1 : after we have write all the code correctly then the last step is to run our program when
we run our program it works correctly as shown on the above figure(5.1).
Case 2: when the program runs correctly the the output that is shown on the figure below will be
displayed on the screen. In this case both the players have zero score.
Game field
Ball
Point updater
Left paddle (for player 1) and
The right paddle (for player 2) as shown in figure below. also In our first case fig (5.2)
both the first player and the second player have the same score 0-0
14
fig 5.2 Connection of the system
Case 3
When the game is started both player will press the keyboard we have selected
A- for player 1 to move the paddle to the upper boarder.
F- for player 1 to move the paddle down the boarder.
Up key- for player 2 to move the paddle to the upper boarder.
Down key- for player 2 to move the paddle down the boarder.
15
As we see on the figure below the scores are updated as the ball touch the border by passing the
paddle of the players. The aim of the game is to kick the ball not to touch the border and score on
the other player.
16
CHAPTER - 6
6.1 Conclusion
The design of ping pong game was successfully carried out and tested effectively. The
system did not pose extra-ordinary constraint andno any other components are needed so
everyone can use this game by running on his pc. Finally, the project was challenging
because it needs deep knowledge of python coding. gave an exposure into the practical
application of theoretical knowledge in solving problems associated with design and
construction in most of our world . Likewise, it gave more
6.2 Recommendation
Accomplishing the full task needs time and resource which gives smart and persuasive
output. But the time for the project and sources of information is scarce due to lack of
access. Even if we don’t have anything to support and we don’t have any lab for practice.
Therefore such obstacles should be proved for the coming final project. And if it is
possible in the future the department should supply students particularly for students who
are doing there BSC. With relevant information regarding there project.
17
REFERENCES
18
12. ^ "International Table Tennis Federation Archives". www.ittf.com. ITTF.
Archived from the original on 1 March 2011. Retrieved 29 August 2010.
13. ^ Jump up to:a b c "About USATT". United States Olympic Committee. Archived from
the original on 4 November 2010. Retrieved 6 November 2010.
19
APPENDIX
import turtle as t
import os
# Score varibales
player_a_score = 0
player_b_score = 0
paddle_left = t.Turtle()
paddle_left.speed(0)
paddle_left.shape('square')
paddle_left.color('green')
paddle_left.shapesize(stretch_wid=5, stretch_len=1)
paddle_left.penup()
paddle_left.goto(-350, 0)
paddle_right = t.Turtle()
paddle_right.speed(0)
paddle_right.shape('square')
20
paddle_right.shapesize(stretch_wid=5, stretch_len=1)
paddle_right.color('red')
paddle_right.penup()
paddle_right.goto(350, 0)
ball = t.Turtle()
ball.speed(0)
ball.shape('circle')
ball.color('blue')
ball.penup()
ball.goto(0, 0)
ball_dx = 1.5 # Setting up the pixels for the ball movement.
ball_dy = 1.5
pen = t.Turtle()
pen.speed(0)
pen.color('skyblue')
pen.penup()
pen.hideturtle()
pen.goto(0, 300)
pen.write("Player A=0 Player B=0 ",
align="center", font=('Monaco', 24, "normal"))
21
def paddle_left_up():
y = paddle_left.ycor()
y = y + 15
paddle_left.sety(y)
def paddle_left_down():
y = paddle_left.ycor()
y = y - 20
paddle_left.sety(y)
def paddle_right_up():
y = paddle_right.ycor()
y = y + 20
paddle_right.sety(y)
def paddle_right_down():
y = paddle_right.ycor()
y = y - 20
paddle_right.sety(y)
22
# Keyboard binding
win.listen()
win.onkeypress(paddle_left_up, "a")
win.onkeypress(paddle_left_down, "z")
win.onkeypress(paddle_right_up, "Up")
win.onkeypress(paddle_right_down, "Down")
while True:
win.update() # This methods is mandatory to run any game
23
pen.clear()
pen.write("Player A: {} Player B: {}
".format(player_a_score, player_b_score),
align="center", font=('Monaco', 24, "normal"))
os.system("afplay wallhit.wav&")
24