Advertisement
here2share

# R_U_fast_N_uff.py

Mar 26th, 2019
222
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.28 KB | None | 0 0
  1. # R_U_fast_N_uff.py
  2.  
  3. from Tkinter import *
  4. from random import *
  5. from time import *
  6.  
  7. class Run:
  8.     def __init__(self):
  9.         root = Tk()
  10.         frame = Frame(root)
  11.         root.geometry("280x280+{0}+{1}".format(
  12.             int(root.winfo_screenwidth() / 2 - 125),
  13.             int(root.winfo_screenheight() / 2 - 125)))
  14.         root.resizable(width=False, height=False)
  15.         root.title("R_U_fast_N_uff?")
  16.         root.bind("<Button-1>", self.do_event)
  17.         frame.pack()
  18.  
  19.         self.hello_b = Button(root,text="Quit",command=root.destroy)
  20.         self.hello_b.bind("<Enter>",self.jump)
  21.         self.hello_b.bind("<Motion>",self.jump)
  22.         self.hello_b.pack()
  23.         self.hello_b.place(x=20,y=20)
  24.        
  25.         root.protocol("WM_DELETE_WINDOW", lambda: None)
  26.  
  27.         self.counter = 0
  28.         self.speed = []
  29.         self.bounds = 240/5
  30.        
  31.         root.mainloop()
  32.        
  33.     def do_event(self, event):
  34.         self.counter = 0
  35.        
  36.     def jump(self, event):
  37.         total = 9
  38.         if self.counter != 30:
  39.             xx = randint(1,self.bounds)*5
  40.             yy = randint(1,self.bounds)*5
  41.             t = time()
  42.             if t not in self.speed:
  43.                 self.speed.append(t)
  44.                 if len(self.speed) > 6:
  45.                     self.speed.pop(0)
  46.                     total = (self.speed[-1]-self.speed[0])/6
  47.                 if total > 0.4:
  48.                     self.hello_b.place(x=xx,y=yy)
  49.                     self.counter += 1
  50.  
  51.  
  52. score = time()
  53. Run()
  54. print "You Got The Button At %.3f Seconds"%(time()-score)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement