0% found this document useful (0 votes)
344 views

Class 12 CBSE Boards Computer Project File

This document is a project report submitted by Aviral Dwivedi for their Computer Science class. The project involves creating 4 games - Tic Tac Toe, Snake and Apple, Hangman, and Tetris - using Python. The report includes an acknowledgments section, topics covered, hardware and software requirements, a user manual, program codes, system and application flowcharts, outputs, limitations, and bibliography.

Uploaded by

Aviral Dwivedi
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
344 views

Class 12 CBSE Boards Computer Project File

This document is a project report submitted by Aviral Dwivedi for their Computer Science class. The project involves creating 4 games - Tic Tac Toe, Snake and Apple, Hangman, and Tetris - using Python. The report includes an acknowledgments section, topics covered, hardware and software requirements, a user manual, program codes, system and application flowcharts, outputs, limitations, and bibliography.

Uploaded by

Aviral Dwivedi
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 67

MONTFORT INTER COLLEGE

SESSION: 2021-2022

COMPUTER SCIENCE
PROJECT REPORT FILE
TOPIC: GAMES

SUBMITTED BY
AVIRAL DWIVEDI CLASS 12-A
ROLL NO 23680726
Sno Topic Page No.
1 Acknowledgement 3
2 Topics 4
3 Hardware Requirements 6
3 Software Requirements 7
4 User Mannual 8
5 Program Codes 13
6 System Flowcharts 49
7 Application Flowcharts 51
8 Outputs 60
9 Limitations 65
10 Bibliography 66
Firstly, I want to express my heartfelt gratitude
towards our computer teacher Mrs. Rumana
Ahmad for giving such a nice topic for project.
Secondly, I want to thank our Principal Brother
Joy Thomas for giving such a tallented and
excellent teacher.
Lastly, I want to thank my parents who helped
me a lot by arranging all the resources for the
making of this project.
The topic chosen by me is GAMES in which I have
created 4 games as following
❖ Tic Tac Toe
❖ Snake and Apple
❖ Hangman
❖ Tetris
The software will run through cmd and the module
used for linking is “import OS” choices for the
games to be played will be given through the menu
driven program. This menu driven program is
created through python IDLE. Simple interface and
easy to understand concept attract the player or
the user of the software.

User will have 4 choices of games as per the list and


last choice as EXIT which will break the program
otherwise, it will keep asking for the next desired
choice for input after completion of every game.
The game has no level and it will only end when the user
either win the match or loses it. Two of the games have
graphics creating a point of interest for the user.
Graphical Games are created using the Pygame
module. This is a module which we have to download for
its usage.

Tetris and snake game is graphical based and the other


two tic tac toe and Hagman are totally based on the
interface created using simple and effective codes and
their output creates a game.
A completely working pc

500 GB HDD
Storage

2 GB graphic
card

Minimum 2 GB RAM
Python IDLE or VS Code
should be installed

Pygame module should be


installed properly
User Manual
(Best guidance to use the software)

1. Insertion of the disk


Take the software disk and ensure that there is no dust
on the surfaces if observed should be cleaned
preferably by a microfibre cloth to avoid any type of
scratches. Now carefully insert the disk in the drive.

2. Software Introduction
The software of games is saved with the name “menu”
which is .py extension file that will open in association
with Command Prompt [CMD].
There are some contents as well named on the names
of games created that is Hangman, snake game, Tic tac
Toe and Tetris. These are resources used in the main
coding of the software and are the components of
graphic games.

select menu.py extension file to open software.


The software opens directly with the display of choices
in the order as follows
➢ Tic Tac Toe
➢ Snake Game
➢ Hangman
➢ Tetris
➢ Exit
Suppose if you don’t know about any particular game or
even any so a one-line description is also provided with
every choice. You can select anyone of them at a time
and can enjoy the game.

3. Game Guide
Now below are the full instructions to play every game
You can follow them to succeed the game.
• Tic tac toe
In this game a tic tac toe table is created using 9
positions and you can tell where the ‘X’ or ‘0’ has to
be placed as it is a two-player game so you can’t
play it alone and you require a partner.
And as soon as the sequence of three continuous
characters either ‘X’ or ‘0’ forms game is over and
player with the sequence forming character wins.
Sequence ca be latitudinal, longitudinal or even
diagonal so play it accordingly.
• Snake Game
In this game there is a snake moving and you have
to feed the apple as food to the snake this will
increase the length of the snake. As you eat an
apple the snake will increase 1 block as it is a
graphical game and also contains sound effects so
you will require good quality speakers and a
graphic card of minimum 2 GB for better
experience.
The movement of the snake is guided by the arrow
keys press upper arrow to move forward down
arrow to move downwards in the same way left
arrow for left turn and right arrow for right
turn.
There is a caution also as it is an endless game so
game overs only when the body of snake gets hit by
snake’s head so play carefully and the longest
length is the high score of your game play.
• Hangman
This a game which is not common at all and a game
which may be confusing but once you read the
instructions you will surely gain success.
So, in this game there is a list of random words the
software will choose a word at a random and you
have to guess its spelling and as you guess the
correct spelling you will win at the end of spelling.
If the spelling guessed by you keeps on going
incorrect some portion of the man is drawn by the
program and the image of is a hanging man which
you have to prevent by guessing the correct
spelling.
As the spelling entered is correct your man gets
prevented otherwise, he hangs and you lose the
game.
• Tetris
Tetris is a very old game and very easy to play.
There are some colourful blocks which will be
coming down in various shapes you have to set them
in the way that they form a full line sequence and
gets vanished in this way the game continues and
the game ends as there is no row left for the block
to come down.
The game also contains sound so you need good
quality speakers for the best experience.
4. EXIT
If you don’t like any game or have completed all of them
you can exit the program/software by the exit option
which directly breaks the program and prevents next
choice asking.
CODES
Menu Page
import os

print("=================================
======================================
=HELLO EVERYONE
!!=====================================
======================================
===")
print(""

"")
print(" I AM A
GAMING SOFTWARE CREATED BY AVIRAL
DWIVEDI ")
print("
************************************************")
print("""

""")
print ("BELOW ARE SOME EXCITING GAMES
PLEASE SELECT A CHOICE AS PER YOUR
INTEREST :")
print(""

"")
print("1. TIC TAC TOE GAME [COMMONLY CALLED
'X' AND '0' GAME]")
print("2. SNAKE GAME [A GAME WITH MOVING
SNAKE CONTROLLED BY USER AND EARNS A
POINT WHEN FEEDS AN APPLE]")
print("3. HANGMAN [A GAME OF SPELLINGS
THE MAN HANGS AS THE SPELLING GOES
WRONG]")
print("4. TETRIS [A BEAUTIFUL AND
COLOURFUL BLOCK PUZZLE]")
print("5. EXIT ")

print("""

""")
while True:
choice=input("Enter` Your Choice as per the number
listed above against each game :")
if choice == "1":
os.system("python tic/tic.py")
if choice == "2":
os.system("cd snakegame && python main.py &&
cd ..")
if choice == "3":
os.system("python Hangman/hangman.py")
if choice == "4":
os.system("python Tetris/tetris.py")
if choice == "5":
break
exit()
Tic Tac Toe
#tic tac toe

"""
tic tac toe board
[
[x, -, -],
[-, -, -],
[-, -, -]
]
user_input -> something 1-9
if they enter anything else: tell them too go again
check if the user_input is already taken
add it to the board
check if user won: checking rows, columns and
diagonals
toggle between users upon succesful moves
"""
board = [
["-", "-", "-"],
["-", "-", "-"],
["-", "-", "-"]
]

user = True # when true it refers to x, otherwise o


turns = 0

def print_board(board):
for row in board:
for slot in row:
print(f"{slot} ", end="")
print()

def quit(user_input):
if user_input.lower() == "q":
print("Thanks for playing")
return True
else: return False

def check_input(user_input):
# check if its a number
if not isnum(user_input): return False
user_input = int(user_input)
# check if its 1 - 9
if not bounds(user_input): return False
return True

def isnum(user_input):
if not user_input.isnumeric():
print("This is not a valid number")
return False
else: return True

def bounds(user_input):
if user_input > 9 or user_input < 1:
print("This is number is out of bounds")
return False
else: return True

def istaken(coords, board):


row = coords[0]
col = coords[1]
if board[row][col] != "-":
print("This position is already taken.")
return True
else: return False

def coordinates(user_input):
row = int(user_input / 3)
col = user_input
if col > 2: col = int(col % 3)
return (row,col)
def add_to_board(coords, board, active_user):
row = coords[0]
col = coords[1]

board[row][col] = active_user

def current_user(user):
if user: return "x"
else: return "o"

def iswin(user, board):


if check_row(user, board): return True
if check_col(user, board): return True
if check_diag(user, board): return True
return False

def check_row(user, board):


for row in board:
complete_row = True
for slot in row:
if slot != user:
complete_row = False
break
if complete_row: return True
return False
def check_col(user, board):
for col in range(3):
complete_col = True
for row in range(3):
if board[row][col] != user:
complete_col = False
break
if complete_col: return True
return False

def check_diag(user, board):


#top left to bottom right
if board[0][0] == user and board[1][1] == user and
board[2][2] == user: return True
elif board[0][2] == user and board[1][1] == user and
board[2][0] == user: return True
else: return False

while turns < 9:


active_user = current_user(user)
print_board(board)
user_input = input("Please enter a position 1 through
9 or enter \"q\" to quit:")
if quit(user_input): break
if not check_input(user_input):
print("Please try again.")
continue
user_input = int(user_input) - 1
coords = coordinates(user_input)
if istaken(coords, board):
print("Please try again.")
continue
add_to_board(coords, board, active_user)
if iswin(active_user, board):
print(f"{active_user.upper()} won!")
break

turns += 1
if turns == 9: print("Tie!")
user = not user
Snake Game
# Add background image and music

import pygame
from pygame.locals import *
import time
import random

SIZE = 40
BACKGROUND_COLOR = (110, 110, 5)
class Apple:
def __init__(self, parent_screen):
self.parent_screen = parent_screen
self.image =
pygame.image.load("resources/apple.jpg").convert()
self.x = 120
self.y = 120
2
def draw(self):
self.parent_screen.blit(self.image, (self.x, self.y))
pygame.display.flip()

def move(self):
self.x = random.randint(1,24)*SIZE
self.y = random.randint(1,19)*SIZE

class Snake:
def __init__(self, parent_screen):
self.parent_screen = parent_screen
self.image =
pygame.image.load("resources/block.jpg").convert()
self.direction = 'down'

self.length = 1
self.x = [40]
self.y = [40]

def move_left(self):
self.direction = 'left'
def move_right(self):
self.direction = 'right'

def move_up(self):
self.direction = 'up'

def move_down(self):
self.direction = 'down'

def walk(self):
# update body
for i in range(self.length-1,0,-1):
self.x[i] = self.x[i-1]
self.y[i] = self.y[i-1]

# update head
if self.direction == 'left':
self.x[0] -= SIZE
if self.direction == 'right':
self.x[0] += SIZE
if self.direction == 'up':
self.y[0] -= SIZE
if self.direction == 'down':
self.y[0] += SIZE

self.draw()

def draw(self):
for i in range(self.length):
self.parent_screen.blit(self.image, (self.x[i],
self.y[i]))

pygame.display.flip()

def increase_length(self):
self.length += 1
self.x.append(-1)
self.y.append(-1)

class Game:
def __init__(self):
pygame.init()
pygame.display.set_caption("Codebasics Snake
And Apple Game")

pygame.mixer.init()
self.play_background_music()

self.surface = pygame.display.set_mode((1000,
800))
self.snake = Snake(self.surface)
self.snake.draw()
self.apple = Apple(self.surface)
self.apple.draw()

def play_background_music(self):
pygame.mixer.music.load('resources/bg_music_1.mp
3')
pygame.mixer.music.play(-1, 0)

def play_sound(self, sound_name):


if sound_name == "crash":
sound =
pygame.mixer.Sound("resources/crash.mp3")
elif sound_name == 'ding':
sound =
pygame.mixer.Sound("resources/ding.mp3")

pygame.mixer.Sound.play(sound)

def reset(self):
self.snake = Snake(self.surface)
self.apple = Apple(self.surface)

def is_collision(self, x1, y1, x2, y2):


if x1 >= x2 and x1 < x2 + SIZE:
if y1 >= y2 and y1 < y2 + SIZE:
return True
return False

def render_background(self):
bg =
pygame.image.load("resources/background.jpg")
self.surface.blit(bg, (0,0))
def play(self):
self.render_background()
self.snake.walk()
self.apple.draw()
self.display_score()
pygame.display.flip()

# snake eating apple scenario


if self.is_collision(self.snake.x[0], self.snake.y[0],
self.apple.x, self.apple.y):
self.play_sound("ding")
self.snake.increase_length()
self.apple.move()

# snake colliding with itself


for i in range(3, self.snake.length):
if self.is_collision(self.snake.x[0],
self.snake.y[0], self.snake.x[i], self.snake.y[i]):
self.play_sound('crash')
raise "Collision Occurred"

def display_score(self):
font = pygame.font.SysFont('arial',30)
score = font.render(f"Score:
{self.snake.length}",True,(200,200,200))
self.surface.blit(score,(850,10))

def show_game_over(self):
self.render_background()
font = pygame.font.SysFont('arial', 30)
line1 = font.render(f"Game is over! Your score is
{self.snake.length}", True, (255, 255, 255))
self.surface.blit(line1, (200, 300))
line2 = font.render("To play again press Enter. To
exit press Escape!", True, (255, 255, 255))
self.surface.blit(line2, (200, 350))
pygame.mixer.music.pause()
pygame.display.flip()

def run(self):
running = True
pause = False

while running:
for event in pygame.event.get():
if event.type == KEYDOWN:
if event.key == K_ESCAPE:
running = False

if event.key == K_RETURN:
pygame.mixer.music.unpause()
pause = False

if not pause:
if event.key == K_LEFT:
self.snake.move_left()

if event.key == K_RIGHT:
self.snake.move_right()

if event.key == K_UP:
self.snake.move_up()

if event.key == K_DOWN:
self.snake.move_down()

elif event.type == QUIT:


running = False
try:

if not pause:
self.play()

except Exception as e:
self.show_game_over()
pause = True
self.reset()

time.sleep(.25)

if __name__ == '__main__':
game = Game()
game.run()

Hangman
import random
from words import word_list

def get_word():
word = random.choice(word_list)
return word.upper()

def play(word):
word_completion = "_" * len(word)
guessed = False
guessed_letters = []
guessed_words = []
tries = 6
print("Let's play Hangman!")
print(display_hangman(tries))
print(word_completion)
print("\n")
while not guessed and tries > 0:
guess = input("Please guess a letter or word:
").upper()
if len(guess) == 1 and guess.isalpha():
if guess in guessed_letters:
print("You already guessed the letter", guess)
elif guess not in word:
print(guess, "is not in the word.")
tries -= 1
guessed_letters.append(guess)
else:
print("Good job,", guess, "is in the word!")
guessed_letters.append(guess)
word_as_list = list(word_completion)
indices = [i for i, letter in enumerate(word) if
letter == guess]
for index in indices:
word_as_list[index] = guess
word_completion = "".join(word_as_list)
if "_" not in word_completion:
guessed = True
elif len(guess) == len(word) and guess.isalpha():
if guess in guessed_words:
print("You already guessed the word", guess)
elif guess != word:
print(guess, "is not the word.")
tries -= 1
guessed_words.append(guess)
else:
guessed = True
word_completion = word
else:
print("Not a valid guess.")
print(display_hangman(tries))
print(word_completion)
print("\n")
if guessed:
print("Congrats, you guessed the word! You
win!")
else:

print("Sorry, you ran out of tries. The word was "


+ word + ". Maybe next time!")

def display_hangman(tries):
stages = [ # final state: head, torso, both arms, and
both legs
"""
--------
| |
| O
| \\|/
| |
| / \\
-
""",
# head, torso, both arms, and one leg
"""
--------
| |
| O
| \\|/
| |
| /
-
""",

# head, torso, and both arms


"""
--------
| |
| O
| \\|/
| |
|
-
""",
# head, torso, and one arm
"""
--------
| |
| O
| \\|
| |
|
-
""",
# head and torso
"""
--------
| |
| O
| |
| |
|
-
""",

# head
"""
--------
| |
| O
|
|
|
-
""",
# initial empty state
"""
--------
| |
|
|
|
|
-
"""
]
return stages[tries]

def main():
word = get_word()
play(word)
while input("Play Again? (Y/N) ").upper() == "Y":
word = get_word()
play(word)

if __name__ == "__main__":
main()
Tetris
import pygame
import random

"""
10 x 20 square grid
shapes: S, Z, I, O, J, L, T
represented in order by 0 - 6
"""

pygame.font.init()

# GLOBALS VARS
s_width = 800
s_height = 700
play_width = 300 # meaning 300 // 10 = 30 width per
block
play_height = 600 # meaning 600 // 20 = 20 height
per blo ck
block_size = 30

top_left_x = (s_width - play_width) // 2


top_left_y = s_height - play_height

# SHAPE FORMATS

S = [['.....',
'.....',
'..00.',
'.00..',
'.....'],
['.....',
'..0..',
'..00.',
'...0.',
'.....']]

Z = [['.....',
'.....',
'.00..',
'..00.',
'.....'],
['.....',
'..0..',
'.00..',
'.0...',
'.....']]

I = [['..0..',
'..0..',
'..0..',
'..0..',
'.....'],
['.....',
'0000.',
'.....',
'.....',
'.....']]

O = [['.....',
'.....',
'.00..',
'.00..',
'.....']]

J = [['.....',
'.0...',
'.000.',
'.....',
'.....'],
['.....',
'..00.',
'..0..',
'..0..',
'.....'],
['.....',
'.....',
'.000.',
'...0.',
'.....'],
['.....',
'..0..',
'..0..',
'.00..',
'.....']]

L = [['.....',
'...0.',
'.000.',
'.....',
'.....'],
['.....',
'..0..',
'..0..',
'..00.',
'.....'],
['.....',
'.....',
'.000.',
'.0...',
'.....'],
['.....',
'.00..',
'..0..',
'..0..',
'.....']]

T = [['.....',
'..0..',
'.000.',
'.....',
'.....'],
['.....',
'..0..',
'..00.',
'..0..',
'.....'],
['.....',
'.....',
'.000.',
'..0..',
'.....'],
['.....',
'..0..',
'.00..',
'..0..',
'.....']]

shapes = [S, Z, I, O, J, L, T]
shape_colors = [(0, 255, 0), (255, 0, 0), (0, 255, 255),
(255, 255, 0), (255, 165, 0), (0, 0, 255), (128, 0, 128)]
# index 0 - 6 represent shape

class Piece(object):
rows = 20 # y
columns = 10 # x

def __init__(self, column, row, shape):


self.x = column
self.y = row
self.shape = shape
self.color = shape_colors[shapes.index(shape)]
self.rotation = 0 # number from 0-3
def create_grid(locked_positions={}):
grid = [[(0,0,0) for x in range(10)] for x in
range(20)]

for i in range(len(grid)):
for j in range(len(grid[i])):
if (j,i) in locked_positions:
c = locked_positions[(j,i)]
grid[i][j] = c
return grid

def convert_shape_format(shape):
positions = []
format = shape.shape[shape.rotation %
len(shape.shape)]

for i, line in enumerate(format):


row = list(line)
for j, column in enumerate(row):
if column == '0':
positions.append((shape.x + j, shape.y + i))

for i, pos in enumerate(positions):


positions[i] = (pos[0] - 2, pos[1] - 4)

return positions
def valid_space(shape, grid):
accepted_positions = [[(j, i) for j in range(10) if
grid[i][j] == (0,0,0)] for i in range(20)]
accepted_positions = [j for sub in
accepted_positions for j in sub]
formatted = convert_shape_format(shape)

for pos in formatted:


if pos not in accepted_positions:
if pos[1] > -1:
return False

return True

def check_lost(positions):
for pos in positions:
x, y = pos
if y < 1:
return True
return False

def get_shape():
global shapes, shape_colors

return Piece(5, 0, random.choice(shapes))


def draw_text_middle(text, size, color, surface):
font = pygame.font.SysFont('comicsans', size,
bold=True)
label = font.render(text, 1, color)

surface.blit(label, (top_left_x + play_width/2 -


(label.get_width() / 2), top_left_y + play_height/2 -
label.get_height()/2))

def draw_grid(surface, row, col):


sx = top_left_x
sy = top_left_y
for i in range(row):
pygame.draw.line(surface, (128,128,128), (sx, sy+
i*30), (sx + play_width, sy + i * 30)) # horizontal lines
for j in range(col):
pygame.draw.line(surface, (128,128,128), (sx + j
* 30, sy), (sx + j * 30, sy + play_height)) # vertical
lines

def clear_rows(grid, locked):


# need to see if row is clear the shift every other row
above down one

inc = 0
for i in range(len(grid)-1,-1,-1):
row = grid[i]
if (0, 0, 0) not in row:
inc += 1
# add positions to remove from locked
ind = i
for j in range(len(row)):
try:
del locked[(j, i)]
except:
continue
if inc > 0:
for key in sorted(list(locked), key=lambda x:
x[1])[::-1]:
x, y = key
if y < ind:
newKey = (x, y + inc)
locked[newKey] = locked.pop(key)

def draw_next_shape(shape, surface):


font = pygame.font.SysFont('comicsans', 30)
label = font.render('Next Shape', 1, (255,255,255))

sx = top_left_x + play_width + 50
sy = top_left_y + play_height/2 - 100
format = shape.shape[shape.rotation %
len(shape.shape)]

for i, line in enumerate(format):


row = list(line)
for j, column in enumerate(row):
if column == '0':
pygame.draw.rect(surface, shape.color, (sx +
j*30, sy + i*30, 30, 30), 0)

surface.blit(label, (sx + 10, sy- 30))

def draw_window(surface):
surface.fill((0,0,0))
# Tetris Title
font = pygame.font.SysFont('comicsans', 60)
label = font.render('TETRIS', 1, (255,255,255))

surface.blit(label, (top_left_x + play_width / 2 -


(label.get_width() / 2), 30))

for i in range(len(grid)):
for j in range(len(grid[i])):
pygame.draw.rect(surface, grid[i][j], (top_left_x
+ j* 30, top_left_y + i * 30, 30, 30), 0)

# draw grid and border


draw_grid(surface, 20, 10)
pygame.draw.rect(surface, (255, 0, 0), (top_left_x,
top_left_y, play_width, play_height), 5)
# pygame.display.update()
def main():
global grid

locked_positions = {} # (x,y):(255,0,0)
grid = create_grid(locked_positions)

change_piece = False
run = True
current_piece = get_shape()
next_piece = get_shape()
clock = pygame.time.Clock()
fall_time = 0
level_time = 0
fall_speed = 0.27
score = 0

while run:

grid = create_grid(locked_positions)
fall_time += clock.get_rawtime()
level_time += clock.get_rawtime()
clock.tick()

if level_time/1000 > 4:
level_time = 0
if fall_speed > 0.15:
fall_speed -= 0.005
# PIECE FALLING CODE
if fall_time/1000 >= fall_speed:
fall_time = 0
current_piece.y += 1
if not (valid_space(current_piece, grid)) and
current_piece.y > 0:
current_piece.y -= 1
change_piece = True

for event in pygame.event.get():


if event.type == pygame.QUIT:
run = False
pygame.display.quit()
quit()

if event.type == pygame.KEYDOWN:
if event.key == pygame.K_LEFT:
current_piece.x -= 1
if not valid_space(current_piece, grid):
current_piece.x += 1

elif event.key == pygame.K_RIGHT:


current_piece.x += 1
if not valid_space(current_piece, grid):
current_piece.x -= 1
elif event.key == pygame.K_UP:
# rotate shape
current_piece.rotation =
current_piece.rotation + 1 % len(current_piece.shape)
if not valid_space(current_piece, grid):
current_piece.rotation =
current_piece.rotation - 1 % len(current_piece.shape)

if event.key == pygame.K_DOWN:
# move shape down
current_piece.y += 1
if not valid_space(current_piece, grid):
current_piece.y -= 1

'''if event.key == pygame.K_SPACE:


while valid_space(current_piece, grid):
current_piece.y += 1
current_piece.y -= 1

print(convert_shape_format(current_piece))''' # todo
fix

shape_pos =
convert_shape_format(current_piece)

# add piece to the grid for drawing


for i in range(len(shape_pos)):
x, y = shape_pos[i]
if y > -1:
grid[y][x] = current_piece.color

# IF PIECE HIT GROUND


if change_piece:
for pos in shape_pos:
p = (pos[0], pos[1])
locked_positions[p] = current_piece.color
current_piece = next_piece
next_piece = get_shape()
change_piece = False

# call four times to check for multiple clear rows


if clear_rows(grid, locked_positions):
score += 10

draw_window(win)
draw_next_shape(next_piece, win)
pygame.display.update()

# Check if user lost


if check_lost(locked_positions):
run = False

draw_text_middle("You Lost", 40, (255,255,255),


win)
pygame.display.update()
pygame.time.delay(2000)

def main_menu():
run = True
while run:
win.fill((0,0,0))
draw_text_middle('Press any key to begin.', 60,
(255, 255, 255), win)
pygame.display.update()
for event in pygame.event.get():
if event.type == pygame.QUIT:
run = False

if event.type == pygame.KEYDOWN:
main()
pygame.quit()

win = pygame.display.set_mode((s_width, s_height))


pygame.display.set_caption('Tetris')

main_menu() # start game


SYSTEM

FLOWCHART
Start
program
A

Display Choices

Tic tac
Choice 1 A
Toe

Snake
Choice 2 A
Game
2 == 2

Choice 3 Hangman A

Choice 4 Tetris A

Choice 5

STOP
APPLICATION

FLOWCHART
Tic Tac Toe

Python code
Tic Tak Toe

Enter position for X

Calculating row and column as per


entered choice

Just after entering output seen as


presence of X at the entered position.

Enter position for 0

Calculating row and column as per


entered choice

output seen as presence of 0 at the


entered position.
And this loop continues till winning
of any one

RETURN TO MAIN MENU


Snake

Game
Snake Game

User needs to select arrow keys


to move the snake

Turn right
If Choice = A

Move
If Choice =
upwards
A

Turn Left A
If Choice =

Turn
If Choice = Down A

RETURN TO MAIN MENU


Hangman

Game
Hangman

User needs to select guess and


type the letters of the word
seleceted

correct
Entered letter Get one
chance A

Incorrect

Another correct Get one


chance chance A

Incorrect
GAME OVER

RETURN TO MAIN MENU


Tetris

Game
Tetris

User needs to select arrow keys


to move the block

Turn right
If Choice A

If Choice Turn Left A

Turn
If Choice Down
A

RETURN TO MAIN MENU


Outputs
Limitaions
As there is nothing perfect in this world so there are
some limitations of my software as well.
In this Graphic games is limited to only two, various
components and resourecs are not so real looking and in
snake games Boundries are not set for the play area so if
snake goes out so it can never be returned.
There is only one game which can contribute multiplayer
play simultaneously.

Areas of Improvement
There are several areas where improvisation is required
like Boundaries of Snake game has to be made so that it
cannot escape out.
All games should me made for a simultaneous multiplayer
platform. In tetris game the blocks coming done should
land directly ig the player presses the down arrow key.
Bibliography
All the coding and Programming
is done by :

Aviral Dwivedi Class 12-A

All the images are taken from :

www.google.com
www.shutterstock.com
www.gettyimages.com

You might also like