This is a simple rock paper scissors game implemented using Python and the tkinter module. The game allows the user to choose between rock, paper, and scissors and play against the computer. The rules of the game are defined in a dictionary, and the score is kept track of using variables.
- Clone or download the repository.
- Open the terminal and navigate to the directory where the file is located.
- Run the following command to start the game:
- A window will appear with the game interface.
- Click on the "Rock", "Paper", or "Scissors" button to make your choice.
- The computer will randomly choose its option.
- The result of the game will be displayed in the "Result" section and the scores will be updated accordingly in the "User" and "Computer" sections.
python rock_paper_scissors.py
The game code is implemented in Python and uses the tkinter module to create a GUI. The game logic is implemented in the play()
function which takes the user's choice as an argument. The function selects a random choice for the computer and then uses the rules dictionary to determine the result of the game. Depending on the result, the score and the result label are updated.
The GUI is created using the Tk()
function from the tkinter module. The labels and buttons are created using the Label()
and Button()
functions respectively. The buttons are bound to the play()
function using the command
parameter.
Finally, the mainloop()
of the window is started using the function which waits for user input and updates the window accordingly.