0% found this document useful (0 votes)
6 views14 pages

Vedi & Ritesh

The document outlines a project on developing a color game using Python, submitted by students Vedansh and Ritesh Kumar Sharma for their Computer Science class. It includes details about the game's purpose, how it works, the coding process, and acknowledges the guidance received from their teacher. The project aims to enhance programming skills and provide a fun, interactive experience for players.

Uploaded by

ghostmodeonhoes
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)
6 views14 pages

Vedi & Ritesh

The document outlines a project on developing a color game using Python, submitted by students Vedansh and Ritesh Kumar Sharma for their Computer Science class. It includes details about the game's purpose, how it works, the coding process, and acknowledges the guidance received from their teacher. The project aims to enhance programming skills and provide a fun, interactive experience for players.

Uploaded by

ghostmodeonhoes
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/ 14

COMPUTER SCIENCE

INVESTIGATORY PROJECT
ON
DEVELOPING A COLOR GAME
Using Python

SESSION – 2024-2025
Sumbitted To: Mr. Rajulal Meena

Made By: Vedansh & Ritesh Kumar Sharma

Class: 11th Science (PCM)

DEPARTMENT OF COMPUTER SCIENCE


KENDRIYA VIDYALAYA NO. 1 BATHINDA CANTT
BATHINDA (PUNJAB)
CERTIFICATE

This is to certify that the embodied work on the project entitled


“Color Game in Python” for the partial fulfillment of the SESSION
2024-25 is a part of the practical examination of Computer Science
subject. It has been successfully completed by: Vedansh & Ritesh
Kumar Sharma, And class Roll No: 27 & 22 of Kendriya Vidyalaya
No.1 Bathinda Cantt. This project is the genuine work done by under
our proper supervision and guidance of Mr. Rajulal Meena .

Signature of the Examiner


Signature of Guide

Signature of Principal

ACKNOWLEDGEMENT
We, Vedansh & Ritesh Kumar Sharma , would like to thank our
principal, Miss. Kumud Ahuja, who has inspired and encouraged us
by her deeds and achievements, as she always tells us what we do
the best and be the best init.

Next, I would like to express my sincere gratitude towards our


Computer Science teacher, Mr. Rajulal Meena , for his continuous
support and valuable guidance in making this project a great
success.

Vedansh & Ritesh Kumar Sharma


Class – 11th B
Roll No: 27 & 22

AIM OF THE PROJECT


DEVELOPING A
COLOR GAME

CONTENTS
 Purpose
 What is python?
 Why python?
 About the game and how it works
 Modules/functions used in coding
 Coding for the snake game
 Output
 Conclusion
 Bibliography

PURPOSE
Game Development has emerged as an integral field in the sector of
technological advancement. Gamers and gaming professional are
slowly improving on this sector and every now and then new games
are being developed by such programmers.

For the ones who wish to make a career in this field, this small
project can be regarded as their first step.

The game has also provided me an avenue for eliminating stress


once in a while. It’s extremely simple and yet competitive. Trying to
beat my previous score pushes me toward typing quicker and
thinking faster.

WHAT IS PYHTON?

Python is an interpreted, object-oriented, high-level programming


language with dynamic semantics. Its high-level built in data
structures, combined with dynamic typing and dynamic binding,
make it very attractive for Rapid Application Development, as well
as for use as a scripting or glue language to connect existing
components together. Python's simple, easy to learn syntax
emphasizes readability and therefore reduces the cost of program
maintenance. Python supports modules and packages, which
encourages program modularity and code reuse. The Python
interpreter and the extensive standard library are available in
source or binary form without charge for all major platforms, and
can be freely distributed.

WHY PYHTON?

Why is Python so popular?


1. Syntax is extremely simple to read and follow
2. Python is very beginner-friendly
3. Millions of happy learners
4. Easier than other programming language.
Why should we learn Python?
1. General-purpose language
2. Wide range of applications
3. Web development-django Bottle
4. Mathematical computations (numpy and simpy)
5. Graphical user interface (Panda 3D)
6. Length of the code is relatively short
7. Fun to work with

ABOUT THE GAME AND


HOW IT WORKS

This game is a quick response time killer. Anyone can play it. It
attempts to trick the player into entering an incorrect input. The
goal is to enter as many correct inputs as possible within the given
time. The primary goal of the game is to break the previous record
for highest score.
There are ten available colors in this game; Red, Blue, Green, Pink,
Black, Yellow, Orange, White, Purple and Brown. The game window
displays one of the color names as text. Here comes the catch. The
text is formatted and displayed in another color (from the available
colors). The player must enter the name of the color with which the
text is formatter and not the name already on display. This demands
quick thinking and even faster typing. As soon as a player registers
the correct input, the name and color on display changes and a
point is scored.
The goal is to get as many points as possible within 30 seconds.

CODE FOR THE PROGRAM

# import the modules


import tkinter
import random

# list of possible colour.


colours = ['Red','Blue','Green','Pink','Black',
'Yellow','Orange','White','Purple','Brown']
score = 0

# the game time left, initially 30 seconds.


timeleft = 30

# function that will start the game.


def startGame(event):

if timeleft == 30:

# start the countdown timer.


countdown()

# run the function to


# choose the next colour.
nextColour()

# Function to choose and


# display the next colour.
def nextColour():

# use the globally declared 'score'


# and 'play' variables above.
global score
global timeleft

# if a game is currently in play


if timeleft > 0:

# make the text entry box active.


e.focus_set()

# if the colour typed is equal


# to the colour of the text
if e.get().lower() == colours[1].lower():

score += 1

# clear the text entry box.


e.delete(0, tkinter.END)

random.shuffle(colours)

# change the colour to type, by changing the


# text _and_ the colour to a random colour value
label.config(fg = str(colours[1]), text = str(colours[0]))

# update the score.


scoreLabel.config(text = "Score: " + str(score))

# Countdown timer function


def countdown():

global timeleft

# if a game is in play
if timeleft > 0:

# decrement the timer.


timeleft -= 1

# update the time left label


timeLabel.config(text = "Time left: "
+ str(timeleft))

# run the function again after 1 second.


timeLabel.after(1000, countdown)

# Driver Code

# create a GUI window


root = tkinter.Tk()
# set the title
root.title("COLORGAME")

# set the size


root.geometry("375x200")

# add an instructions label


instructions = tkinter.Label(root, text = "Type in the colour"
"of the words, and not the word text!",
font = ('Helvetica', 12))
instructions.pack()

# add a score label


scoreLabel = tkinter.Label(root, text = "Press enter to start",
font = ('Helvetica', 12))
scoreLabel.pack()

# add a time left label


timeLabel = tkinter.Label(root, text = "Time left: " +
str(timeleft), font = ('Helvetica', 12))

timeLabel.pack()

# add a label for displaying the colours


label = tkinter.Label(root, font = ('Helvetica', 60))
label.pack()

# add a text entry box for


# typing in colours
e = tkinter.Entry(root)

# run the 'startGame' function


# when the enter key is pressed
root.bind('<Return>', startGame)
e.pack()

# set focus on the entry box


e.focus_set()

# start the GUI


root.mainloop()
OUTPUT
CONCLUSION
We learned how to create the color game in Python. Many things
could be added to this little toy game but this serves as a very
simple example.

The good thing about this game and our solution is that it is very
simple. The approach is pretty simple and easy to understand even
for beginners. This game could run on many platforms.

There can be many more features which can be added to this game
to make it more interactive and interesting.
BIBLIOGRAPHY
Books used:
Sumita Arora Computer text book for class XI
Sumita Arora Computer text book for class XII

Websites:
1. https://www.geeksforgeeks.org/introduction-to-pygame/
2. https://www.pythonforbeginners.com/random/how-to-use-the-random-module-in-python
3. https://www.geeksforgeeks.org/python-gui-tkinter/

You might also like