Professional Documents
Culture Documents
S. RAMAKRISHNAN
XII- VIBRANT
1
CERTIFICATE
2
ACKNOWLEDGEMENT
S. RAMAKRISHNAN
XII-VIBRANT
3
The word Python- isn't it scary? Does it bring the image of
big reptile that we prefer to see either in jungles or zoo? Well, it's
time to change the image. Now on, you'll remember word Python
for its playfulness and pleasant productivity. Confused? Well,
don’t be - because, now on you'll get introduced to a new
programming language namely 'Python, which promises to make
you a big programming fan.
Python programming language was developed by Guido Van
Rossum in February 1991.Python is based on or influenced with
two programming languages:
ABC language, a teaching language created as a replacement
of BASIC, and
Modula-3
Python is an easy-to-learn yet powerful object oriented
programming language. It is a very high level programming
language yet as powerful as many other middle-level not so high-
level languages like C, C++, Java etc.
4
Though Python language came into being in early 1990's, yet
it is competing with ever-popular languages such as C, C++, Java
etc. in popularity index.
Let's see what are these advantages of Python.
Python is compact and very easy to use object oriented language
with very simple syntax rules. It is a very high level language and
thus very-very programmer-friendly.
Python is an interpreted language, not a compiled language. It
makes Python an easy-to-debug language and thus suitable for to
advanced users.
5
For most types of required functionality is available through
various modules of Python standard library¹. For example, for
diverse functionality such as emails, web-pages databases GUI
development, network connections and many more, everything is
available in Python standard library. Thus, it is also called Python
follows "Batteries Included" philosophy.
6
Eight-ball (also spelled 8-ball or eight ball, and sometimes called solids
and stripes, spots and stripes or rarely highs and lows) is a pool billiards
played on a billiard table with six pockets, cue sticks, and sixteen billiard
balls: a cue ball and fifteen object balls. The object balls include seven solid-
colored balls numbered 1 through 7, seven striped balls numbered 9
through 15, and the black 8 ball. After the balls are scattered with a break
shot, a player is assigned either the group of solid or striped balls once they
have legally pocketed a ball from that group. The object of the game is to
legally pocket the 8-ball in a "called" pocket, which can only be done after all
of the balls from a player's assigned group have been cleared from the table.
The game is the most frequently played discipline of pool, and is often
thought of as synonymous with "pool". The game has numerous variations,
mostly regional. It is the second most played professional pool game, after
nine-ball, and for the last several decades ahead of straight pool.
Play online with real money, Play With Friends, Quick Deposit and Money
Withdrawal, Advertisement.
7
import pygame
import sys
import random
pygame.init()
width = 660
height = 360
outerHeight = 400
margin = 30
clock = pygame.time.Clock()
8
colors = [yellow, blue, red, purple, orange, green, brown, black, yellow, blue, red, purple,
orange, green, brown]
balls = []
noBalls = 15
radius = 10
friction = 0.005
# Ball Class
class Ball:
self.x = x + radius
self.y = y + radius
self.color = color
self.angle = angle
self.speed = speed
self.ballNum = ballNum
display.blit(ballNo, (x - 5, y - 5))
else:
if self.ballNum > 9:
display.blit(ballNo, (x - 6, y - 5))
else:
9
display.blit(ballNo, (x - 5, y - 5))
def move(self):
self.speed -= friction
if self.speed <= 0:
self.speed = 0
# Pocket Class
class Pockets:
self.r = margin/2
self.x = x + self.r + 10
self.y = y + self.r + 10
self.color = color
10
# Draws the Pockets on Pygame Window
def draw(self):
def checkPut(self):
global balls
ballsCopy = balls[:]
for i in range(len(balls)):
if balls[i] in ballsCopy:
if balls[i].ballNum == 8:
gameOver()
else:
ballsCopy.remove(balls[i])
balls = ballsCopy[:]
class CueStick:
self.x = x
self.y = y
self.length = length
self.color = color
self.tangent = 0
cueBall.angle = self.tangent
11
cueBall.speed = force
# Checks Collision
return True
else:
return False
def checkCueCollision(cueBall):
for i in range(len(balls)):
if collision(cueBall, balls[i]):
if balls[i].x == cueBall.x:
angleIncline = 2*90
else:
u1 = balls[i].speed
u2 = cueBall.speed
))**2**0.5
12
)))**2)**0.5
angle = tangent + 90
balls[i].x += (balls[i].speed)*sin(radians(angle))
balls[i].y -= (balls[i].speed)*cos(radians(angle))
cueBall.x -= (cueBall.speed)*sin(radians(angle))
cueBall.y += (cueBall.speed)*cos(radians(angle))
def checkCollision():
for i in range(len(balls)):
if collision(balls[i], balls[j]):
if balls[i].x == balls[j].x:
angleIncline = 2*90
else:
u1 = balls[i].speed
u2 = balls[j].speed
e)))** 2)**0.5
e)))**2)**0.5
angle = tangent + 90
13
balls[i].x += (balls[i].speed)*sin(radians(angle))
balls[i].y -= (balls[i].speed)*cos(radians(angle))
balls[j].x -= (balls[j].speed)*sin(radians(angle))
balls[j].y += (balls[j].speed)*cos(radians(angle))
def border():
def score():
for i in range(len(balls)):
def reset():
noBalls = 15
balls = []
s = 70
14
b7 = Ball(s + 6*radius, height/2 - 1*radius, 0, colors[6], 0, 7)
balls.append(b1)
balls.append(b2)
balls.append(b3)
balls.append(b4)
balls.append(b5)
balls.append(b6)
balls.append(b7)
balls.append(b8)
balls.append(b9)
balls.append(b10)
balls.append(b11)
balls.append(b12)
balls.append(b13)
balls.append(b14)
balls.append(b15)
def gameOver():
15
if len(balls) == 0:
else:
while True:
if event.type == pygame.QUIT:
close()
if event.type == pygame.KEYDOWN:
if event.key == pygame.K_q:
close()
if event.key == pygame.K_r:
poolTable()
pygame.display.update()
clock.tick()
def close():
pygame.quit()
sys.exit()
# Main Function
def poolTable():
loop = True
reset()
noPockets = 6
pockets = []
p1 = Pockets(0, 0, black)
16
p3 = Pockets(width - p1.r - margin - 5, 0, black)
pockets.append(p1)
pockets.append(p2)
pockets.append(p3)
pockets.append(p4)
pockets.append(p5)
pockets.append(p6)
start = 0
end = 0
while loop:
if event.type == pygame.QUIT:
close()
if event.type == pygame.KEYDOWN:
if event.key == pygame.K_q:
close()
if event.key == pygame.K_r:
poolTable()
if event.type == pygame.MOUSEBUTTONDOWN:
x, y = pygame.mouse.get_pos()
end = [x ,y]
17
dist = ((start[0] - end[0])**2 + (start[1] - end[1])**2)**0.5
force = dist/10.0
force = 10
cueStick.applyForce(cueBall, force)
display.fill(background)
cueBall.draw(cueBall.x, cueBall.y)
cueBall.move()
cueStick.draw(cueBall.x, cueBall.y)
for i in range(len(balls)):
balls[i].draw(balls[i].x, balls[i].y)
for i in range(len(balls)):
balls[i].move()
checkCollision()
checkCueCollision(cueBall)
border()
for i in range(noPockets):
pockets[i].draw()
for i in range(noPockets):
pockets[i].checkPut()
gameOver()
score()
pygame.display.update()
clock.tick(60)
poolTable()
18
8 Ball Pool is a really famous game and therefore it will be hard to penetrate the
market. However, the success rate of the 8 Ball Pool game and the revenue model is
quite appealing and therefore one can penetrate the market with the perfect product.
Your app should be able to provide the best gaming experience, plus, it should have
new features and functionalities so that the users are drawn towards your app. Just
make sure that you hire the best gaming app development company so that you can
have the perfect 8 Ball Pool app that can penetrate the existing market.
Python