Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # R_U_fast_N_uff.py
- from Tkinter import *
- from random import *
- from time import *
- class Run:
- def __init__(self):
- root = Tk()
- frame = Frame(root)
- root.geometry("280x280+{0}+{1}".format(
- int(root.winfo_screenwidth() / 2 - 125),
- int(root.winfo_screenheight() / 2 - 125)))
- root.resizable(width=False, height=False)
- root.title("R_U_fast_N_uff?")
- root.bind("<Button-1>", self.do_event)
- frame.pack()
- self.hello_b = Button(root,text="Quit",command=root.destroy)
- self.hello_b.bind("<Enter>",self.jump)
- self.hello_b.bind("<Motion>",self.jump)
- self.hello_b.pack()
- self.hello_b.place(x=20,y=20)
- root.protocol("WM_DELETE_WINDOW", lambda: None)
- self.counter = 0
- self.speed = []
- self.bounds = 240/5
- root.mainloop()
- def do_event(self, event):
- self.counter = 0
- def jump(self, event):
- total = 9
- if self.counter != 30:
- xx = randint(1,self.bounds)*5
- yy = randint(1,self.bounds)*5
- t = time()
- if t not in self.speed:
- self.speed.append(t)
- if len(self.speed) > 6:
- self.speed.pop(0)
- total = (self.speed[-1]-self.speed[0])/6
- if total > 0.4:
- self.hello_b.place(x=xx,y=yy)
- self.counter += 1
- score = time()
- Run()
- print "You Got The Button At %.3f Seconds"%(time()-score)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement