【发布时间】:2021-02-02 14:37:15
【问题描述】:
我正在编写一个简单的程序,我希望(球图像 png)在其中从墙上反弹。到目前为止,我已经写了这段代码:
import tkinter as tk
root = tk.Tk()
WIDTH = 500
HEIGHT = 500
canvas = tk.Canvas(root,bg="white",width=WIDTH,height=HEIGHT)
canvas.pack()
img = tk.PhotoImage(file="images/ball1.png")
ball = canvas.create_image(0,0,anchor="nw",image=img)
yspeed = 2
xspeed = 2
def move_ball():
global xspeed,yspeed,ball
canvas.move(ball,xspeed,yspeed)
canvas.after(10,move_ball)
move_ball()
root.mainloop()
【问题讨论】:
-
似乎没有任何代码让您尝试进行任何类型的边缘检测。
标签: python image animation tkinter png