0% found this document useful (0 votes)
83 views20 pages

Python Report Egg Catcher

The document is a mini project report on the 'Egg Catcher Game' developed as part of Project Based Learning by students from K. K. Wagh Institute of Engineering Education & Research. It includes sections on the game's abstract, introduction, methodology, requirements, data flow diagrams, sample code, and acknowledgments. The game is designed for entertainment, where players catch falling eggs with a basket, facing increasing difficulty as they progress.

Uploaded by

yogeshgavit208
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
83 views20 pages

Python Report Egg Catcher

The document is a mini project report on the 'Egg Catcher Game' developed as part of Project Based Learning by students from K. K. Wagh Institute of Engineering Education & Research. It includes sections on the game's abstract, introduction, methodology, requirements, data flow diagrams, sample code, and acknowledgments. The game is designed for entertainment, where players catch falling eggs with a basket, facing increasing difficulty as they progress.

Uploaded by

yogeshgavit208
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 20

MINI PROJECT REPORT

ON
“Egg Catcher Game”
as a part of
Project Based Learning

Submitted by
Prathamesh Chaure
Nilesh Gaikawad
Yogesh Gavit
Vaibhav More

Guided by
Prof. Poonam Patil

Master of Computer Applications


(Under Faculty of Engineering)

Department of MCA
K. K. Wagh Institute of Engineering Education & Research
Hirabai Haridas Vidyanagari, Amrutdham, Panchavati,
Nashik – 422 003

1
K. K. WAGH INSTITUTE OF ENGINEERING EDUCATION &
RESEARCH
NASHIK - 422003

CERTIFICATE
This is to certify that

Prathamesh Chaure
Nilesh Gaikawad
Yogesh Gavit
Vaibhav More

Has successfully completed the Mini Project on

“Egg Catcher Game”


As a part of
Project Based Learning

During academic year 2022 – 23

Prof. Poonam Patil Prof. V. C. Bagal Dr. K. N. Nandurkar


Project Guide I/c Head, Principal
Dept. of MCA

2
Index

Title Page no.

1. Abstract 4

2. Introduction 5

3. Methodology 6

4. Requirements 8

5. Data flow diagram 10

6. Sample code 13

7. Screenshots 14

8. Conclusion 18

9. Acknowledgment 19

10. Reference 20

3
Abstract
Egg Catcher Game

As we know that Egg catcher is a game in which eggs are falling from up one by one which
has to be catch in the basket which is and that basket were controlled by player. This game is
for entertainment purpose and can be played by any age group. When the game starts, the
speed of eggs falling from up is slow but as the score of the game increases the speed of the
eggs also increases gradually, This is result into difficulty of the game. To control the basket
we have give two arrow button left and right.

The game is developed for playing single player where we provide three lives. If the player
misses any egg from catching in the basket the lives is decreased eventually. If the lives of the
player become 0 the game is terminated and the score is displayed to the player through pop
window.

The background of the game is designed with simple light blue colour in one third of the game
representing as eggs falling from sky and bottom of the game is filled with green color
representing as grass onto which the eggs are falling. There is also a half circular at the top
left corner which represents as sun.

Keywords: Eggs, Basket, Score, Lives, Speed.

(Division – B)
Team Members:
11: Prathamesh Keda Chaure
18: Nilesh Murlidhar Gaikawad
21: Yogesh Yashvant Gavit
42: Vaibhav Madhukar More

Introduction
Egg Catcher Game
4
Eggs Catcher is a classic game where the goal is to catch as many eggs as
possible. In this game, every egg you catch will increase your score and if you
miss 3 eggs you will lose the game.

An egg catcher game tests your concentration and the speed of your reflexes as you have to
catch eggs falling all around the screen with one basket. To create an egg catcher game you
have to design an animation of falling eggs at random positions and a basket will be catching
all the falling eggs.

To create an eggs catcher game using Python, the first step is to design a floor, basket, and
eggs. Once your game starts, the eggs will gradually move across the floor, which will create
an animation indicating that the eggs are falling. Then with the help of loops, we can
constantly check that the eggs have been caught in the basket or have touched the ground.
When the egg is caught or dropped, it will be an end of an event, so here the egg will be
removed and the game has to adjust the score by increasing the score if the egg was caught
in the basket or by decreasing your one life if the egg has touched the ground.

To create an egg catcher game using Python, we need to use three different loops:

1. One to create new eggs.


2. Another to check if the catcher has caught an egg.
3. And the third loop to move eggs and to check if the eggs touched the ground.

We will be using three Python modules:

1. itertools: to change the colours of the falling eggs.


2. random: to make the eggs appear at random positions.
3. Tkinter: to animate the game on the screen.

5
Methodology
Python Modules:
1) Tkinter:-

The tkinter package (“Tk interface”) is the standard Python interface to the Tcl/Tk
GUI toolkit. Both Tk and tkinter are available on most Unix platforms, including
macOS, as well as on Windows systems.

Running python -m tkinter from the command line should open a window
demonstrating a simple Tk interface, letting you know that tkinter is properly
installed on your system, and also showing what version of Tcl/Tk is installed, so you
can read the Tcl/Tk documentation specific to that version.

Tkinter supports a range of Tcl/Tk versions, built either with or without thread support.
The official Python binary release bundles Tcl/Tk 8.6 threaded

When your Python application uses a class in Tkinter, e.g., to create a widget,
the tkinter module first assembles a Tcl/Tk command string. It passes that Tcl
command string to an internal _tkinter binary module, which then calls the Tcl
interpreter to evaluate it. The Tcl interpreter will then call into the Tk and/or Ttk
packages, which will in turn make calls to Xlib, Cocoa, or GDI.

from tkinter import *


from tkinter import ttk

Tkinter is not a thin wrapper, but adds a fair amount of its own logic to make the
experience more pythonic.

2) Random:-

The Random module contains some very useful functions namely randint() function,
random() function, choice() function, randrange() function and shuffle() function.

The random module in Python is used to generate random numbers and make random
selections from sequences. The module uses a pseudorandom number generator to
generate random numbers. A pseudorandom number generator is an algorithm that
generates numbers that appear to be random but are actually determined by a starting
value called a seed.
The random module uses a seed value to generate random numbers. By default, the
seed value is based on the current time and is different each time the program is run.
However, you can also set the seed value manually using the seed() function. If you set
the seed value to a fixed value, you will get the same sequence of random numbers
every time you run the program.

6
3) Itertools:-

itertools is a Python module that provides a set of functions for working with iterable
objects. The module contains a collection of tools for handling iterators, such as infinite
iterators, permutations, and combinations. It is a powerful and efficient toolset for
creating complex data pipelines.
Here are some commonly used functions in the itertools module:
1. count(start=0, step=1) - This function returns an infinite iterator that generates numbers
starting from start and incrementing by step for each iteration.
2. cycle(iterable) - This function returns an infinite iterator that cycles through the
elements of the given iterable.
3. repeat(elem, n=None) - This function returns an iterator that repeats the element elem
n times or indefinitely if n is None.
4. chain(*iterables) - This function returns an iterator that chains together the elements of
the given iterables.
5. zip_longest(*iterables, fillvalue=None) - This function returns an iterator that
aggregates the elements of the given iterables, filling in missing values with the fillvalue
argument.
6. permutations(iterable, r=None) - This function returns an iterator that generates all
possible permutations of the elements of the given iterable.
7. combinations(iterable, r) - This function returns an iterator that generates all possible
combinations of r elements from the given iterable.
8. product(*iterables, repeat=1) - This function returns an iterator that generates the
Cartesian product of the given iterables.
The itertools module can be used to write efficient and concise code for tasks such as
data processing, mathematical computations, and algorithmic problem-solving. It is
particularly useful for working with large datasets or complex data structures.

7
Requirements
System
Requirements

The system requirements for an Egg Catcher game in Python will depend
on the complexity of the game and the libraries used to develop it.
However, for a basic Egg Catcher game, the following system
requirements are recommended:
1. Operating System: Any modern operating system such as Windows,
macOS, or Linux.
2. Processor: Any processor that supports Python 3.x. For a basic game, a
CPU with a clock speed of 1 GHz or higher should suffice.
3. Memory (RAM): At least 2 GB of RAM is recommended for smooth
performance.
4. Storage: The game itself requires very little storage space, but some
additional space will be needed to store sound effects or other assets.
5. Python version: Python 3.x should be installed on the system.
6. Python libraries: The game may use libraries such as Pygame, which will
need to be installed.
7. Graphics card: A dedicated graphics card is not required for a basic game,
but it can improve the game's performance and visual quality.
It's important to note that these are just general guidelines, and the exact
system requirements will depend on the specific requirements of the game
being developed. Additionally, if the game is intended to run on mobile
devices or tablets, the system requirements will differ from those of a
desktop or laptop computer.

.
Software Requirements

To develop an Egg Catcher game in Python, you will need a few software
requirements. These include:
1. Python - You will need to have Python installed on your computer. Python is
a free and open-source programming language, and you can download the
latest version from the official website.
2. Pygame - Pygame is a set of Python modules designed for writing games. It
provides functions to handle graphics, sound, input, and other game-related
tasks. You can install Pygame using pip, the Python package installer.
3. Code editor - You will need a code editor to write and edit the Python code.
There are many code editors available, including Visual Studio Code,
PyCharm, and Sublime Text, among others. You can choose the one that
best suits your needs.
4. Sound editor - You may also need a sound editor to create or edit sound
effects for your game. There are many sound editors available, such as
Audacity, which is a free, open-source sound editor.
5. Graphics editor - You may also need a graphics editor to create or edit
graphics for your game. There are many graphics editors available, such as
8
GIMP, which is a free, open-source graphics editor

Functional Requirements

The functional requirements of an Egg Catcher game in Python define what the game
should be able to do and how it should behave. Here are some common functional
requirements for an Egg Catcher game:

1. Start screen - The game should display a start screen that provides instructions on how
to play the game and allows the player to start a new game.

2. Difficulty levels - The game should offer different difficulty levels that affect the speed of
the falling eggs and the score multiplier.

3. Basket movement - The game should allow the player to move the basket horizontally
using the arrow keys or other input methods.

4. Egg falling - The game should generate eggs that fall from the top of the screen and
move towards the bottom.

5. Egg catching - The game should allow the player to catch the falling eggs using the
basket.

6. Scoring - The game should keep track of the player's score and display it on the
screen.

7. Lives - The game should allow the player to have a certain number of lives, and the
player loses a life when an egg hits the ground.

8. Game over screen - The game should display a game over screen when the player has
lost all their lives.

9. Sound effects - The game should include sound effects such as the sound of an egg
breaking when it hits the ground and a sound when the player catches an egg.

10. High scores - The game should keep track of the highest score achieved by the player
and display it on the screen.

These are some common functional requirements for an Egg Catcher game in Python.
Depending on the specific design of the game, there may be additional or different
requirements.
.

9
Data Flow Diagram

1) FLOWCHART

Start
|
v
Display Start Screen
|
v
Wait for Player Moves (Start Game or Quit)
|
v
while Lives > 0:
|
|__> Generate Falling Eggs
|__> Player Moves Basket according to catch eggs
|__> Check for Egg is catched or Not
|__> If Catched, Add Points and Generate New Egg
|__> If Egg Hits Ground, Lose Life
|__> Update Score and Lives on Screen
|
v
Display Game Over Screen and Final Score
|
v
Wait for Player Moves (Restart or Quit)
|
v
End

1
0
2) Use case diagram

USER

START THE GAME

MOVE THE
BASKET

CATCH THE
FALLING EGGS

INCREASE THE
SCORE

LOSE A LIFE

GAME OVER (NO


MORE LIVES)

END

RESTART THE
GAME

1
1
SAMPLE CODE
from itertools import cycle
from random import randrange
from tkinter import Canvas, Tk, messagebox, font

canvas_width = 800
canvas_height = 400

root = Tk()
root.title("Egg Catcher")
c = Canvas(root, width=canvas_width, height=canvas_height, background="deep sky blue")
c.create_rectangle(-5, canvas_height-100, canvas_width+5, canvas_height+5, fill="sea green", width=0)
c.create_oval(-80, -80, 120, 120, fill='orange', width=0)
c.pack()

color_cycle = cycle(["light blue", "light green", "light pink", "light yellow", "light cyan"])
egg_width = 45
egg_height = 55
egg_score = 10
egg_speed = 500
egg_interval = 4000
difficulty = 0.95
catcher_color = "blue"
catcher_width = 100
catcher_height = 100
catcher_startx = canvas_width / 2 - catcher_width / 2
catcher_starty = canvas_height - catcher_height - 20
catcher_startx2 = catcher_startx + catcher_width
catcher_starty2 = catcher_starty + catcher_height

catcher = c.create_arc(catcher_startx, catcher_starty, catcher_startx2, catcher_starty2, start=200, extent=140,


style="arc", outline=catcher_color, width=3)
game_font = font.nametofont("TkFixedFont")
game_font.config(size=18)

score = 0
score_text = c.create_text(10, 10, anchor="nw", font=game_font, fill="darkblue", text="Score: "+ str(score))

lives_remaining = 3
lives_text = c.create_text(canvas_width-10, 10, anchor="ne", font=game_font, fill="darkblue", text="Lives: "+
str(lives_remaining))

eggs = []

def create_egg():
x = randrange(10, 740)
y = 40
new_egg = c.create_oval(x, y, x+egg_width, y+egg_height, fill=next(color_cycle), width=0)
eggs.append(new_egg)
root.after(egg_interval, create_egg)

def move_eggs():
for egg in eggs:
1
2
(eggx, eggy, eggx2, eggy2) = c.coords(egg)
c.move(egg, 0, 10)
if eggy2 > canvas_height:
egg_dropped(egg)
root.after(egg_speed, move_eggs)

def egg_dropped(egg):
eggs.remove(egg)
c.delete(egg)
lose_a_life()
if lives_remaining == 0:
messagebox.showinfo("Game Over!", "Final Score: "+ str(score))
root.destroy()

def lose_a_life():
global lives_remaining
lives_remaining -= 1
c.itemconfigure(lives_text, text="Lives: "+ str(lives_remaining))

def check_catch():
(catcherx, catchery, catcherx2, catchery2) = c.coords(catcher)
for egg in eggs:
(eggx, eggy, eggx2, eggy2) = c.coords(egg)
if catcherx < eggx and eggx2 < catcherx2 and catchery2 - eggy2 < 40:
eggs.remove(egg)
c.delete(egg)
increase_score(egg_score)
root.after(100, check_catch)

def increase_score(points):
global score, egg_speed, egg_interval
score += points
egg_speed = int(egg_speed * difficulty)
egg_interval = int(egg_interval * difficulty)
c.itemconfigure(score_text, text="Score: "+ str(score))

def move_left(event):
(x1, y1, x2, y2) = c.coords(catcher)
if x1 > 0:
c.move(catcher, -20, 0)

def move_right(event):
(x1, y1, x2, y2) = c.coords(catcher)
if x2 < canvas_width:
c.move(catcher, 20, 0)

c.bind("<Left>", move_left)
c.bind("<Right>", move_right)
c.focus_set()
root.after(1000, create_egg)
root.after(1000, move_eggs)
root.after(1000, check_catch)
root.mainloop()

1
3
SCREENSHOTS

After running the above-given command you will get a new window opened and
the egg catcher game will be started in that window.

This is the output of the code. we can see there is an egg coming toward the
ground and there is a blue u-shaped basket. now we have to catch the egg into
the basket by moving toward the left and right using the left arrow key and right
arrow key.

This is the final score we get after using three lives. here is final score i.e, 80

1
4
CONCLUSION

In conclusion, the Egg Catcher game in Python is a fun and interactive


game that involves catching falling eggs with a basket. The game requires
the use of various programming concepts such as event handling,
animation, collision detection, and user input. By implementing the game,
one can improve their understanding of programming fundamentals and
learn how to create a simple yet engaging game.
The functional requirements of an Egg Catcher game include generating
falling eggs, moving the basket based on user input, checking for egg-
basket collision, keeping track of the score and lives, and displaying a
game over screen when the player loses all their lives. In addition, the
game can include features such as different difficulty levels, sound
effects, and high score tracking.
Overall, the Egg Catcher game in Python is a great project for beginners
and advanced programmers alike. It offers a fun way to learn
programming and can be customized to suit different levels of skill and
interests.

1
5
ACKNOWLEDGEMENT
We have taken efforts in this Project “Egg Catcher Game”. However, it would
not have been possible without the kind support and help of many individuals
and organizations. We would like to extend our sincere thanks to all of them.

Firstly we express our gratitude to Principle Dr. K. N. Nandurkar Sir and the
project co-ordinator Prof. Poonam Patil Mam for their support.

We would like to thank our project guide Prof. Poonam Patil Mam for guiding us
throughout our work with patience. She has taken pain to go through our project
and make necessary corrections as and when needed. Without her guidance
and persistent efforts this project would not have been possible.

We extend our gratefulness to our institute’s library and its members for their
support and heartfelt thanks to all the faculty members of the college

1
6
Reference

 Python.org
 Real python

1
7
Thank you

1
8
1
9
2
0

You might also like