Its all in the title, but this is not my code, I'm writing something similar for my homework but instead of random I will use a certain equation, I just want to see where I can implement a random statement to make the ball move back and forth.
from tkinter import *
import time
gui = Tk()
gui.geometry("800x800")
c = Canvas(gui ,width=800 ,height=800)
c.pack()
oval = c.create_oval(5,5,60,60,fill='pink')
xd = 5
yd = 10
while True:
c.move(oval,xd,yd)
p=c.coords(oval)
if p[3] >= 800 or p[1] <=0:
yd = -yd
if p[2] >=800 or p[0] <=0:
xd = -xd
gui.update()
time.sleep(0.025)
gui.title("First title")
gui.mainloop()
Aucun commentaire:
Enregistrer un commentaire