A Color Code Game In Python is a game in which you must predict the color of a random word.
You must type the color of the words, not the word text, in this case.
This system’s design is also fairly straightforward, so the user will have no problems dealing with it.
This project was constructed from the ground up. The project file includes a Python script (main.py).
This is a simple GUI-based project that is easy to understand and use.
Furthermore, this project offers an easy method for users to play and have leisure time.
What is a Color Game In Python?
This Color Game in Python has a distinct text color that will be used to indicate different color names.
The player’s job in this game is to enter the correct color of the word that is displayed on the screen.
The player’s score will be increased by one each time he or she enters the correct color. In addition, the game will last 60 seconds.
What Is The Goal Of Color Game?
The purpose of the color game is to find a color combination that the computer has chosen at random.
Project Details and Technology
Project Name: | Color Game Using Tkinter In Python With Source Code |
Abstract | This Color Game Using Tkinter In Python a simple game designed for gamers who love guessing colors. |
Language/s Used: | Python (GUI Based) |
Python version (Recommended): | 3.8 or 3.9 |
Type: | Desktop Application |
Developer: | Source Code Hero |
Updates: | 0 |
About the Project
The Color Game Using Tkinter In Python is a fully functional GUI (Graphical User Interface) system that covers all of the elements that IT students and computer-related courses will require for their college projects.
A Color Game Tkinter In Python player must input the color of the word that comes on the screen to increase their score by one.
Additionally, this game takes a total of 30 seconds to complete. Red, Blue, Green, Pink, Black, Yellow, Orange, White, Purple, and Brown are the colors used in this game.
Color names will be displayed in various hues on the interface. To win the game, a player must identify the color and submit the correct color name.
Moreover, this system is quite useful, and the concept and logic of the project are simple to grasp.
The source code is open source and free to use. Simply scroll down and click the download option.
How Do You Program A Color Game Using Tkinter In Python?
The code given below is the full source code on Color Game Using Tkinter In Python.
create a file name main.py
from tkinter import * import random #list of possible colour. colours = ['Red','Blue','Green','Pink','Black', 'Yellow','Orange','White','Purple','Brown'] score = 0 #To take in account the time left: initially 30 seconds time = 30 #Function that will start the Game def startGame(event): if time==30: #start the countdown timer countdown() #run the function to chose the next color nextcolor() def nextcolor(): global score global time #if a game is in play if time > 0: #make the text entry box active colour_entry.focus_set() if colour_entry.get().lower() == colours[1].lower(): score += 1 #clear the entry the box colour_entry.delete(0, END) random.shuffle(colours) # change the colour to type, by changing the # text _and_ the colour to a random colour value colour.config(fg= str(colours[1]) , text = str(colours[0])) # update the score. scoreLabel.config(text = "Score: " + str(score)) #Countdown Timer Fuction def countdown(): global time #if a game is in play if time > 0 : #decrement the value time -= 1 # update the time left label timeLabel.config(text = "Time left: "+ str(time)) # run the function again after 1 second. timeLabel.after(1000, countdown) #Driver Code if __name__=='__main__': root = Tk() #Setting the title root.title('Color Game') #Setting the geometry of the window root.geometry('375x200') #set an instruction label instructions = Label(root, text = 'Type in the colour of the words, and not the word text!', font = ('Helvetica', 12)) instructions.pack() #Create a Score label scoreLabel = Label(root, text = 'Score :'+str(score), font=('Helvetica' , 12)) scoreLabel.pack() #Create a Time Label timeLabel = Label(root, text = 'Time Left : '+str(time), font=('Helvetica' , 12)) timeLabel.pack() #create a colour label colour = Label(root, font=('Helevetica',12)) colour.pack() #Entry box for input from user colour_entry = Entry(root) colour_entry.focus_set() root.bind('<Return>',startGame) colour_entry.pack() root.mainloop()
Steps On How To Run The Project
Time needed: 5 minutes
These are the steps on how to run Color Game Using Tkinter In Python With Source Code
- Download Source Code
First, find the downloadable source code below and click to start downloading the source code file.
- Extract File
Next, after finished to download the file, go to file location and right click the file and click extract.
- Open PyCharm
Next, open pycharm IDE and open the project you’ve downloaded.
- Run Project
Next, go to the Pycharm and click the run button to start executing the project.
Download the Source Code below!
Summary
This Article is a way to enhance and develop our skills and logic ideas which is important in practicing the Python programming language which is the most well-known and most usable programming language in many companies.
Inquiries
If you have any questions or suggestions about Color Game Using Tkinter In Python With Source Code, please feel free to leave a comment below.