I need help... why is the ball...
So this is the code:
from tkinter import * import random import time tk = Tk() # create toolkit object WIDTH=500 HEIGHT=500 canvas = Canvas(tk, width=WIDTH, height=HEIGHT) tk.title("2 Ball") canvas.pack() ball = canvas.create_oval(5,5, 30, 30, fill="blue") xs = 1 ys= 2 ball2=canvas.create_oval(5,5,30,30, fill="red") x=2 y=1 while True: canvas.move(ball, xs, ys) canvas.move(ball2, x, y) pos = canvas.coords(ball) pos2 = canvas.coords(ball2) if pos[0]<0 or pos[2]>WIDTH: xs=-xs if pos[1]<0 or pos[3]>HEIGHT: ys=-ys canvas.update() time.sleep(0.01) tk.mainloop()
The red ball went out of the window...
So how do I fix this?
Btw this is python
Voters
Fix it in tinkercad, then print it out. Btw how r u using tinkercad in repl python?
@TheBest156 NO
@TheBest156 this is python with tkinter