You are on page 1of 31

MEET OUR TEAM

Harsh Jha
• XI - Science
• Roll No. - 32

Mihir Patel
• XI - Science
• Roll No. - 39
TABLE OF CONTENT

01 09
ACKNOWLEDGEMENT TESTING
expressing my special thanks of gratitude Testing the Software.
to my teacher as well as our principal. (PONG GAME)
[Page no. 1] [Page no. 26]

10
BIBLIOGRAPHY

02
INTRODUCTION A list Sources that has been
Introducing Our Software used in preparing the Software.
(PONG GAME) [Page no. 27]
[Page no. 3]

03
CONCEPT
Concept of software used for
developing software.
[Page no. 4]

04
ABOUT
Breif Introduction to python And Mysql
programing Languages.
[Page no. 5 & 11]

05
INSTALLATTION
Procedure for the Installation of
Software (PONG GAME)
[Page no. 10 & 16]

06
REQUIREMNTS
Hardware and Software Requirements
for the Software.
[Page no. 17]

07
SOURCE CODE
Source code of the Software.
(PONG GAME)
[Page no. 18]

08
OUTPUT
Output of the Software.
(PONG GAME)
[Page no. 26]
Acknowledgement
While I was preparing this project file, Various
Information that I found helped me and I am glad that I
was able to complete this project and understand many
things. Through preparation of this Informatics Practices
Project was an Immense learning Experience and I
inculcated many personal qualities during this process
like responsibility, punctuality, confidence and many
more.

Primarily I would like to express my gratitude to our


principal ma’am “𝐌𝐫𝐬. 𝐁𝐈𝐍𝐘 𝐏𝐀𝐔𝐋” who gave me the
golden opportunity to do the wonderful project and We
are also grateful to 𝐒𝐡𝐫𝐢 𝐋.𝐆 𝐇𝐚𝐫𝐢𝐚 𝐌𝐮𝐥𝐭𝐢𝐩𝐮𝐫𝐩𝐨𝐬𝐞 𝐒𝐜𝐡𝐨𝐨𝐥 for
provision of expertise and technical support in the
implementation.

We are very thankful to our Informatics Practices


Teacher "𝐌𝐫. 𝐍𝐚𝐮𝐬𝐡𝐚𝐝 𝐊𝐡𝐚𝐧" for their logistical support and
for providing necessary guidance in execution of our
project.

Finally, I'd like to express my gratitude to my classmates.


who have assisted me in the completion of this project,
for which I am very grateful.

01
PONG
GAME
02
INTRODUCTION
𝐂𝐫𝐞𝐚𝐭𝐞 𝐩𝐨𝐧𝐠 𝐠𝐚𝐦𝐞 𝐮𝐬𝐢𝐧𝐠 𝐏𝐲𝐭𝐡𝐨𝐧 – 𝐓𝐮𝐫𝐭𝐥𝐞

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.

Page no. 03
CONCEPT OF
SOFTWARE USED FOR
DEVELOPING SOFTWARE
we have used Python and the Turtle
library to create a simple Pong game.
The game is similar to an actual game
of table tennis, where two players will
use keys to move two paddles up and
down on either side of the game screen.
Users will use these to deflect a ball
and prevent it from hitting the edge of
the screen on their side. The game is
lots of fun to play, and its’ simple
code makes it the perfect project for
kids or those who are new to Python to
create. Regardless of your proficiency
with Python, this project is a great
way to test your knowledge and learn
more about making a functional program.

Page no. 04
Introduction to Python
Python is an interpreted high-level
general-purpose programming
language. Its design philosophy
emphasizes code readability with
its use of significant indentation.
Its language constructs as well as its
object-oriented approach aim to
help programmers write clear,
logical code for small and large-
scale projects.

Page no. 05
History of Python
Guido van Rossum began
working on Python in the late
1980s, as a successor to the
ABC programming language,
and first released it in 1991 as
Python 0.9.0. Guido van Rossum

Python 2.0 was released in 2000 and introduced new


features, such as list comprehensions and a cycle-
detecting garbage collection system (in addition to
reference counting). Python 3.0 was released in 2008
and was a major revision of the language that is not
completely backward-compatible. Python 2 was
discontinued with version 2.7.18 in 2020.

Python consistently ranks as one of the most popular


programming languages.

Page no. 06
Naming of Python :
Python's name is derived from the
British comedy group Monty Python,
whom Python creator Guido van
Rossum enjoyed while developing the
language. Monty Python references p
dy gro u
Come
appear frequently in Python code and y Py th o n (19 69)
Mo nt
culture; for example, the metasyntactic
variables often used in Python literature are spam and eggs instead
of the traditional foo and bar. The official Python documentation
also contains various references to Monty Python routines.

Python Libraries :
Python's large standard library, commonly cited as one of its greatest
strengths, provides tools suited to many tasks.
For Internet-facing applications, many standard formats and protocols
such as MIME and HTTP are supported. It includes modules for
creating graphical user interfaces, connecting to relational databases,
generating pseudorandom numbers, arithmetic with arbitrary-
precision decimals, manipulating regular expressions, and unit testing.
Some of the Popular python Libraries are :-
TensorFlow, Scikit-Learn, Numpy, Keras, PyTorch, LightGBM,
Eli5, SciPy.
Page no. 07
What is Python used for?
AI and machine learning
Data analytics
Data visualisation
Programming applications
Web development
Game development
Language developmentFinance
Search engine optimisation (SEO)
Natural language processing (NLP)

What can python do?


Python can be used on a server to create web applications.

Python can be used alongside software to create workflows.

Python can connect to database systems. It can also read and

modify files.

Python can be used to handle big data and perform complex

mathematics.

Python can be used for rapid prototyping, or for production-ready

software development.

Page no. 08
Why Python?
There are Some of the Reasons Listed below
that why Python is mostly preferred :-

Python works on different platforms


(Windows, Mac, Linux, Raspberry Pi, etc).
Python has a simple syntax similar to the
English language.
Python has syntax that allows developers
to write programs with fewer lines than
some other programming languages.
Python runs on an interpreter system,
meaning that code can be executed as
soon as it is written. This means that
prototyping can be very quick.
Python can be treated in a procedural
way, an object-oriented way or a
functional way.

Page no. 09
Installation Procedure Of
Python
1] Select Version of Python to Install
Python has various versions available with differences between the syntax

and working of different versions of the language. We need to choose the version which
we want to use or need. There are different versions of Python 2 and Python 3 available.

2] Download Python Executable Installer


On the web browser, in the official site of python (www.python.org), move
to the Download for Windows section. All the available versions of Python will be listed.
Select the version required by you and click on Download. Let suppose, we chose the
Python 3.9.1 version.

3] Run Executable Installer


We downloaded the Python 3.9.1 Windows 64 bit installer.Run the installer. Make sure to
select both the checkboxes at the bottom and then click Install New.

4] Verify Python is installed on Windows


To ensure if Python is succesfully installed on your system. Follow the given steps −
Open the command prompt.
Type ‘python’ and press enter.
The version of the python which you have installed will be displayed if the python is
successfully installed
on your windows.

5] Verify Pip was installed


Pip is a powerful package management system for Python software packages. Thus, make
sure that you
have it installed.
To verify if pip was installed, follow the given steps −
Open the command prompt.
Enter pip –V to check if pip was installed.
The following output appears if pip is installed successfully.

Page no. 10
Introduction to MySQL
MySQL is an open-source relational database
management system (RDBMS). Its name is a
combination of "My", the name of co-founder
Michael Widenius's daughter, and "SQL", the
abbreviation for Structured Query Language. A
relational database organizes data into one or
more data tables in which data types may be
related to each other; these relations help
structure the data. SQL is a language
programmers use to create, modify and extract
data from the relational database, as well as
control user access to the database. In addition to
relational databases and SQL, an RDBMS like
MySQL works with an operating system to
implement a relational database in a computer's
storage system, manages users, allows for network
access and facilitates testing database integrity and
creation of backups.

Page no. 11
History of MySQL
MySQL was created by a Swedish
company, MySQL AB, founded by
Swedes David Axmark, Allan Larsson
and Finland Swede Michael "Monty"
Widenius. Original development of
MySQL by Widenius and Axmark
began in 1994. The first version of
David Axmark and Michael "Monty" Widenius
MySQL appeared on 23 May 1995.

It was initially created for personal usage from mSQL based on


the low-level language ISAM, which the creators considered too
slow and inflexible. They created a new SQL interface, while
keeping the same API as mSQL. By keeping the API consistent
with the mSQL system, many developers were able to use
MySQL instead of the (proprietarily licensed) mSQL
antecedent.
In January 2010, before Oracle's acquisition of MySQL AB,
Monty Widenius started a GPL-only fork, MariaDB. MariaDB
is based on the same code base as MySQL server 5.5 and aims to
maintain compatibility with Oracle-provided versions.

Page no. 12
Features of MySQL
MySQL is offered under two different editions: the open
source MySQL Community Server and the proprietary
Enterprise Server. MySQL Enterprise Server is differentiated
by a series of proprietary extensions which install as server
plugins, but otherwise shares the version numbering system
and is built from the same code base.

MySQL is easy to use :


Though MySQL's relational nature and the ensuing rigid storage
structures might seem restrictive, the tabular paradigm is perhaps the most
intuitive, and ultimately allows for greater usability. In fact, MySQL makes
many concessions to supporting the widest possible variety of data
structures, from the standard but rich logical, numeric, alphanumeric, date,
and time types, to more advanced JSON or geospatial data. Beyond mere
data types and an expansive built-in feature set, the MySQL ecosystem
also includes a variety of tools, easing everything from server management
to reporting and data analysis.

MySQL is open-source :
Any individual or enterprise may freely use, modify, publish, and expand on
Oracle's open-source MySQL code base. The software is released under
the GNU General Public License (GPL). For MySQL code needing to be
integrated or included in a commercial
application (or if open-source software is not a priority), enterprises can
purchase a commercially licensed version from Oracle.

Page no. 13
MySQL is widely compatible :
Though often associated with internet applications or web services, MySQL
was designed to be extensively compatible with other technologies and
architectures. The RDBMS runs on all major computing platforms, including
Unix-based operating systems, such as the myriad Linux distributions or
Mac OS, and Windows.
MySQL's client-server architecture means it can support a variety of
backends, as well as different programming interfaces. Data can be directly
migrated from MySQL to its forks (e.g. MariaDB), as well as most other
RDBMSS thanks to architectural and language similarities.

Established Oracle and third-party migration tools further allow MySQL


to move data to and from a vast set of general storage systems, whether
these are designed to be on-premises or cloud-based. MySQL can be
deployed in virtualized environments, distributed or centralized, and
even exists as portable standalone libraries for learning purposes, testing,
or small applications.
MySQL's wide compatibility with all these other systems and software
makes it a particularly practical choice of RDBMS in most situations.

MySQL can run on very modest hardwareand puts very little strain on system
resources; many small users serve up information to their organizations by
running MySQL on modest desktop systems. The speed with which it can
retrieve information has made it a longstanding favorite of web administrators.

MySQL can run on very modest hardwareand puts very little strain on system
resources; many small users serve up information to their organizations by
running MySQL on modest desktop systems. The speed with which it can
retrieve information has made it a longstanding favorite of web administrators.

Page no. 14
MySQL databases are relational :
The primary factor differentiating relational databases from other digital
storage lies in how data is organized at a high level. Databases like
MySQL contain records in multiple, separate, and highly codified
tables, as opposed to a single all-encompassing repository, or
collections of semi or unstructured documents.
This allows RDBMSS to better optimize actions like data retrieval,
updating information, or more complex actions like aggregations. A
logical model is defined over all of the contents of the database,
describing for example the values allowed in individual columns,
characteristics of tables and views, or how indices from two tables are
related.
Relational models have remained popular for several reasons. They
empower users with intuitive, declarative programming languages -
essentially telling the database what result is wanted in language akin
to, or at least comprehensible as, written english, instead of
meticulously coding up each step of the procedure leading to that
result. This moves a lot of the work into the RDBMS and SQL engines,
better enforcing logical rules and saving valuable resources and
manpower.

Security And Scalability :


A privilege and password system that is very flexible and secure, and
that enables host-based verification Password security by encryption
of all password traffic when you connect to a server.
Support for large databases. We use MySQL Server with databases
that contain 50 million records. We also know of users who use
MySQL Server with 200,000 tables and about 5,000,000,000 rows.

Page no. 15
Installation Procedure Of
MySQL

The process for installing


MySQL from a ZIP Archive
package is as follows:
1. Extract the main archive to the
desired install directory.
2. Create an option file.
3. Choose a MySQL server type.
4. Initialize MySQL.
5. Start the MySQL server.
6. Secure the default user accounts.

Page no. 16
Hardware &
Software
Requirements
1] Operating system :
Linux- Ubuntu 16.04 to 17.10,
or Windows 7 to 11

RAM (4GB preferable)

2] You have to install Python


3.9/3.10 and related packages,
pleasefollow the installation
instructions given above.

3] You need to have


x8664-bit CPU,with 5GB
free diskspace.

Page no. 17
SOURCE CODE
import pygame
import sys
import random
from math import *

pygame.init()

width = 600
height = 400
display = pygame.display.set_mode((width, height))
pygame.display.set_caption("Pong!")
clock = pygame.time.Clock()

background = (27, 38, 49)


white = (236, 240, 241)
red = (203, 67, 53)
blue = (52, 152, 219)
yellow = (244, 208, 63)

top = white
bottom = white
left = white
right = white

margin = 4

scoreLeft = 0
scoreRight = 0
maxScore = 20

Page no. 18
font = pygame.font.SysFont("Small Fonts", 30)
largeFont = pygame.font.SysFont("Small Fonts", 60)

# Draw the Boundary of Board


def boundary():
global top, bottom, left, right
pygame.draw.rect(display, left, (0, 0, margin, height))
pygame.draw.rect(display, top, (0, 0, width, margin))
pygame.draw.rect(display, right, (width-margin, 0, margin, height))
pygame.draw.rect(display, bottom, (0, height - margin, width,
margin))

l = 25

pygame.draw.rect(display, white, (width/2-margin/2, 10, margin, l))


pygame.draw.rect(display, white, (width/2-margin/2, 60, margin, l))
pygame.draw.rect(display, white, (width/2-margin/2, 110, margin, l))
pygame.draw.rect(display, white, (width/2-margin/2, 160, margin, l))
pygame.draw.rect(display, white, (width/2-margin/2, 210, margin, l))
pygame.draw.rect(display, white, (width/2-margin/2, 260, margin, l))
pygame.draw.rect(display, white, (width/2-margin/2, 310, margin, l))
pygame.draw.rect(display, white, (width/2-margin/2, 360, margin, l))

# Paddle Class
class Paddle:
def __init__(self, position):
self.w = 10
self.h = self.w*8
self.paddleSpeed = 6

if position == -1:
self.x = 1.5*margin
else:
self.x = width - 1.5*margin - self.w

self.y = height/2 - self.h/2

Page no. 19
# Show the Paddle
def show(self):
pygame.draw.rect(display, white, (self.x, self.y,
self.w, self.h))

# Move the Paddle


def move(self, ydir):
self.y += self.paddleSpeed*ydir
if self.y < 0:
self.y -= self.paddleSpeed*ydir
elif self.y + self.h> height:
self.y -= self.paddleSpeed*ydir

leftPaddle = Paddle(-1)
rightPaddle = Paddle(1)

# Ball Class
class Ball:
def __init__(self, color):
self.r = 20
self.x = width/2 - self.r/2
self.y = height/2 -self.r/2
self.color = color
self.angle = random.randint(-75, 75)
if random.randint(0, 1):
self.angle += 180

self.speed = 8

# Show the Ball


def show(self):
pygame.draw.ellipse(display, self.color, (self.x,
self.y, self.r, self.r))

Page no. 20
# Move the Ball
def move(self):
global scoreLeft, scoreRight
self.x += self.speed*cos(radians(self.angle))
self.y += self.speed*sin(radians(self.angle))
if self.x + self.r > width - margin:
scoreLeft += 1
self.angle = 180 - self.angle
if self.x < margin:
scoreRight += 1
self.angle = 180 - self.angle
if self.y < margin:
self.angle = - self.angle
if self.y + self.r >=height - margin:
self.angle = - self.angle

# Check and Reflect the Ball when it hits the padddle


def checkForPaddle(self):
if self.x < width/2:
if leftPaddle.x < self.x < leftPaddle.x +
leftPaddle.w:
if leftPaddle.y < self.y < leftPaddle.y + 10 or
leftPaddle.y < self.y + self.r< leftPaddle.y + 10:
self.angle = -45
if leftPaddle.y + 10 < self.y < leftPaddle.y +
20 or leftPaddle.y + 10 < self.y + self.r< leftPaddle.y + 20:
self.angle = -30
if leftPaddle.y + 20 < self.y < leftPaddle.y +
30 or leftPaddle.y + 20 < self.y + self.r< leftPaddle.y + 30:
self.angle = -15
if leftPaddle.y + 30 < self.y < leftPaddle.y +
40 or leftPaddle.y + 30 < self.y + self.r< leftPaddle.y + 40:
self.angle = -10
if leftPaddle.y + 40 < self.y < leftPaddle.y +
50 or leftPaddle.y + 40 < self.y + self.r< leftPaddle.y + 50:
self.angle = 10

Page no. 21
if leftPaddle.y + 50 < self.y < leftPaddle.y + 60
or leftPaddle.y + 50 < self.y + self.r< leftPaddle.y + 60:
self.angle = 15
if leftPaddle.y + 60 < self.y < leftPaddle.y + 70
or leftPaddle.y + 60 < self.y + self.r< leftPaddle.y + 70:
self.angle = 30
if leftPaddle.y + 70 < self.y < leftPaddle.y + 80
or leftPaddle.y + 70 < self.y + self.r< leftPaddle.y + 80:
self.angle = 45
else:
if rightPaddle.x + rightPaddle.w > self.x + self.r >
rightPaddle.x:
if rightPaddle.y < self.y < leftPaddle.y + 10 or
leftPaddle.y < self.y + self.r< leftPaddle.y + 10:
self.angle = -135
if rightPaddle.y + 10 < self.y < rightPaddle.y +
20 or rightPaddle.y + 10 < self.y + self.r< rightPaddle.y + 20:
self.angle = -150
if rightPaddle.y + 20 < self.y < rightPaddle.y +
30 or rightPaddle.y + 20 < self.y + self.r< rightPaddle.y + 30:
self.angle = -165
if rightPaddle.y + 30 < self.y < rightPaddle.y +
40 or rightPaddle.y + 30 < self.y + self.r< rightPaddle.y + 40:
self.angle = 170
if rightPaddle.y + 40 < self.y < rightPaddle.y +
50 or rightPaddle.y + 40 < self.y + self.r< rightPaddle.y + 50:
self.angle = 190
if rightPaddle.y + 50 < self.y < rightPaddle.y +
60 or rightPaddle.y + 50 < self.y + self.r< rightPaddle.y + 60:
self.angle = 165
if rightPaddle.y + 60 < self.y < rightPaddle.y +
70 or rightPaddle.y + 60 < self.y + self.r< rightPaddle.y + 70:
self.angle = 150
if rightPaddle.y + 70 < self.y < rightPaddle.y +
80 or rightPaddle.y + 70 < self.y + self.r< rightPaddle.y + 80:
self.angle = 135

Page no. 22
# Show the Score
def showScore():
leftScoreText = font.render("Score : " + str(scoreLeft),
True, red)
rightScoreText = font.render("Score : " + str(scoreRight),
True, blue)

display.blit(leftScoreText, (3*margin, 3*margin))


display.blit(rightScoreText, (width/2 + 3*margin,
3*margin))

# Game Over
def gameOver():
if scoreLeft == maxScore or scoreRight == maxScore:
while True:
for event in pygame.event.get():
if event.type == pygame.QUIT:
close()
if event.type == pygame.KEYDOWN:
if event.key == pygame.K_q:
close()
if event.key == pygame.K_r:
reset()
if scoreLeft == maxScore:
playerWins = largeFont.render("Left Player
Wins!", True, red)
elif scoreRight == maxScore:
playerWins = largeFont.render("Right Player
Wins!", True, blue)

display.blit(playerWins, (width/2 - 100,


height/2))
pygame.display.update()

Page no. 23
def reset():
global scoreLeft, scoreRight
scoreLeft = 0
scoreRight = 0
board()

def close():
pygame.quit()
sys.exit()

def board():
loop = True
leftChange = 0
rightChange = 0
ball = Ball(yellow)

while loop:
for event in pygame.event.get():
if event.type == pygame.QUIT:
close()
if event.type == pygame.KEYDOWN:
if event.key == pygame.K_q:
close()
if event.key == pygame.K_SPACE or event.key ==
pygame.K_p:
Pause()
if event.key == pygame.K_r:
reset()
if event.key == pygame.K_w:
leftChange = -1
if event.key == pygame.K_s:
leftChange = 1
if event.key == pygame.K_UP:
rightChange = -1
if event.key == pygame.K_DOWN:
rightChange = 1
if event.type == pygame.KEYUP:
leftChange = 0
rightChange = 0

Page no. 24
leftPaddle.move(leftChange)
rightPaddle.move(rightChange)
ball.move()
ball.checkForPaddle()

display.fill(background)
showScore()

ball.show()
leftPaddle.show()
rightPaddle.show()

boundary()

gameOver()

pygame.display.update()
clock.tick(60)

board()

Page no. 25
Output & Testing

Page no. 26
BIBLIOGRAPHY
Our Source for this Project was
𝐒𝐔𝐌𝐈𝐓𝐀 𝐀𝐑𝐎𝐑𝐀'𝐒 Book of
𝗜𝗡𝗙𝗢𝗥𝗠𝗔𝗧𝗜𝗖𝗦
𝗣𝗥𝗔𝗖𝗧𝗜𝗖𝗘𝗦.
Also with the Assistance of Our
I.P Sir "𝐌𝐑. 𝐍𝐀𝐔𝐒𝐇𝐀𝐃 𝐊𝐇𝐀𝐍"
We have also taken help from several websites.

Source Code Projects

Projects By Medium

Page no. 27

You might also like