In this game player has to enter color of the word that appears on the screen and hence the score increases by one, the total time to play this game is 60 seconds
I have imported tkinter the GUI itself and random to randomly select the color from the list.
When the player clicks on the start button, the startGame() function will be called. this function first checks whether the timer is equal to 60 or not. Previously I have set timer variable to 60. if the timer variable is equal to 60 then another function startCountDown() will be called to start counting from 60 to 0.
After calling the startCountDown() function a random color from the colors list will be fetched and shown to the user with a different text color
startCountDown() function will just count from 60 to 0 and when the counter hits 0 it will display a message “Game Over!!!” to the player.
And have written another function called displayNextWord(). The purpose of this function is to display a new word every time the player submits his answer and increment the score if the player enters the correct answer. And repeat this process until the timer gets to zero.
We have also defined a reset button in our interface. When the player clicks on this reset button resetGame() function will be called. This function will simply set the timer variable to 60 and sets the score variable to 0. And updates the same in the UI.
Submitted by Vimal (Vimalarun)
Download packets of source code on Coders Packet