Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Save New Duplicate & Edit Just Text
- from tkinter import *
- from random import randint
- import time
- location = [0,0]
- window = Tk()
- Direction = "none"
- Gold = 0
- window.geometry("1000x800")
- window.title("Wander")
- def GoldF():
- global Gold
- global GCount
- global GLabel
- Gold = Gold + 5
- GCount.grid()
- GCount.delete(0.0, END)
- GCount.insert(END, Gold)
- GLabel.grid()
- Start()
- def Found():
- global Gold
- global GCount
- chance = randint(1, 5)
- if chance == 1:
- W.delete(0.0, END)
- W.insert(END,"You find some gold as you travel")
- North.grid_remove()
- South.grid_remove()
- West.grid_remove()
- East.grid_remove()
- GButton.grid()
- else:
- Start()
- def Display():
- global Direction
- Loc.delete(0.0, END)
- location[0] = str(location[0])
- location[1] = str(location[1])
- Loc.insert(END, location[0]+","+location[1])
- W.delete(0.0, END)
- W.insert(END,"You traveled", Direction)
- time.sleep(3)
- Found()
- def WanderNorth():
- global location
- global Direction
- MovementV = randint(1, 3)
- Vmove = location[1]
- Nomove = location[0]
- Vmove = int(Vmove)
- Nomove = int(Nomove)
- Vmove = Vmove + MovementV
- location = [Nomove,Vmove]
- print(location)
- Direction = "North"
- Display()
- def WanderEast():
- global location
- global Direction
- MovementH = randint(1, 3)
- Hmove = location[0]
- Nomove = location[1]
- Hmove = int(Hmove)
- Nomove = int(Nomove)
- Hmove = Hmove + MovementH
- location = [Hmove,Nomove]
- print(location)
- Direction = "East"
- Display()
- def WanderSouth():
- global location
- global Direction
- MovementV = randint(1, 3)
- Vmove = location[1]
- Nomove = location[0]
- Vmove = int(Vmove)
- Nomove = int(Nomove)
- Vmove = Vmove - MovementV
- location = [Nomove,Vmove]
- print(location)
- Direction = "South"
- Display()
- def WanderWest():
- global location
- global Direction
- MovementH = randint(1, 3)
- Hmove = location[0]
- Nomove = location[1]
- Hmove = int(Hmove)
- Nomove = int(Nomove)
- Hmove = Hmove - MovementH
- location = [Hmove,Nomove]
- print(location)
- Direction = "West"
- Display()
- W = Text(window, width=30, height=5, wrap=WORD, bg="Pink")
- W.grid(row=1, column=1, columnspan=6, rowspan=5)
- Loc = Text(window, width=9, height=1, wrap=WORD, bg ="Cyan")
- Loc.grid(row=2, column=7, sticky="n")
- GCount = Text(window, width=3, height=1, wrap=WORD, bg="Yellow")
- GCount.grid(row=2, column=8, stick="n")
- GButton = Button(window, text="Pickup", width=5, command=GoldF)
- GButton.grid(row=3, column=8, rowspan=2, columnspan=1, sticky="n")
- GLabel = Label(window, text= "Gold")
- GLabel.grid(row=1, column=8, stick="n")
- LocNot = Label(window, text= "Location")
- LocNot.grid(row=1, column=7, stick="n")
- North = Button(window, text="North", width=5, command=WanderNorth)
- North.grid(row=6, column=1, rowspan=2, columnspan=1, sticky="w")
- East = Button(window, text="East", width=5, command=WanderEast)
- East.grid(row=6, column=5, rowspan=2, columnspan=1, sticky="e")
- South = Button(window, text="South", width=5, command=WanderSouth)
- South.grid(row=6, column=2, rowspan=2, columnspan=1, sticky="w")
- West = Button(window, text="West", width=5, command=WanderWest)
- West.grid(row=6, column=6, rowspan=2, columnspan=1, sticky="e")
- def Start():
- North.grid()
- South.grid()
- West.grid()
- East.grid()
- GButton.grid_remove()
- W.delete(0.0, END)
- W.insert(0.0, "Which way do you want to travel?")
- W.delete(2.0, 3.0)
- def Hide():
- GCount.grid_remove()
- GCount.delete(0.0, END)
- GLabel.grid_remove()
- GButton.grid_remove()
- Start()
- Hide()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement