diff --git a/Games/Dice_rolling_simulator/README.md b/Games/Dice_rolling_simulator/README.md new file mode 100644 index 0000000000..51e88fc0b6 --- /dev/null +++ b/Games/Dice_rolling_simulator/README.md @@ -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 diff --git a/Games/Dice_rolling_simulator/dice_1.png b/Games/Dice_rolling_simulator/dice_1.png new file mode 100644 index 0000000000..7a2623ff08 Binary files /dev/null and b/Games/Dice_rolling_simulator/dice_1.png differ diff --git a/Games/Dice_rolling_simulator/dice_2.png b/Games/Dice_rolling_simulator/dice_2.png new file mode 100644 index 0000000000..6f04a93f11 Binary files /dev/null and b/Games/Dice_rolling_simulator/dice_2.png differ diff --git a/Games/Dice_rolling_simulator/dice_3.png b/Games/Dice_rolling_simulator/dice_3.png new file mode 100644 index 0000000000..cd4c14725f Binary files /dev/null and b/Games/Dice_rolling_simulator/dice_3.png differ diff --git a/Games/Dice_rolling_simulator/dice_4.png b/Games/Dice_rolling_simulator/dice_4.png new file mode 100644 index 0000000000..5cf0420bc4 Binary files /dev/null and b/Games/Dice_rolling_simulator/dice_4.png differ diff --git a/Games/Dice_rolling_simulator/dice_5.png b/Games/Dice_rolling_simulator/dice_5.png new file mode 100644 index 0000000000..113ee44b6a Binary files /dev/null and b/Games/Dice_rolling_simulator/dice_5.png differ diff --git a/Games/Dice_rolling_simulator/dice_6.png b/Games/Dice_rolling_simulator/dice_6.png new file mode 100644 index 0000000000..0d6c378c0d Binary files /dev/null and b/Games/Dice_rolling_simulator/dice_6.png differ diff --git a/Games/Dice_rolling_simulator/main3.py b/Games/Dice_rolling_simulator/main3.py new file mode 100644 index 0000000000..07fd4a4e5f --- /dev/null +++ b/Games/Dice_rolling_simulator/main3.py @@ -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() diff --git a/README.md b/README.md index 07c85a671e..1d6c8d66eb 100644 --- a/README.md +++ b/README.md @@ -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)| diff --git a/assets/images/Dice_Rolling_simulator_Game.png b/assets/images/Dice_Rolling_simulator_Game.png new file mode 100644 index 0000000000..370395801d Binary files /dev/null and b/assets/images/Dice_Rolling_simulator_Game.png differ