Skip to content

Commit 557e6a2

Browse files
authored
Add files via upload
1 parent fb14133 commit 557e6a2

File tree

8 files changed

+125
-0
lines changed

8 files changed

+125
-0
lines changed

Dice_Rolling_Simulator/README.md

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
### Description
2+
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.
3+
4+
### Game_Logic
5+
6+
- Initialization: When the program starts, it initializes the main window using Tkinter.
7+
- Dice Roll: A function generates a random number between 1 and 6 using Python's random module.
8+
- Display: The result of the dice roll is displayed on the GUI, typically as a number or a graphical representation of a dice face.
9+
- Interaction: The user can roll the dice by clicking a button on the GUI, which triggers the dice roll function.
10+
11+
### FEATURES
12+
Random Dice Roll: Uses the random.randint(1, 6) function to generate a number between 1 and 6.
13+
Graphical Interface: A user-friendly interface built with Tkinter, making it easy to interact with the simulator.
14+
Roll Button: A button that the user clicks to roll the dice.
15+
Display Area: Shows the result of the dice roll, either as a numeric value or a visual representation.
16+
17+
### Screenshot![Dice_Rolling_simulator_Game](https://github.com/priyashuu/GameZone/assets/150767072/46569298-3844-4240-a3c3-544fc47c524e)
18+
### Video
19+
20+
https://github.com/priyashuu/GameZone/assets/150767072/0d88b796-9125-4bf4-bb58-7178a456ecc8
21+
22+
23+
24+
25+
### Tech Stack Overview
26+
27+
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:
28+
29+
#### **Programming Language:**
30+
- **Python**
31+
32+
#### **Graphical User Interface (GUI):**
33+
- **Tkinter**
34+
35+
#### **Libraries and Modules:**
36+
- **Random**
37+
38+
#### **Development Environment:**
39+
- **IDLE**
40+
- **VS Code**
41+
#### **Version Control:**
42+
- **Git**
43+
- **GitHub**
44+
### Example of Tech Stack in Action
45+
1. **Python**: The logic of the dice roll is implemented in Python using simple functions and conditional statements.
46+
2. **Tkinter**: Used to create the main window, buttons, and labels that make up the user interface.
47+
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.
48+
4. **Git and GitHub**: The code is version-controlled using Git and hosted on GitHub, making it easy to share and collaborate with others.
49+
50+
### Installation Instructions
51+
1. **Install Python**: Download and install Python from [python.org](https://www.python.org/).
52+
2. **Install Tkinter**: Tkinter is included with Python, so no additional installation is required.
53+
3. **Clone the Repository**: If the project is hosted on GitHub, clone the repository using Git.
54+
```bash
55+
git clone https://github.com/username/repository-name.git
56+
```
57+
4. **Run the Application**: Navigate to the project directory and run the Python script.
58+
```bash
59+
cd repository-name
60+
python dice_simulator.py
61+
```
62+
<<<<<<< HEAD
63+
64+
=======
65+
>>>>>>> priyashuu-patch-1

Dice_Rolling_Simulator/dice_1.png

10.7 KB
Loading

Dice_Rolling_Simulator/dice_2.png

12.7 KB
Loading

Dice_Rolling_Simulator/dice_3.png

15.1 KB
Loading

Dice_Rolling_Simulator/dice_4.png

13.8 KB
Loading

Dice_Rolling_Simulator/dice_5.png

16 KB
Loading

Dice_Rolling_Simulator/dice_6.png

16.3 KB
Loading

Dice_Rolling_Simulator/main3.py

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
import tkinter as tk
2+
from PIL import Image, ImageTk
3+
import random
4+
import time
5+
import os
6+
7+
# Initialize the Tkinter window
8+
window = tk.Tk()
9+
window.geometry("500x360")
10+
window.title("Dice Roll")
11+
window.configure(bg='black')
12+
13+
# Define a list of dice images
14+
dice = ["dice_1.png", "dice_2.png", "dice_3.png", "dice_4.png", "dice_5.png", "dice_6.png"]
15+
16+
# Verify that all dice images exist
17+
for dice_image in dice:
18+
if not os.path.exists(dice_image):
19+
print(f"Error: {dice_image} not found.")
20+
exit()
21+
22+
# Define a list of colors for the animation
23+
colors = ['red', 'orange', 'yellow', 'green', 'blue', 'purple', 'pink']
24+
25+
# Choose a random image for each dice and display them initially on the window
26+
image1 = ImageTk.PhotoImage(Image.open(random.choice(dice)))
27+
image2 = ImageTk.PhotoImage(Image.open(random.choice(dice)))
28+
label1 = tk.Label(window, image=image1, bg='black')
29+
label2 = tk.Label(window, image=image2, bg='black')
30+
label1.image = image1
31+
label2.image = image2
32+
label1.place(x=40, y=100)
33+
label2.place(x=900, y=100)
34+
35+
# Define a function named "dice_roll" with animation
36+
def dice_roll():
37+
for _ in range(10): # Number of frames in the animation
38+
color = random.choice(colors) # Choose a random color for the background
39+
image1 = ImageTk.PhotoImage(Image.open(random.choice(dice)))
40+
label1.configure(image=image1, bg=color)
41+
label1.image = image1
42+
image2 = ImageTk.PhotoImage(Image.open(random.choice(dice)))
43+
label2.configure(image=image2, bg=color)
44+
label2.image = image2
45+
window.update() # Update the window to show changes
46+
time.sleep(0.1) # Pause to create animation effect
47+
# Set the final images and background to black after animation
48+
image1 = ImageTk.PhotoImage(Image.open(random.choice(dice)))
49+
label1.configure(image=image1, bg='black')
50+
label1.image = image1
51+
image2 = ImageTk.PhotoImage(Image.open(random.choice(dice)))
52+
label2.configure(image=image2, bg='black')
53+
label2.image = image2
54+
55+
# Define a button widget labeled "ROLL" with green background and white text, positioned at the top of the window
56+
button = tk.Button(window, text="ROLL", bg="green", fg="white", font="Times 20 bold", command=dice_roll)
57+
button.place(x=660, y=10)
58+
59+
# Display the Tkinter window and wait for user interaction
60+
window.mainloop()

0 commit comments

Comments
 (0)