PyQt5 – The Color Game
In this article we will see how we can create a color game using PyQt5. In this game user has to score maximum by naming the color name of the color of given word and in order to confuse the player the text will be of different color name. Below is how color game looks like
GUI Implementation Steps :
1. Create a head label to show the name of the game, set its features like alignment color etc.
2. Create a instruction label to tell the instruction to the user
3. Create a push button to start/ reset the game
4. Create Label to show the score
5. Create a line edit to get the input from user
6. Create a label for count down of 30 seconds
Back-end implementation steps :
1. Create start flag, a list of colors, counter value variable and score value variable
2. Create a timer object which call a method after one second
3. Inside the timer method check for the start flag if its true set counter value to the counter label and decrement the count value
4. Check if counter variable is equal to zero then make the start flag false and make the line edit disable
5. Add action to the start button
6. Inside the start button action make the start value to true set count value to 30 and clear the line edit text
7. Get the random choice from the color list and set that color to the color label
8. Again get the random choice from the list and set that text to the label
9. Add action to the line edit when enter is pressed
10. Inside the action of line edit check for the entered text with the random choice if matches increment the score value and change the color label color and text with another random value.
Below is the implementation
Attention geek! Strengthen your foundations with the Python Programming Foundation Course and learn the basics.
To begin with, your interview preparations Enhance your Data Structures concepts with the Python DS Course. And to begin with your Machine Learning Journey, join the Machine Learning – Basic Level Course