Skip to content

Commit

Permalink
Merge pull request #4759 from priyashuu/main
Browse files Browse the repository at this point in the history
New Game:-Dice_Rolling_simulator
  • Loading branch information
kunjgit authored Jul 9, 2024
2 parents ed7c886 + 8f7cd11 commit c77066f
Show file tree
Hide file tree
Showing 10 changed files with 126 additions and 0 deletions.
65 changes: 65 additions & 0 deletions Games/Dice_rolling_simulator/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
### Description
The dice rolling simulator is a simple application built using Python and the Tkinter library for the graphical user interface (GUI). The simulator mimics the action of rolling a dice, providing a random outcome between 1 and 6 each time the user interacts with the interface. This application is useful for games, educational purposes, or simply for fun.

### Game_Logic

- Initialization: When the program starts, it initializes the main window using Tkinter.
- Dice Roll: A function generates a random number between 1 and 6 using Python's random module.
- Display: The result of the dice roll is displayed on the GUI, typically as a number or a graphical representation of a dice face.
- Interaction: The user can roll the dice by clicking a button on the GUI, which triggers the dice roll function.

### FEATURES
Random Dice Roll: Uses the random.randint(1, 6) function to generate a number between 1 and 6.
Graphical Interface: A user-friendly interface built with Tkinter, making it easy to interact with the simulator.
Roll Button: A button that the user clicks to roll the dice.
Display Area: Shows the result of the dice roll, either as a numeric value or a visual representation.

### Screenshot![Dice_Rolling_simulator_Game](https://github.com/priyashuu/GameZone/assets/150767072/46569298-3844-4240-a3c3-544fc47c524e)
### Video

https://github.com/priyashuu/GameZone/assets/150767072/0d88b796-9125-4bf4-bb58-7178a456ecc8




### Tech Stack Overview

The dice rolling simulator utilizes a combination of technologies and libraries to create a functional and interactive application. Below is a breakdown of the tech stack used:

#### **Programming Language:**
- **Python**

#### **Graphical User Interface (GUI):**
- **Tkinter**

#### **Libraries and Modules:**
- **Random**

#### **Development Environment:**
- **IDLE**
- **VS Code**
#### **Version Control:**
- **Git**
- **GitHub**
### Example of Tech Stack in Action
1. **Python**: The logic of the dice roll is implemented in Python using simple functions and conditional statements.
2. **Tkinter**: Used to create the main window, buttons, and labels that make up the user interface.
3. **Random Module**: Utilized within the dice roll function to generate a random number between 1 and 6 each time the user clicks the roll button.
4. **Git and GitHub**: The code is version-controlled using Git and hosted on GitHub, making it easy to share and collaborate with others.

### Installation Instructions
1. **Install Python**: Download and install Python from [python.org](https://www.python.org/).
2. **Install Tkinter**: Tkinter is included with Python, so no additional installation is required.
3. **Clone the Repository**: If the project is hosted on GitHub, clone the repository using Git.
```bash
git clone https://github.com/username/repository-name.git
```
4. **Run the Application**: Navigate to the project directory and run the Python script.
```bash
cd repository-name
python dice_simulator.py
```
<<<<<<< HEAD

=======
>>>>>>> priyashuu-patch-1
Binary file added Games/Dice_rolling_simulator/dice_1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Games/Dice_rolling_simulator/dice_2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Games/Dice_rolling_simulator/dice_3.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Games/Dice_rolling_simulator/dice_4.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Games/Dice_rolling_simulator/dice_5.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Games/Dice_rolling_simulator/dice_6.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
60 changes: 60 additions & 0 deletions Games/Dice_rolling_simulator/main3.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
import tkinter as tk
from PIL import Image, ImageTk
import random
import time
import os

# Initialize the Tkinter window
window = tk.Tk()
window.geometry("500x360")
window.title("Dice Roll")
window.configure(bg='black')

# Define a list of dice images
dice = ["dice_1.png", "dice_2.png", "dice_3.png", "dice_4.png", "dice_5.png", "dice_6.png"]

# Verify that all dice images exist
for dice_image in dice:
if not os.path.exists(dice_image):
print(f"Error: {dice_image} not found.")
exit()

# Define a list of colors for the animation
colors = ['red', 'orange', 'yellow', 'green', 'blue', 'purple', 'pink']

# Choose a random image for each dice and display them initially on the window
image1 = ImageTk.PhotoImage(Image.open(random.choice(dice)))
image2 = ImageTk.PhotoImage(Image.open(random.choice(dice)))
label1 = tk.Label(window, image=image1, bg='black')
label2 = tk.Label(window, image=image2, bg='black')
label1.image = image1
label2.image = image2
label1.place(x=40, y=100)
label2.place(x=900, y=100)

# Define a function named "dice_roll" with animation
def dice_roll():
for _ in range(10): # Number of frames in the animation
color = random.choice(colors) # Choose a random color for the background
image1 = ImageTk.PhotoImage(Image.open(random.choice(dice)))
label1.configure(image=image1, bg=color)
label1.image = image1
image2 = ImageTk.PhotoImage(Image.open(random.choice(dice)))
label2.configure(image=image2, bg=color)
label2.image = image2
window.update() # Update the window to show changes
time.sleep(0.1) # Pause to create animation effect
# Set the final images and background to black after animation
image1 = ImageTk.PhotoImage(Image.open(random.choice(dice)))
label1.configure(image=image1, bg='black')
label1.image = image1
image2 = ImageTk.PhotoImage(Image.open(random.choice(dice)))
label2.configure(image=image2, bg='black')
label2.image = image2

# Define a button widget labeled "ROLL" with green background and white text, positioned at the top of the window
button = tk.Button(window, text="ROLL", bg="green", fg="white", font="Times 20 bold", command=dice_roll)
button.place(x=660, y=10)

# Display the Tkinter window and wait for user interaction
window.mainloop()
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -865,6 +865,7 @@ This repository also provides one such platforms where contributers come over an
| [IKnowYou-Mind-Reading-Game](https://github.com/kunjgit/GameZone/tree/main/Games/IKnowYou-Mind-Reading-Game) |
| [Tic_Tac_Toe_Neon](https://github.com/kunjgit/GameZone/tree/main/Games/Tic_Tac_Toe_Neon) | [Magic_8_ball_Game](https://github.com/kunjgit/GameZone/tree/main/Games/Magic_8_ball) |
| [Catch_Craze](https://github.com/kunjgit/GameZone/tree/main/Games/Catch_Craze) |
|[Dice_Rolling_Simulator](https://github.com/priyashuu/GameZone/tree/main/Games/Dice_rolling_simulator)|
|[Space_Dominators](https://github.com/kunjgit/GameZone/tree/main/Games/Space_Dominators)|
</center>

Expand Down
Binary file added assets/images/Dice_Rolling_simulator_Game.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit c77066f

Please sign in to comment.