Skip to content

Commit

Permalink
Add files via upload
Browse files Browse the repository at this point in the history
This virtual game emulates the real-world dice-rolling mechanics and offers players an engaging platform to enjoy various dice games without the need for physical dice. Whether you're a seasoned board gamer or someone looking for a casual pastime, the Virtual Dice Rolling Game is designed to provide hours of fun and excitement.
  • Loading branch information
Anirudh99N committed Jul 28, 2023
0 parents commit 2136295
Show file tree
Hide file tree
Showing 7 changed files with 40 additions and 0 deletions.
Binary file added my python projects/Roll-a-Dice/D1.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 my python projects/Roll-a-Dice/D2.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 my python projects/Roll-a-Dice/D3.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 my python projects/Roll-a-Dice/D4.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 my python projects/Roll-a-Dice/D5.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 my python projects/Roll-a-Dice/D6.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
40 changes: 40 additions & 0 deletions my python projects/Roll-a-Dice/Roll-a-Dice.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
import tkinter as tk #here we are importing the tkinter which is a standard GUI library for python used for crating Graphic User Interface .
from PIL import Image , ImageTk # we are using Pillow library which is an imaging library .
import random

window = tk.Tk()
window.geometry("1000x720")
window.title("Roll-a-Dice: Your Virtual dice Rolling Companion")



dice= ["D1.png","D2.png","D3.png","D4.png","D5.png","D6.png"]

image1 = ImageTk.PhotoImage(Image.open(random.choice(dice)))
image2 = ImageTk.PhotoImage(Image.open(random.choice(dice)))

label1 = tk.Label(window, image = image1)
label2 = tk.Label(window, image = image2)


label1.image=image1
label2.image=image2

label1.place(x=20 , y=200)
label2.place(x=570,y=200)

#givng the command to the ROLL button

def dice_roll():
image1= ImageTk.PhotoImage(Image.open(random.choice(dice)))
label1.configure(image=image1)
label1.image=image1

image2= ImageTk.PhotoImage(Image.open(random.choice(dice)))
label2.configure(image=image2)
label2.image=image2

button = tk.Button(window, text='ROLL' , bg='green', fg='yellow', font="Times 20 bold", command=dice_roll)
button.place(x=450 , y=0)

window.mainloop()

0 comments on commit 2136295

Please sign in to comment.