Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import Tkinter
- import time
- from random import *
- aimyon = Tkinter.Tk()
- rock = Tkinter.Canvas(aimyon ,width = 500, height = 500)
- rock.pack()
- x = 0
- y = 0
- bobo = rock.create_oval(225, 225, 275, 275 , fill='pink')
- xspeed = randint(1 ,5)
- yspeed = randint(1, 5)
- while True:
- rock.move(bobo, xspeed, yspeed)
- rock.update()
- time.sleep(0.01)
- if rock.coords(bobo)[0] < 1 :
- xspeed = randint(1, 5)
- if rock.coords(bobo)[2] > 499 :
- xspeed = -randint(1, 5)
- if rock.coords(bobo)[1] < 1 :
- yspeed = randint(1, 5)
- if rock.coords(bobo)[3] > 499 :
- yspeed = -randint(1, 5)
- aimyon.mainloop()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement