Skip to content

Instantly share code, notes, and snippets.

@kjanjua26
Created August 30, 2016 01:10
Show Gist options
  • Save kjanjua26/06b71caad8e2ab38be9181cf713b3bef to your computer and use it in GitHub Desktop.
Save kjanjua26/06b71caad8e2ab38be9181cf713b3bef to your computer and use it in GitHub Desktop.
A simple game which takes a random number from the random module and adds it to the health of the player and if the difficulty level is increased the lesser the health player gets.
import random
import tkinter
from tkinter import messagebox
health = 50
difficulty = input("Please input difficulty level: ")
difficulty = int(difficulty)
health_potion = random.randint(25, 50)
health = health + health_potion
health = int(health / difficulty)
def game():
messagebox.showinfo("The Answer is: ", health)
gui = tkinter.Tk()
gui.title('My Game')
Label = tkinter.Label(gui, text='This is the game')
Label.pack()
button1 = tkinter.Button(gui, text='Press to get the potion health', command=game)
button1.pack()
gui.mainloop()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment