def interface():
global root
global c
global ballplay_enable
root.title("Game Interface")
c.pack()
c.create_rectangle(0,0,510,290, fill = "#00BCD4", outline = "")
c.create_rectangle(0,0, 510,30, fill = "#4682B4", outline = "")
c.create_rectangle(10, 40, 35, 44, fill = "#F5F5F5", outline = "")
c.create_rectangle(10, 47, 35, 51, fill = "#F5F5F5", outline = "")
c.create_rectangle(10, 54, 35, 58, fill = "#F5F5F5", outline = "")
c.create_oval(330,240,430,340, fill = "#FF4081", outline = "")
c.create_line(330, 290, 430, 290, fill = "white")
font1 = tkFont.Font(size = 28, family = "Roboto", weight = tkFont.BOLD, overstrike = 0)
font2 = tkFont.Font(family = 'Roboto',size = 13)
c.create_text(235, 150, text = "Bouncing Ball",font = font1, fill = "white")
c.create_text(235, 180, text = "Powered by Python", font = font2, fill = "#B2EBF2")
c.create_text(235, 360, text = "Copyright©(2016)Gao Chao\n\nchoose the mode to start", font = font2, fill = "#B6B6B6")
c.create_text(380, 275, text = "Mode-1",font = font2, fill= "white")
c.create_text(380, 305, text = "Mode-2",font = font2, fill= "white")
c.bind("<Button-1>", out)
sb = []
for i in range(5):
sb.append(c.create_oval(15 * i, 435, 15 * i + 10, 445, fill = "#00BCD4", outline = ""))
x = [5, 15, 25, 35, 45]
speed = [0, 0, 0, 0, 0]
#ball play image
while ballplay_enable == 0:
for i in range(5):
speed[i] = (abs(250 - x[i]) + 200) / 35
x[i] += speed[i]
c.move(sb[i], speed[i], 0)
c.update()
if x[0] > 480:
for i in range(5):
c.delete(sb[i])
for i in range(5):
sb[i] = c.create_oval(15 * i,435,15 * i + 10,445, fill = "#00BCD4", outline = "")
x = [5, 15, 25, 35, 45]
sleep(0.04)
root.mainloop()
评论列表
文章目录