Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # Tk_ball_velocity.py
- from Tkinter import *
- root = Tk()
- root.geometry("%dx%d+%d+%d" % (480, 540, 10, 10))
- canvas = Canvas(root, bg='green')
- canvas.pack(fill=BOTH, expand=1)
- class Cv():
- x = 0
- y = 0
- cv=Cv()
- canvas.create_oval(50,50,100,100,fill="orange",tag="ball")
- def mv():
- x = cv.x * 0.02
- y = cv.y * 0.02
- cv.x -= x
- cv.y -= y
- if max(cv.x,cv.y) < 0.5:
- cv.x = 300
- cv.y = 400
- canvas.delete("ball")
- canvas.create_oval(50,50,100,100,fill="orange",tag="ball")
- canvas.move("ball", x, y)
- canvas.update()
- root.after(1, mv)
- mv()
- root.mainloop()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement